-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
72 lines (53 loc) · 1.55 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
// main.cpp
// Defines the entry point of the application
#include <SFML/Graphics.hpp>
#include <SFML/Graphics/Color.hpp> // for use of Color class
#include <SFML/Graphics/Image.hpp>
#include <iostream> // For the cout
#include <unistd.h>
#include "animationhelper.h"
#include "rtscursor.h"
#include "rtssoldier.h"
#include "rtsunit.h"
using namespace sf;
int main()
{
RenderWindow window(sf::VideoMode(1024, 768), "Pixel Battle");
window. setFramerateLimit(60);
window.setMouseCursorVisible(false);
AnimationHelper::Instance()->setSheet("sprites/sheet.png");
RTSCursor cursor(&window);
RectangleShape bg;
bg.setSize(sf::Vector2f(1024, 768));
bg.setFillColor(Color(100,181,59));
// Soldier declarations
RTSSoldier one(&window);
one.setTeamColor(AnimationHelper::spriteColor::Blue);
one.setPosition(20,20);
one.setTarget(20,20);
RTSSoldier two(&window);
two.setTeamColor(AnimationHelper::spriteColor::Blue);
two.setPosition(500,400);
two.setTarget(500,400);
RTSUnit unit;
unit.addMovable(&one);
unit.addMovable(&two);
unit.setTargets(50,50);
unsigned long frameCount = 0;
// Game loop n shit
while (window.isOpen()){
// Window-closing events
Event event;
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
window.close();
}
window.draw(bg);
unit.drawMovables(frameCount);
cursor.draw();
window.display();
frameCount++;
}
return 0;
}