blob: 44654f66470231def614b6bee8e6dd475b433588 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef CAR_H
#define CAR_H
#include <QGraphicsObject>
#include <QBrush>
class Car : public QGraphicsObject
{
Q_OBJECT
public:
Car();
QRectF boundingRect() const;
public Q_SLOTS:
void accelerate();
void decelerate();
void turnLeft();
void turnRight();
Q_SIGNALS:
void crashed();
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr);
void timerEvent(QTimerEvent *event);
private:
QBrush color;
qreal wheelsAngle; // used when applying rotation
qreal speed; // delta movement along the body axis
};
#endif // CAR_H
|