1 /*
2  * Volleyball - video game similary to GNU Arcade Volleyball
3  * Copyright (C) 2005, 2006 Hugo Ruscitti : hugoruscitti@gmail.com
4  * web site: http://www.loosersjuegos.com.ar
5  *
6  * This file is part of Volleyball.
7  *
8  * Volleyball is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Volleyball is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23 
24 #ifndef _PLAYER_H
25 #define _PLAYER_H
26 
27 #include "common.h"
28 #include "fileoptions.h"
29 #include "display.h"
30 #include "player_control.h"
31 #include "animation.h"
32 
33 /*! \brief Define la cantidad de atributos que se obtienen desde `info.txt` */
34 #define MAX_OPTIONS 27
35 
36 /*!
37  * \file
38  */
39 
40 /*!
41  * \brief Representa un personaje del juego
42  *
43  */
44 typedef struct player_t
45 {
46 	struct ball * ball;
47 	Player_control * control;	/*!< maneja los movimientos */
48 	Animation * animation;		/*!< maneja los cuadros de animaci�n */
49 
50 	char nick [256];		/*!< nombre corto */
51 	char description [256];		/*!< descripci�n del personaje */
52 	char author [256];		/*!< nombre del autor */
53 	char email [256];		/*!< correo electr�nico */
54 	char web [256];			/*!< url de la web del autor */
55 
56 	SDL_Surface * image;		/*!< grilla de cuadros */
57 	SDL_Surface * preview;		/*!< rostro del personaje */
58 
59 	int debug;
60 	int x;				/*! posici�n horizontal */
61 	int y;				/*! posici�n vertical */
62 	int actual_dx;			/*! desplazamiento horizontal actual */
63 	int flip;			/*! espejado (0 derecha, 1 izquierda)*/
64 	int arena_boundary_left;	/*! limite en su campo de juego */
65 	int arena_boundary_right;	/*! limite en su campo de juego */
66 	int initial_jump_speed;		/*! velocidad inicial del salto */
67 
68 	int step;			/*! paso dentro de la animaci�n */
69 	int frame;			/*! cuadro actual en la grilla */
70 	int delay;			/*! pausa entre cuadros de animaci�n */
71 	int jump_power;			/*! velocidad inicial de salto */
72 	int speed;			/*! velocidad horizontal */
73 	int width;			/*! ancho de colisi�n con las paredes */
74 
75 	int columns;			/*! columnas en la grilla completa */
76 	int hotspot_x;			/*! eje o punto de control */
77 	int hotspot_y;			/*! eje o punto de control */
78 
79 	int collision_x;		/*! eje de colisi�n horizontal */
80 	int collision_y;		/*! eje de colisi�n vertical */
81 	int collision_ratio;		/*! radio del c�rculo de colisi�n */
82 
83 	void (* state) (struct player_t * data);	/*! estado actual */
84 } Player;
85 
86 
87 
88 Player * player_init (char * path, char * file, int debug);
89 int player_init_examine_files (char * complete_path);
90 int player_init_load_images (Player * data, char * complete_path);
91 int player_init_load_attributes (Player * data, char * complete_path);
92 void player_draw_debug_lines (Player * data);
93 
94 void player_draw_preview (Player * data, int x, int y, Display * display);
95 void player_draw (Player * data, Display * display);
96 void player_free (void * data);
97 
98 void player_init_game (Player * data, struct ball * ball, int player,
99 		int left, int right);
100 
101 void player_set_position (Player * data, int x, int y, int flip);
102 void player_set_control (Player * data, Player_control * control);
103 void player_update (Player * data);
104 void player_update_animation (Player * data);
105 
106 void player_change_state (Player * data, void (* init) (Player * data),
107 		void (* update) (Player * data));
108 
109 void player_state_ready (Player * data);
110 void player_state_select (Player * data);
111 void player_state_run_left (Player * data);
112 void player_state_run_right (Player * data);
113 void player_state_jump (Player * data);
114 
115 void player_init_ready (Player * data);
116 void player_init_select (Player * data);
117 void player_init_run_left (Player * data);
118 void player_init_run_right (Player * data);
119 void player_init_jump (Player * data);
120 
121 void player_set_arena_boudary (Player * data, int left, int right);
122 void player_move (Player * data, int direction);
123 int player_collision (Player * data, int x, int y, int ratio);
124 void player_get_collision_area (Player * data, int * x, int * y, int * ratio);
125 float player_get_collision_power (Player * data, int dx);
126 void player_collision_with_ball (Player * data, int dx);
127 
128 void player_do_run_left (Player * data);
129 void player_do_run_right (Player * data);
130 void player_do_jump (Player * data);
131 void player_do_ready (Player * data);
132 
133 /* localizadas */
134 void player_ai_do_run_to_best_place_to_start (Player * data);
135 void player_ai_do_start_game_jumping (Player * data);
136 void player_ai_do_waiting_receive (Player * data);
137 void player_ai_do_waiting_other_player (Player * data);
138 
139 void player_set_ai_control (Player * data);
140 
141 #endif
142