-
Notifications
You must be signed in to change notification settings - Fork 0
/
ball.h
44 lines (34 loc) · 844 Bytes
/
ball.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
37
38
39
40
41
42
43
44
#ifndef BALL_H
#define BALL_H
#include "settings.h"
#include <QGraphicsRectItem>
#include <QObject>
#include <QGraphicsItem>
class QMediaPlayer;
class Ball : public QObject, public QGraphicsRectItem
{
Q_OBJECT
private:
double speed = Global::Height/343.0 * Global::ballSpeedConst;
double dx = speed * 1.80;
double dy = random(-speed,speed);
Side Turn = Left;
QMediaPlayer *reflect_sound;
public:
Ball(QGraphicsItem *parent = nullptr);
~Ball() = default;
void move();
double getDX() const;
void resize();
void setVolume(int sound); //set volume
void changeTurn();
public slots:
void reflectX();
void reflectY();
void changeDY(); //random change after racket collision
void soundPlay();
signals:
void ballMovedUp();
void ballMovedDown();
};
#endif // BALL_H