-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckers.cpp
More file actions
125 lines (110 loc) · 3.92 KB
/
Copy pathcheckers.cpp
File metadata and controls
125 lines (110 loc) · 3.92 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
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
#include <thread>
#include <chrono>
#include "board.hpp"
#include "game.hpp"
#include "square.hpp"
#include "player.hpp"
#include "grid.hpp"
int GameLoop(Game &game)
{
while (!WindowShouldClose())
{
game.PlayTurns();
}
return 1;
}
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 960;
const int screenHeight = 960;
InitWindow(screenWidth, screenHeight, "Checkers");
Game game;
bool alternate = false;
std::vector<std::vector<Square>> the_grid = game.GetGrid().GetGrid();
std::vector<std::vector<BoardSquare>> *bo = &game.GetBoard().GetBoard();
SetTargetFPS(2);
Camera2D camera;
camera.offset.x = -120;
camera.offset.y = -120;
camera.target.x = 0;
camera.target.y = 0;
camera.rotation = 0;
camera.zoom = 1;
// make players
// make
std::thread thread(GameLoop, std::ref(game));
// Define the camera to look into our 3d world
Camera3D camera3 = {0};
camera3.position = (Vector3){0.0f, 10.0f, 10.0f}; // Camera position
camera3.target = (Vector3){0.0f, 0.0f, 0.0f}; // Camera looking at point
camera3.up = (Vector3){0.0f, 1.0f, 0.0f}; // Camera up vector (rotation towards target)
camera3.fovy = 45.0f; // Camera field-of-view Y
camera3.projection = CAMERA_ORTHOGRAPHIC; // Camera mode type
Vector3 circle_position = {0.0f, 0.0f, 0.0f};
Vector3 circle_position2 = {0.9f, 0.0f, 7.9f};
Vector3 rotation_axis = {1, 1, 1};
while (!WindowShouldClose())
{
BeginDrawing();
ClearBackground(LIGHTGRAY);
BeginMode2D(camera);
for (size_t i = 0; i < 8; ++i)
{
for (size_t j = 0; j < 8; ++j)
{
Rectangle rec = {the_grid[i][j].GetDLPoint().first, the_grid[i][j].GetDLPoint().second, 120, 120};
if (alternate == true)
{
DrawRectangleRec(rec, WHITE);
alternate = false;
}
else
{
DrawRectangleRec(rec, BROWN);
alternate = true;
}
}
alternate = alternate == true ? false : true;
}
// std::cout << bo[i][j].GetDLPoint().first << ", " << bo[i][j].GetDLPoint().second << std::endl;
size_t counter = 0;
for (auto const &player : game.GetPlayers())
{
for (size_t i = 0; i < 8; ++i)
{
for (size_t j = 0; j < 8; ++j)
{
if ((*bo)[i][j].GetPawn().GetPawnId() != -1)
{
if ((*bo)[i][j].GetPawn().GetPlayerId() == PlayerId::ONE)
{
auto color = game.GetPlayers()[0].GetColor();
DrawCircle(the_grid[i][j].GetDLPoint().first + 60,
the_grid[i][j].GetDLPoint().second + 60, 55, CLITERAL(color));
}
else
{
auto color = game.GetPlayers()[1].GetColor();
DrawCircle(the_grid[i][j].GetDLPoint().first + 60,
the_grid[i][j].GetDLPoint().second + 60, 55, CLITERAL(color));
}
}
}
}
}
// game.PlayTurn();
EndMode2D();
/* BeginMode3D(camera3);
DrawCylinder(circle_position, 2.5, 2.5, 0.6, 5, BLACK);
DrawCylinderWires(circle_position, 2.5, 2.5, 0.6, 20, DARKGRAY);
DrawCylinder(circle_position2, 2.5, 2.5, 0.6, 5, BLACK);
DrawCylinderWires(circle_position2, 2.5, 2.5, 0.6, 20, DARKGRAY);
EndMode3D(); */
EndDrawing();
}
CloseWindow();
thread.join();
return 0;
}