Pac-Man Evolution
Loading...
Searching...
No Matches
ObjectsPacMan.h
1/*----------------------------------------------------------------------
2Pac-Man Evolution - Roberto Prieto
3Copyright (C) 2018-2024 MegaStorm Systems
4contact@megastormsystems.com - http://www.megastormsystems.com
5
6This software is provided 'as-is', without any express or implied
7warranty. In no event will the authors be held liable for any damages
8arising from the use of this software.
9
10Permission is granted to anyone to use this software for any purpose,
11including commercial applications, and to alter it and redistribute it
12freely, subject to the following restrictions:
13
141. The origin of this software must not be misrepresented; you must not
15claim that you wrote the original software. If you use this software
16in a product, an acknowledgment in the product documentation would be
17appreciated but is not required.
182. Altered source versions must be plainly marked as such, and must not be
19misrepresented as being the original software.
203. This notice may not be removed or altered from any source distribution.
21
22------------------------------------------------------------------------
23
24PacMan and states classes
25
26------------------------------------------------------------------------ */
27
28#ifndef OBJECTSPACMANPME_H
29#define OBJECTSPACMANPME_H
30
31// Includes and forward definitions
32#include "Objects.h"
33
34// Init State
35class PacManStateInit : public State
36{
37public:
38 explicit PacManStateInit(const string&);
39 void enter(Actor*);
40 void execute(Actor*);
41 void exit(Actor*);
42private:
43 Uint32 iTime;
44};
45
46// Evading State
47class PacManStateEvading : public State
48{
49public:
50 explicit PacManStateEvading(const string&);
51 void execute(Actor*);
52private:
53 Sint32 iTX, iTY, iITX, iITY;
54 bool bGetNewTarget;
55};
56
57// Chasing State
58class PacManStateChasing : public State
59{
60public:
61 explicit PacManStateChasing(const string&);
62 void enter(Actor*);
63 void execute(Actor*);
64 void exit(Actor*);
65private:
66 Sint32 iTicks;
67};
68
69// Death State
70class PacManStateDeath : public State
71{
72public:
73 explicit PacManStateDeath(const string&);
74 void enter(Actor*);
75 void execute(Actor*);
76};
77
78// Pac-Man class
79class PacMan : public Actor
80{
81 // State classes can access to all attributes
82 friend class PacManStateInit;
83 friend class PacManStateEvading;
84 friend class PacManStateChasing;
85 friend class PacManStateDeath;
86
87public:
88 PacMan(Sint32 iMX, Sint32 iMY, GameField* GF);
89 ~PacMan();
90 Sint32 execute();
91 Sint32 debug(Sint32);
92 Sint32 getLifes();
93
94 // Messages that modified our state
95 Sint32 msgGoInit();
96 Sint32 msgPelletPowerEaten(Sint32, Sint32);
97 Sint32 msgGhostCollision();
98
99private:
100 // Methods
101 Sint32 applyMovementRules(Sint32, Sint32);
102
103 // Attributes
104 Sint32 iLifes; // Lifes.
105 Sint32 iPointsForEatingGhostsPerPelletPower; // With each power pellet, eating ghosts give us PME_PACMAN_POINTS_EAT_GHOST points
106
107 // PacMan states
108 PacManStateInit* pStateInit;
109 PacManStateEvading* pStateEvading;
110 PacManStateChasing* pStateChasing;
111 PacManStateDeath* pStateDeath;
112};
113
114#endif