-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
57 lines (44 loc) · 1.32 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
#include <iostream>
#include "include/SDL2/SDL.h"
#include "MazeGenerator.h"
#include "MazeSolver.h"
#define WIN_HEIGHT 900
#define WIN_WIDTH 900
using namespace std;
int main (int argc, char** argv)
{
SDL_Window* window = NULL;
window = SDL_CreateWindow
(
"MazeSolver", SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
WIN_HEIGHT,
WIN_WIDTH,
SDL_WINDOW_SHOWN
);
// Setup renderer
SDL_Renderer* renderer = NULL;
renderer = SDL_CreateRenderer( window, -1, SDL_RENDERER_ACCELERATED);
// Set render color to red ( background will be rendered in this color )
SDL_SetRenderDrawColor( renderer, 0, 0, 0, 0);
// Clear winow
SDL_RenderClear( renderer );
MazeGenerator* generator = new MazeGenerator(75, WIN_WIDTH, WIN_HEIGHT, renderer);
generator->GenerateMaze();
generator->pickRandomStartEnd();
MazeSolver* solver = new MazeSolver(generator,renderer);
solver->debug = false;
solver->astar_solve();
//gameLoop
SDL_Event e;
while( SDL_WaitEvent(&e) )
{
if (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE || e.type == SDL_QUIT) break;
solver->dragndrop(e);
}
//Garbage Collect Cellgrid
generator->destroy();
SDL_DestroyWindow(window);
SDL_Quit();
return EXIT_SUCCESS;
}