forked from marcincichowski/makao
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
134 lines (129 loc) · 5.23 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#include <iostream>
#include <SFML/Graphics.hpp>
#include "game_elements/headers/Cards.h"
#include "game_elements/headers/Player.h"
#include "game_elements/headers/Deck.h"
#include "game_elements/headers/Stack.h"
#include "resources/gui/headers/Menu.h"
#include "resources/gui/headers/Board.h"
void debug(){
}
int main(){
sf::Image icon;
icon.loadFromFile("../resources/icon.png");
sf::RenderWindow window(sf::VideoMode(1280,720),"Makao");
window.setIcon(icon.getSize().x, icon.getSize().y, icon.getPixelsPtr());
window.setFramerateLimit( 30 );
sf::Texture zasadyTexture;
zasadyTexture.loadFromFile("../resources/zasady.PNG");
sf::Sprite zasadySprite;
zasadySprite.setTexture(zasadyTexture);
zasadySprite.setPosition(window.getSize().x/ 2 - 400, window.getSize().y/ 2 - 350);
sf::Text pressToExit;
sf::Font arial;
arial.loadFromFile("../assets/fonts/arial.ttf");
pressToExit.setFont(arial);
pressToExit.setFillColor(sf::Color::White);
pressToExit.setPosition(window.getSize().x/ 2 - 170, window.getSize().y / 2 + 300);
pressToExit.setString(L"Naciśnij enter aby wrócić...");
int STATE = 0;
Menu menu(window.getSize().x, window.getSize().y);
Board plansza(window.getSize().x, window.getSize().y);
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)) {
switch(event.type){
case sf::Event::Closed:{
window.close();
break;
}
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::Left:{
if(plansza.getChooseWindowNumber())
plansza.chooseMoveLeftNumber();
else if(plansza.getChooseWindowShape())
plansza.chooseMoveLeftShape();
else if(!plansza.getIsNewRound())
plansza.moveLeft();
break;
}
case sf::Keyboard::Right:{
if(plansza.getChooseWindowNumber())
plansza.chooseMoveRightNumber();
else if(plansza.getChooseWindowShape())
plansza.chooseMoveRightShape();
else if(!plansza.getIsNewRound())
plansza.moveRight();
break;
}
case sf::Keyboard::Space:{
plansza.pressSpace();
break;
}
case sf::Keyboard::Return:{
if(plansza.getChooseWindowNumber())
plansza.getSelectedWindowNumber(window);
else if(plansza.getChooseWindowShape())
plansza.getSelectedWindowShape(window);
else if(STATE == 1){
STATE = 0;
}
else if(STATE == 2){
plansza.throwCard();
if(plansza.getWinCheck()){
STATE = 4;
}
}
else if(STATE == 3){
plansza.initBoard(menu.getPressedItem()+2);
STATE = 2;
}
else if(STATE == 4){
window.close();
}
else{
if(menu.getPressedItem() == 0){
STATE = 3; //gra
}else if(menu.getPressedItem() == 1) {
STATE = 1; //zasady
}else{
window.close(); //wyjscie
}
}
break;
}
}
break;
}
}
}
window.clear();
window.draw(plansza.getBackground());
if(STATE == 0){
menu.draw(window);
}else if(STATE == 1) {
window.draw(zasadySprite);
window.draw(pressToExit);
}else if(STATE == 2){
plansza.draw(window);
}
else if(STATE == 3){
menu.changeString(window);
}
else if(STATE == 4){
menu.drawWinners(window, *plansza.getWinners());
window.draw(pressToExit);
}
window.display();
}
return 0;
}