-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_manager.cpp
53 lines (43 loc) · 1.31 KB
/
game_manager.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
#include "game_manager.h"
game_manager::game_manager(int w, int h, char const * tittle, bool fullscreen){
if(not SDL_Init(SDL_INIT_EVERYTHING)){
int flags = 0;
if(fullscreen){
flags = SDL_WINDOW_FULLSCREEN;
}
width = w;
height = h;
window = SDL_CreateWindow(tittle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, flags);
if(window) std::cout << "window created" << std::endl;
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
if(renderer){
std::cout << "renderer created" << std::endl;
}
std::cout << "subsystems initialized!.." << std::endl;
isRunning = true;
}
else isRunning = false;
}
void game_manager::render(){
SDL_RenderClear(renderer);
SDL_SetRenderDrawColor(renderer, rendR, rendG, rendB, rendA);
SDL_RenderPresent(renderer);
}
void game_manager::update(){
return;
}
void game_manager::clean(){
isRunning = false;
SDL_DestroyWindow(window);
SDL_DestroyRenderer(renderer);
SDL_Quit();
std::cout << "game cleaned" << std::endl;
exit(0);
}
void game_manager::handle_events(){
SDL_Event event;
SDL_PollEvent(&event);
// SDL_WaitEvent(&event);
if(event.type == SDL_QUIT)
clean();
}