-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
123 lines (96 loc) · 3.5 KB
/
Player.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*******************************************************************************
CommanderTux
Penguin In Space
Released under the GNU Public License
2005 by Andr� Schnabel ([email protected])
*******************************************************************************/
// Player.h
#ifndef PLAYER_H
#define PLAYER_H
#include "Actor.h"
#include "Text.h"
#include "Bullet.h"
#define SCORE_MSG_DURATION 1000
#define FRAG_MSG_DURATION 1000
#define RELOAD_TIME 500
#define PLAYER_BULLET_SPEED 10
enum ScoreReasons
{
ENEMY_KILLED,
ITEM_COLLECTED
};
class CPlayer : public CActor
{
public:
#ifndef NO_SOUND
CPlayer( int s_x, int s_y, SLevel *level,
SDL_Texture *images[NUM_ACTOR_IMAGES],
Mix_Chunk *player_snds[NUM_PLAYER_SOUNDS],
int p_num, bool duel,
Position border,
CLinkedList< CEnemy > *enemies=NULL,
SDL_Texture *bullet_surf=NULL,
SDL_Texture *gun_surf[2]=NULL );
#else
CPlayer( int s_x, int s_y, SLevel *level,
SDL_Texture *images[NUM_ACTOR_IMAGES],
int p_num, bool duel,
Position border,
CLinkedList< CEnemy > *enemies=NULL,
SDL_Texture *bullet_surf=NULL,
SDL_Texture *gun_surf[2]=NULL );
#endif
virtual void Update( int *scroll_x, int *scroll_y );
virtual void Draw( int *scroll_x, int *scroll_y, int text_y );
virtual void Jump();
virtual void StopJump( bool bump );
virtual void Walk( Direction dir=DIR_LEFT, int walk_speed=WALK_SPEED );
virtual void Die();
virtual void Respawn( int *scroll_x );
bool GetRespawn() { return m_respawned; }
void SetRespawn( bool respawned ) { m_respawned = respawned; }
void Frag( CPlayer *victim );
bool GetActive() { return m_active; }
void SetActive( bool value ) { m_active = value; }
void SetScore( int score ) { m_score = score; }
int GetScore() { return m_score; }
void IncrementScore( int value, int x, int y, int reason );
void SetLives( int lives ) { m_lives = lives; }
int GetLives() { return m_lives; }
bool GetDead() { return m_dead; }
void SetDead( bool value ) { m_dead = value; }
void Shoot();
void AddBullets( int bullets ) { m_num_bullets+=bullets; }
void AddLive() { m_lives++; }
int GetNumBullets() { return m_num_bullets; }
void SetNumBullets( int bullets ) { m_num_bullets = bullets; }
void PlaySound( int sound_nr )
{
#ifndef NO_SOUND
Mix_PlayChannel( -1, m_player_snds[sound_nr], 0 );
#endif
}
private:
#ifndef NO_SOUND
Mix_Chunk *m_player_snds[NUM_PLAYER_SOUNDS];
Uint32 m_last_time_walking_sound;
#endif
bool m_respawned;
Position m_border;
bool m_duel;
int m_p_num;
Color m_text_color;
int m_frags, m_score, m_lives;
bool m_dead;
bool m_lives_decremented;
bool m_active;
CLinkedList< CFlyingText > m_score_msgs, m_frag_msgs;
CLinkedList< CEnemy > *m_enemies;
CLinkedList< CBullet > m_bullets;
Uint32 m_last_shot;
SDL_Texture *m_bullet_surf;
SDL_Texture *m_gun_surf[2];
int m_num_bullets;
bool m_shooting;
};
#endif