-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
78 lines (58 loc) · 1.26 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
#include <SFML/Graphics.hpp>
#include <SFML/Window/Export.hpp>
#include <SFML/Window/Mouse.hpp>
#include <iostream>
#include "Menu.h"
int main()
{
sf::RenderWindow window (sf::VideoMode(587, 544), "* SFML *");
Menu menu(window.getSize().x, window.getSize().y);
sf::Texture texture;
if(!texture.loadFromFile("/home/aeinsara/Desktop/menu/menu1.png")){}
sf::Sprite sprite(texture);
sprite.setTexture(texture);
sprite.setPosition(0, 0);
window.draw(sprite);
while (window.isOpen())
{
sf::Event event;
while (window.pollEvent(event))
{
switch (event.type)
{
case sf::Event :: KeyReleased :
switch (event.key.code)
{
case sf::Keyboard :: Up :
menu.moveUp();
break;
case sf::Keyboard :: Down :
menu.moveDown();
break;
case sf::Keyboard :: Return :
switch (menu.getPressedItem())
{
case 0:
std::cout << "Play\n";
break;
case 1:
std::cout << "Countinue\n";
break;
case 2:
window.close();
break;
}
break;
}
break;
case sf::Event :: Closed:
window.close();
break;
}
}
window.clear();
window.draw(sprite);
menu.draw(window);
window.display();
}
}