-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (38 loc) · 1.65 KB
/
main.cpp
File metadata and controls
49 lines (38 loc) · 1.65 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
#include <SDL.h>
#include <engine/WorldBuilder.hpp>
#include <rendering/SDLDisplayer.hpp>
#include <thread>
constexpr int SCREEN_WIDTH = 640;
constexpr int SCREEN_HEIGHT = 480;
constexpr int defaultFrameRate = 165;
static void eventLoop()
{
SDL_Event e; bool quit = false; while (quit == false) { while (SDL_PollEvent(&e)) { if (e.type == SDL_QUIT) quit = true; } }
}
int main(int argc, char* args[])
{
SDL_Window* w = nullptr;
SDL_Renderer* r = nullptr;
SDL_Init(SDL_INIT_VIDEO);
SDL_CreateWindowAndRenderer(SCREEN_WIDTH, SCREEN_HEIGHT, 0, &w, &r);
SDL_Delay(500);
auto displayer = std::make_unique<rendering::SDLDisplayer>(r);
//WorldBuilder wb(std::move(displayer), SCREEN_WIDTH, SCREEN_HEIGHT, defaultFrameRate);
//wb.withGravity(9)
// .withCircle({ 7.5, 6 }, 5, 1, { 5, 5 })
// //.withCircle({ 12, 17 }, 5, 1, { 0, 5 }, Color::Blue)
// .withRectangle({ 5, 8 }, 5, { 0, 1 }, { 0, 0 }, Color::Black, true)
// .withRectangle({ 5, 1 }, 5, { 1, 17 }, { 0, 0 }, Color::Black, true)
// .withRectangle({ 5, 1 }, 5, { 17, 1 }, { 0, 0 }, Color::Black, true)
// .withRectangle({ 20, 1 }, 5, { 1, 17 }, { 0, 0 }, Color::Black, true)
// .withRectangle({ 5, 18 }, 5, { 16, 1 }, { 0, 0 }, Color::Black, true);
WorldBuilder wb(std::move(displayer), SCREEN_WIDTH, SCREEN_HEIGHT, defaultFrameRate);
wb.withGravity(9)
.withCircle({ 7.5, 6 }, 5, 1, { 0, 0 })
.withRectangle({ 5, 18 }, 5, { 16, 1 }, { 0, 0 }, Color::Black, true);
auto world = wb.buildWorld();
std::thread engine(&World::start, world.get());
engine.detach();
eventLoop();
return 0;
}