forked from hiyorikotobuki/ComputerGraphics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsand.cpp
54 lines (43 loc) · 1.02 KB
/
sand.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
#include "screen.h"
#include "math.h"
class Sand{
public:
int position_x;
int position_y;
Sand(int x, int y)
{
this->position_x = x;
this->position_y = y;
}
};
int main(int argc, char* argv[])
{
G screen;
vector<Sand> world;
//int emitter[2] = {640/2,480/2};
while(true)
{
// Add sand to world
world.push_back(Sand(320,240));
// Update sand
for(auto it = begin(world); it != end(world); ++it)
{
it->position_y += 1;
// Check collision
for(auto it2 = begin(world); it2 != end(world); ++it2)
{
if(it2 == it) { continue; }
}
}
// Render sand
for(auto it = begin(world); it != end(world); ++it)
{
screen.drawpixel(it->position_x, it->position_y);
}
screen.update();
SDL_Delay(200);
screen.input();
screen.clearpixels();
}
return 0;
}