-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollision.h
More file actions
52 lines (41 loc) · 1.23 KB
/
collision.h
File metadata and controls
52 lines (41 loc) · 1.23 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
50
51
52
/* this is the collision mechanism that the sandDemo uses
Utilizes a 2D vector size: (screenWidth, screenHeight) inorder to track
all particles, and keep particles seperated, thus mimicking
a collision system
*/
/* PixelTypes to be stored into 2D vector */
#pragma once
#include <vector>
enum PixelType
{
FREESPACE, //0
SOLID, //1
SAND, //2
WATER //3
};
class CollisionBoard
{
protected:
//track all particles
std::vector<std::vector<PixelType>> board;
public:
//Resolution of the Window
int width, height;
//board height
int board_height;
CollisionBoard(int width, int height);
//Return the Particle ( if any ) in the board at (x , y)
PixelType CheckBelow (int x, int y);
PixelType CheckBelowLeft (int x, int y);
PixelType CheckBelowRight (int x, int y);
PixelType CheckLeft (int x, int y);
PixelType CheckRight (int x, int y);
//Set pixelType to the board at (x , y)
void setPixelType(int x, int y, PixelType type);
/* Invoked everytime collision-board is cleared or instantiated */
void clear();
//Set the Floor to solid
void setFlooring();
//Set the Walls to solid
void setWalls();
};