-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulation.cpp
More file actions
41 lines (34 loc) · 787 Bytes
/
simulation.cpp
File metadata and controls
41 lines (34 loc) · 787 Bytes
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
#include "simulation.h"
#include "globals.h"
#include <SDL.h>
Simulation::Simulation() {
//init everything from SDL
SDL_Init(SDL_INIT_EVERYTHING);
//create window and renderer by global constants
SDL_CreateWindowAndRenderer(globals::WIDTH, globals::HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI, &this->_window, &this->_renderer);
}
void Simulation::start() {
this->_running = true;
//start simulation main loop
this->loop();
}
void Simulation::clear() {
SDL_RenderClear(this->_renderer);
}
void Simulation::render() {
SDL_RenderPresent(this->_renderer);
}
void Simulation::draw() {}
void Simulation::loop() {
SDL_Event event;
while (true) {
if (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
SDL_Quit();
break;
}
}
this->clear();
this->render();
}
}