-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
61 lines (56 loc) · 1.84 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
#include <iostream>
#include "GameManager.h"
#include "helper/input/Input.h"
#include "helper/rendering/SpriteManager.h"
#include "Entity.h"
#include "components/Component.h"
#include "components/TransformComponent.h"
#include "components/SpriteComponent.h"
#include "systems/PrintTransformSystem.h"
#include "systems/RenderSystem.h"
using namespace std;
int main()
{
GameManager gm;
RenderSystem rs(gm);
SpriteManager sm;
Sprite* s = sm.loadSprite("data/sprites/HorrifyingSmiley.png");
Sprite* s2 = sm.loadSprite("data/sprites/Circle.png");
//PrintTransformSystem pts(gm);
//gm.addSystem(pts);
gm.addSystem(rs);
Entity& player = gm.createEntity("player");
TransformComponent* tc = gm.addComponentToEntity<TransformComponent>(player);
tc->position.x = 100;
tc->position.y = 100;
SpriteComponent* sc = gm.addComponentToEntity<SpriteComponent>(player);
sc->sprite = s;
Entity& test2 = gm.createEntity("test2");
//Might as well reuse these
tc = gm.addComponentToEntity<TransformComponent>(test2);
tc->position.x = 500;
tc->position.y = 150;
sc = gm.addComponentToEntity<SpriteComponent>(test2);
sc->sprite = s2;
Input::initInput();
Input::addMapping("Up", 'W');
Input::addMapping("Up", Input::Keys::UP);
Input::addMapping("Down", 'S');
Input::addMapping("Down", Input::Keys::DOWN);
Input::addMapping("Exit", 'Q');
Input::addMapping("Exit", 'P');
Input::addMapping("Exit", Input::Keys::ESC);
for(int i =0; i < 10; i++){
Entity& e = gm.createEntity("whatevs");
TransformComponent* tComp = gm.addComponentToEntity<TransformComponent>(e);
tComp->position.x = (i * 100);// % 800;
tComp->position.y = (i * 100);// % 600;
SpriteComponent* spr = gm.addComponentToEntity<SpriteComponent>(e);
if(i % 2 == 0)
spr->sprite = s2;
else
spr->sprite = s;
spr->layer = i;
}
gm.run();
}