-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.h
More file actions
66 lines (58 loc) · 1.47 KB
/
model.h
File metadata and controls
66 lines (58 loc) · 1.47 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _MODEL_H
#define _MODEL_H
#define SDL_MAIN_HANDLED
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_ttf.h>
enum State { RUN, SEEK, RESET};
enum Direction { UP, DOWN, LEFT, RIGHT, STILL };
// The model manages the state of the game
class Model {
public:
// Constructor (instantiates object)
Model(int w, int h);
// Destructor deletes all dynamically allocated stuff
~Model();
void go(Direction d);
void move();
// Is the game over?
bool gameOver();
//Make the object move
// Move (if the next spot is a wall d = STILL)
Direction direction;
void move_pac();
bool paccollision(SDL_Rect& rect, Direction direction);
bool Collision(SDL_Rect a, SDL_Rect b);
// Move the ghosts (if the next spot is a wall, switch direction)
void move_ghost();
void reset();
void new_path(int k);
bool ghostcollision(SDL_Rect ghost, Direction d);
void ghost_bump(int g);
// instantiate objects
SDL_Rect pacman;
SDL_Rect Rect[32];
// Locations of the pills
SDL_Rect pills[124];
// Is the pill being shown?
bool pillShown[124];
void newlevel();
// ghosts
int time;
SDL_Rect ghost[3];
bool SPshown[5];
SDL_Rect SPloc[5];
SDL_Rect middle;
SDL_Rect middle2;
SDL_Rect checkblock;
SDL_Rect offset;
Direction ghostd[4];
Direction last_d;
bool overlap(SDL_Rect c, SDL_Rect d);
State state;
void resetghost(int i);
int score;
int lives;
};
#endif