This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
motion.h
87 lines (65 loc) · 1.53 KB
/
motion.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
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
#ifndef MOTION_H
#define MOTION_H
#include <SFML/Graphics.hpp>
#include "math.h"
#include "iostream"
class Motion
{
public:
Motion();
virtual sf::Vector2f getNext(float speed)=0;
float getX() const;
void setX(float value);
void setReverseDirection(bool value);
protected:
float x= 0;
int direction=1;
bool reverseDirection() const;
};
class SimpleMotion : public Motion{
public:
SimpleMotion();
sf::Vector2f getNext(float speed);
};
class LinearMotion : public Motion{
public:
LinearMotion(float angle);
sf::Vector2f getNext(float speed);
protected:
float angle;
};
class SinMotion : public Motion{
public:
SinMotion(int scale);
sf::Vector2f getNext(float speed);
protected:
int scale;
};
class FollowerMotion : public Motion{
public:
FollowerMotion(sf::Sprite *owner,sf::Sprite *target);
sf::Vector2f getNext(float speed);
sf::Sprite *getTarget() const;
void setTarget(sf::Sprite *value);
sf::Sprite *getOwner() const;
void setOwner(sf::Sprite *value);
protected:
sf::Sprite *owner;
sf::Sprite *target;
};
class BossMotion : public Motion{
public:
BossMotion(int scale, int yMovement);
sf::Vector2f getNext(float speed);
protected:
int scale;
int yMovement;
};
namespace MotionFactory{
Motion *createSimpleMotion();
Motion *createLinearMotion(float angle);
Motion *createSinMotion(int scale);
Motion *createFollowerMotion(sf::Sprite *owner,sf::Sprite *target);
Motion *createBossMotion(int scale, int yMovement);
}
#endif // MOTION_H