-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (52 loc) · 1.65 KB
/
main.cpp
File metadata and controls
52 lines (52 loc) · 1.65 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
#include"Train.h"
#include"Graphics.h"
#include<SFML/Graphics.hpp>
void main()
{
sf::RenderWindow window(sf::VideoMode(1200, 700), "Fast Express");
Train train_Obj(&window);
Graphics handle(window,train_Obj);
while (window.isOpen())
{
sf::Event Event;
//Event Loop:
while (window.pollEvent(Event))
{
switch (Event.type)
{
case sf::Event::Closed:
{
window.close();
}
case sf::Event::MouseMoved://when mouse is moved
{
handle.MouseMoved();
break;
}
case sf::Event::MouseButtonPressed://when mouse button is pressed
{
handle.MouseButtonsPressed();
break;
}
case sf::Event::TextEntered://when text is entered. This also checks a few conditions
{
if ((handle.btn_num > 1) && (handle.btn_num < 8))//if buttons from 2 to 7 are selected
{
if (!handle.ret)
{
handle.id_Text.typedOn(Event);//if text is typed on the space
}
else
{
handle.id_Text.setSelected(false);
}
}
break;
}
}
window.clear();
handle.Draw();
window.display();
}
}
}