1
1
#include < CL/sycl.hpp>
2
2
#include < SDL2/SDL.h>
3
- #include " Actor.hpp"
4
3
#include < iostream>
5
4
5
+ #include " Actor.hpp"
6
+ #include " Room.hpp"
7
+
6
8
const int WIDTH = 8 ; // metres
7
9
const int HEIGHT = 6 ; // metres
8
10
const int SCALE = 100 ;
@@ -13,7 +15,7 @@ void init(SDL_Window* &win, SDL_Renderer* &render, std::vector<Actor> &actors) {
13
15
win = SDL_CreateWindow (" SYCL Crowd Simulation" , SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH * SCALE, HEIGHT * SCALE, SDL_WINDOW_SHOWN);
14
16
render = SDL_CreateRenderer (win, -1 , SDL_RENDERER_ACCELERATED);
15
17
16
- actors.push_back (Actor{{1 , 2 }, {0.01 , 0 }, {0.02 , 0.02 }, 50 , 0.05 });
18
+ actors.push_back (Actor{{1 , 2 }, {0.01 , 0.01 }, {0.02 , 0.02 }, 50 , 0.05 });
17
19
}
18
20
19
21
void drawCircle (SDL_Renderer* &render, SDL_Point center, int radius, SDL_Color color) {
@@ -36,7 +38,7 @@ void update(std::vector<Actor> &actors) {
36
38
}
37
39
}
38
40
39
- void draw (SDL_Renderer* &render, std::vector<Actor> actors) {
41
+ void draw (SDL_Renderer* &render, std::vector<Actor> actors, Room room ) {
40
42
SDL_SetRenderDrawColor (render, 255 , 255 , 255 , 255 );
41
43
SDL_RenderClear (render);
42
44
@@ -46,6 +48,11 @@ void draw(SDL_Renderer* &render, std::vector<Actor> actors) {
46
48
drawCircle (render, pos, actor.getRadius () * SCALE, red);
47
49
}
48
50
51
+ SDL_SetRenderDrawColor (render, 0 , 0 , 0 , 255 );
52
+ for (std::array<float , 4 > wall : room.getWalls ()) {
53
+ SDL_RenderDrawLine (render, wall[0 ] * SCALE, wall[1 ] * SCALE, wall[2 ] * SCALE, wall[3 ] * SCALE);
54
+ }
55
+
49
56
SDL_RenderPresent (render);
50
57
}
51
58
@@ -60,10 +67,11 @@ int main() {
60
67
SDL_Renderer* render = NULL ;
61
68
62
69
std::vector<Actor> actors;
70
+ Room room = Room ({{0.5 , 0.5 , 0.5 , 1.5 }, {0.5 , 2.5 , 0.5 , 5.5 }, {0.5 , 5.5 , 7.5 , 5.5 }, {7.5 , 5.5 , 7.5 , 0.5 }, {7.5 , 0.5 , 0.5 , 0.5 }}, {});
63
71
64
72
init (win, render, actors);
65
73
66
- draw (render, actors);
74
+ draw (render, actors, room );
67
75
68
76
int delayCounter = 0 ;
69
77
bool isQuit = false ;
@@ -78,7 +86,7 @@ int main() {
78
86
if (delayCounter >= DELAY) {
79
87
delayCounter = 0 ;
80
88
update (actors);
81
- draw (render, actors);
89
+ draw (render, actors, room );
82
90
}
83
91
else {
84
92
delayCounter++;
0 commit comments