-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·78 lines (66 loc) · 2.5 KB
/
main.cpp
File metadata and controls
executable file
·78 lines (66 loc) · 2.5 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
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 <iostream>
using namespace std;
#include "case.h"
#include "player.h"
// #include "piece.h"
#include "board.h"
#include "graphics.h"
int main()
{
Window w = openWindow(400, 300, "Chess by Nexus&cie");
drawString(30, 40, "Welcome on this GUI of Chess, this well-known game!", BLACK,12, 0, false, true);
drawString(10, 80, "-> To play, click on the piece you want to move", BLACK);
drawString(10, 100, "and then where you want to move it.", BLACK);
drawString(10, 120, "-> You can quit with a right click at any time", BLACK);
drawString(20, 200, "Please click on this window to proceed to the GUI.", BLACK,12, 0, false, true);
drawString(120, 270, "Coded by Maximin Duvillard and Nicolas Birac", BLACK, 10, 0, true);
drawString(200, 285, "© - 2019", BLACK, 10, 0, true);
click();
closeWindow(w);
// we load the pieces images in memory
load_all_pieces();
// Display of the board
Window window_game = display_grid_empty();
// TODO: What's that doing here ?
// initiations
Board b;
Player J1(b,1);
Player J2(b,0);
J1.set_other_player(&J2);
J2.set_other_player(&J1);
b.set_player(&J1,&J2);
display_board(b);
//
Case c1, c2;
int tour=0;
bool dont_quit = true;
// the permission function need to be changed in order to call it on an empty case
// to simulate the presence of the piece without moving it
while(!J1.get_checkmate() && !J2.get_checkmate() && dont_quit){
if (tour%2==0){
cout << "white to move" << endl;
dont_quit = click_move(J1,c1,c2);
while (!(J1.move(b.get(c1), c2)) && dont_quit){
dont_quit = click_move(J1,c1,c2);
}
}
else{
cout << "black to move" << endl;
dont_quit = click_move(J2,c1,c2);
while (!(J2.move(b.get(c1), c2)) && dont_quit){
dont_quit = click_move(J2,c1,c2);
}
}
++tour;
}
Window w2 = openWindow(400, 200, "Chess by Nexus&cie");
setActiveWindow(w2);
drawString(30, 60, "We hope you enjoyed playing with this GUI", BLACK);
drawString(30, 90, "See you later!", BLACK);
drawString(20, 140, "Please click again on this window to quit the GUI.", BLACK,12, 0, false, true);
drawString(120, 180, "Coded by Maximin Duvillard and Nicolas Birac", BLACK, 10, 0, true);
drawString(200, 195, "© - 2019", BLACK, 10, 0, true);
endGraphics();
cout << "Quit successfully" << endl;
return 0;
}