-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimatedObject.h
More file actions
102 lines (78 loc) · 2 KB
/
AnimatedObject.h
File metadata and controls
102 lines (78 loc) · 2 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// AnimatedObject.h
// Template Project
//
// Created by Jean-Yves Hervé on 2023-10-17.
//
#ifndef ANIMATED_OBJECT_H
#define ANIMATED_OBJECT_H
#include "Object.h"
namespace earshooter
{
class AnimatedObject : public virtual Object
{
private:
float velocity_, vx_, vy_, spin_;
public:
AnimatedObject(float x, float y, float angle, float vx, float vy, float spin);
AnimatedObject(const WorldPoint& pt, float angle, const Velocity& vel, float spin);
//disabled constructors & operators
AnimatedObject() = delete;
AnimatedObject(const AnimatedObject& obj) = delete; // copy
AnimatedObject(AnimatedObject&& obj) = delete; // move
AnimatedObject& operator = (const AnimatedObject& obj) = delete; // copy operator
AnimatedObject& operator = (AnimatedObject&& obj) = delete; // move operator
virtual void update(float dt);
inline void setSpeed(float speed)
{
vx_ = speed;
vy_ = speed;
}
// set velocity with speed and angle in radians.
inline float getVelocity()
{
return velocity_;
}
// set velocity with speed and angle in radians.
inline void setVelocity(float speed, float angle)
{
velocity_ = speed;
vx_ = speed * cosf(angle);
vy_ = speed * sinf(angle);
}
// set velocity with speed and angle in radians.
inline void setVelocityWithGraphicObjectAngle(float speed)
{
velocity_ = speed;
vx_ = speed * cosf((getAngle() + 90)*(M_PI/180));
// std::cout << "vx_" << vx_ << " | ";
vy_ = speed * sinf((getAngle() + 90)*(M_PI/180));
// std::cout << "vy_" << vy_ << std::endl;
}
inline float getSpeedX() const
{
return vx_;
}
inline void setSpeedX(float vx)
{
vx_ = vx;
}
inline float getSpeedY() const
{
return vy_;
}
inline void setSpeedY(float vy)
{
vy_ = vy;
}
inline float getSpin() const
{
return spin_;
}
inline void setSpin(float spin)
{
spin_ = spin;
}
};
}
#endif // ANIMATED_OBJECT_H