1 /*************************************************************************
2 
3                          "I Have No Tomatoes"
4                   Copyright (c) 2004, Mika Halttunen
5 
6  This software is provided 'as-is', without any express or implied
7  warranty. In no event will the authors be held liable for any damages
8  arising from the use of this software.
9 
10  Permission is granted to anyone to use this software for any purpose,
11  including commercial applications, and to alter it and redistribute
12  it freely, subject to the following restrictions:
13 
14     1. The origin of this software must not be misrepresented; you must
15     not claim that you wrote the original software. If you use this
16     software in a product, an acknowledgment in the product documentation
17     would be appreciated but is not required.
18 
19     2. Altered source versions must be plainly marked as such, and must
20     not be misrepresented as being the original software.
21 
22     3. This notice may not be removed or altered from any source
23     distribution.
24 
25 
26  Mika Halttunen <lsoft@mbnet.fi>
27 
28 *************************************************************************/
29 
30 #ifndef PLAYER_H
31 #define PLAYER_H
32 
33 #include "init.h"
34 #include "vect.h"
35 #include "bonus.h"
36 
37 
38 // Direction defines
39 #define DIR_N		0
40 #define DIR_E		1
41 #define DIR_S		2
42 #define DIR_W		3
43 
44 #define DIR_UP		0
45 #define DIR_DOWN	1
46 #define DIR_STAY	2
47 
48 
49 // Player class
50 class PLAYER {
51 public:
52 	int x, y;					// Tile position
53 	int tx, ty;					// Target tile position
54 	float offset;				// Current offset
55 	int dir;					// Direction
56 	int nextdir;				// Next direction
57 
58 	float size;					// Sprite size
59 	float anim;					// Animation counter
60 	bool walking;				// Walking?
61 	bool turning;				// Turning?
62 	int turning_counter;		// Counter for the turning animation
63 	bool turn_key_down[3];		// Turning keys pressed down?
64 
65 	bool alive;					// Is the player alive?
66 	int death_counter;			// Counts a few seconds before respawning
67 	int reload;					// Reloading counter
68 	int num_bombs;				// Number of active bombs (including flower bombs)
69 	int num_flower_bombs;		// Number of active flower bombs
70 
71 	bool dying;					// Is the dying animation on?
72 	float die_anim;				// Die animation counter
73 
74 	int in_teleport;			// Is the player teleporting?
75 
76 	bool jumping;				// Is the player jumping?
77 	float jump_pos;	   			// Position in the jump arc (between 0 and 1)
78 	float jump_dist;			// Total jump distance
79 	float jump_height;			// Maximum jump height
80 	float jump_speed;			// Jump speed (less than 1)
81 	int jump_tx, jump_ty;		// Jump target tile
82 	VECT jump_dir;				// Jump direction vector (in 2D)
83 
84 	// Functions
85 	void clear();				// Clear the player
86 	void move();				// Move the player
87 	void draw();				// Draw the player
88 	bool check_collisions();	// Check the enemy collisions
89 	float get_real_x();			// Get current x with offset
90 	float get_real_y();			// Get current y with offset
91 	void pick_bonus(BONUS *b);	// Pick a bonus up
92 	void die();					// The player dies
93 
94 	// Jump
95 	void jump(int tx, int ty, float height, float speed);
96 };
97 
98 // Players
99 extern PLAYER p1;
100 extern PLAYER p2;
101 
102 void show_icon(int who);
103 void load_players();
104 void draw_player_icons();
105 
106 
107 #endif
108 
109 
110