-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcollisionchecker.h
70 lines (53 loc) · 1.63 KB
/
collisionchecker.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef _COLLISIONCHECKER_H_
#define _COLLISIONCHECKER_H_
#include "coords.h"
class Level;
// looks for and handles collisions:
// player vs. victim
// player vs. food
// victims vs. food
// player vs. map obstacles
// victims vs. map obstacles
class CollisionChecker
{
public:
CollisionChecker(Level* lvl);
bool foodCanMoveTo(PixelCoords position);
bool projectileCanMoveTo(PixelCoords position);
bool playerCanMoveTo(PixelCoords position);
bool victimCanMoveTo(PixelCoords position);
void playerPickupWeapon();
void playerPickupFood();
void victimPickupFood();
void playerVsVictim();
void victimVsLaser();
void victimVsProjectile();
bool canMoveTo(PixelCoords position, int w, int h);
// cap on nr. of expensive operations per tick (like collisions)
static const int OPERATIONS_CAP = 5000;
// bounding box sizes for collision checks of various objects
static const int PLAYER_WIDTH = 16;
static const int PLAYER_HEIGHT = 20;
static const int VICTIM_WIDTH = 24;
static const int VICTIM_HEIGHT = 24;
static const int FOOD_WIDTH = 24;
static const int FOOD_HEIGHT = 24;
static const int WEAPON_WIDTH = 24;
static const int WEAPON_HEIGHT = 24;
static const int BULLET_WIDTH = 4;
static const int BULLET_HEIGHT = 4;
static const int BLOCK_WIDTH0 = 24;
static const int BLOCK_HEIGHT0 = 24;
static const int BLOCK_WIDTH1 = 56;
static const int BLOCK_HEIGHT1 = 56;
static const int BLOCK_WIDTH2 = 64;
static const int BLOCK_HEIGHT2 = 64;
static const int PROJECTILE_WIDTH = 4;
static const int PROJECTILE_HEIGHT = 4;
static const int LASER_PARTITIONS = 200;
static const int LASER_FIELD_SIZE = 30;
Level* level;
private:
int explodeAudioDelay;
};
#endif