Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
80 lines (59 loc) 路 1.84 KB
/
Copy pathmain.cpp
File metadata and controls
80 lines (59 loc) 路 1.84 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
#include "raylib.h"
#include <iostream>
#include <sstream>
#include <vector>
#include "ga.h"
#include "hsl.h"
#include "ui.h"
int main()
{
// ! RANDOM GENERATOR SEEDING
srand(time(NULL));
// ! WINDOW PROPERTIES
// const int screenWidth = 800;
// const int screenHeight = 800;
const char *title = "Camouflage";
// ! RAYLIB SETUP
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(FLAG_BORDERLESS_WINDOWED_MODE);
SetConfigFlags(FLAG_WINDOW_HIGHDPI);
InitWindow(800, 800, title);
const int screenWidth = GetMonitorWidth(0);
const int screenHeight = GetMonitorHeight(0);
SetWindowSize(screenWidth, screenHeight);
ToggleFullscreen();
SetTargetFPS(60);
// ! GUI SETUP
GuiSetStyle(DEFAULT, TEXT_COLOR_NORMAL, ColorToInt(WHITE));
// ! ALGO SETUP
const int COL_COUNT = 30;
const int ROW_COUNT = 30;
// ! GENETIC ALGORITHM SETUP
GA ga(ROW_COUNT, COL_COUNT, 0.0005, {31, 0.5, 0.5});
// ! UPDATION SPEED CONTROLLER SETUP
float speedMultiplier = 6.0f;
float timeAccumulator = 0.0f;
float updateInterval = 1.0f;
// ! SIMULATION RUN STATE
bool isRunning = false;
while (!WindowShouldClose())
{
timeAccumulator += GetFrameTime();
BeginDrawing();
ClearBackground(HSLToColor(ga.BACKGROUND));
// * YOU DRAWING STARTS HERE ------------>
ga.Render((screenWidth / 2) - 300, (screenHeight / 2) - 300, 600, 600);
if (timeAccumulator >= (updateInterval / speedMultiplier))
{
if (isRunning)
{
ga.Update();
}
timeAccumulator = 0.0f;
}
RenderGUI(ga, screenWidth, screenHeight, (screenWidth / 2) - 300, (screenHeight / 2) - 300, 600, 600, speedMultiplier, isRunning);
EndDrawing();
}
CloseWindow();
return 0;
}