-
Notifications
You must be signed in to change notification settings - Fork 4
/
gameplay.h
36 lines (28 loc) · 673 Bytes
/
gameplay.h
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
#ifndef GAMEPLAY_H
#define GAMEPLAY_H
#include <QObject>
#include <QGraphicsScene>
class QGraphicsItem;
class QTimer;
class Gameplay : public QObject
{
Q_OBJECT
public:
explicit Gameplay(QGraphicsScene & scene, QGraphicsItem *p1, QGraphicsItem *p2, QGraphicsItem *ball, QObject *parent);
protected:
virtual bool eventFilter(QObject *, QEvent *);
signals:
void goal(int player);
private slots:
void tick();
private:
qreal calculateP2Direction();
private:
QGraphicsScene & iScene;
QGraphicsItem *iP1, *iP2, *iBall;
QTimer *iTimer;
QPointF iBallDirection;
qreal iP1Direction;
qreal iP2Direction;
};
#endif // GAMEPLAY_H