/
main.cpp
101 lines (85 loc) · 1.58 KB
/
main.cpp
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
#include "Game.h"
#include "Logger.h"
class Player : public Entity{
public:
Player(std::string fileName)
:Entity(fileName)
//,topDown(this)
, platform(this)
, scrollTo(this){
setPosition(sf::Vector2f(300, 100));
setMovementSpeed(100);
}
void update(float dt){
//topDown.update(dt);
platform.update(dt);
scrollTo.update(dt);
}
//TopDown topDown;
Platform platform;
ScrollTo scrollTo;
};
class Wall : public Entity{
public:
Wall(std::string fileName)
:Entity(fileName){
isSolid = true;
}
void update(float dt){
}
};
class Missile : public Entity{
public:
Missile(std::string fileName)
:Entity(fileName),
bullet(this),
dol(this){
bullet.setSpeed(1000);
}
void update(float dt){
bullet.update(dt);
dol.update(dt);
}
Bullet bullet;
DestroyOutsideLayout dol;
};
class MyGame : public Game{
public:
GameState state;
Player player;
Missile missile;
Mouse mouse;
Wall wall1;
//std::vector<Wall*> myWalls;
MyGame() : Game(),
state("Map3.config"),
player("blue.png"),
missile("bullet.png"),
wall1("box.png")
{
//myWalls.resize(40);
//for(int i = 0; i < 40; i++){
// Wall* wall = new Wall("box.png");
// wall->setPosition(sf::Vector2f(i * 70, 640));
// myWalls.push_back(wall);
//}
wall1.setPosition(sf::Vector2f(260, 240));
addState(&state);
addEntity(&wall1);
addEntity(&player);
addEntity(&missile);
}
void OnStart(){
//for(int i = 0; i < 40; i++){
// addEntity(myWalls[i]);
//}
player.scrollTo.setWindow(this->getWindow());
}
void OnUpdate(){
}
};
int main(){
MyGame game;
game.run();
return 0;
}