#ifndef _GAME_H_
#define _GAME_H_
#define DEAD -1
#define PAUSED 2
#define ENDMATCH 2
#define MSGTIME 300
#define GRIDWIDTH 32
#define GRIDHEIGHT 24
#define BLOCKSIZE 16
#define MINSKY 80
#define FLOORGAP 5
typedef struct key
{
Sint8 pressed;
int def;
} L_key;
typedef struct timer
{
Uint32 framecount;
float rateticks;
Uint32 lastticks;
float ms;
Uint32 mscount;
Uint32 rate;
}L_timer;
typedef struct hero
{
L_spriteCtlRot sprite[HEROANIMS];
L_key up;
L_key left;
L_key right;
float x;
float y;
float vx;
float vy;
float jump;
int id;
int previd;
int dir;
float angle;
float rotateto;
float angspeed;
int floor;
int prevFloor;
int dead;
int lives;
int prevLives;
} hero_t;
typedef struct game
{
int floorTop;
int mapIndex;
float scrollCount;
int floor_l[GRIDHEIGHT];
int floor_r[GRIDHEIGHT];
hero_t* heros;
int numHeros;
int deadHeros;
float T_speed;
float T_count;
float T_timer;
} game_t;
void softScrollUp(game_t* game, graphics_t* gfx, float scroll);
int drawBg(JPB_surface* surf, int x, int y, int w, int h);
int drawFloor(graphics_t* gfx, int x, int y, int bw);
void makeFloor(game_t* game, graphics_t* gfx, int y);
void scrollUp(game_t* game, graphics_t* gfx);
void initGame(game_t* game, graphics_t* gfx, int numHeros);
int playGame(graphics_t* gfx, int numHeros);
int pauseGame(graphics_t* gfx, game_t* game, char* text);
int endMatch(graphics_t* gfx, game_t* game, int time);
void continueTimer(L_timer* time);
int yesNoQuestion(graphics_t* gfx, game_t* game, char* text);
int updateInput();
void markHeroKeys(SDL_Event* event, hero_t* hero) ;
void unmarkHeroKeys(SDL_Event* event, hero_t* hero);
void initHeroKeys(hero_t* hero, int num);
void recoverScr( graphics_t* gfx, game_t* game, int x, int y, int width, int height );
int isFloor(game_t* game, int x, int y);
void scrollHeros(game_t* game, float scroll);
int isStand( game_t* game, int ix, int iy);
int updateHero(game_t* game, graphics_t* gfx, int num, float ms);
void reliveHero(game_t* game, int num);
int updateHeroPosition ( game_t* game, int num , float fact);
int updateGame(game_t* game, graphics_t* gfx, float ms);
void drawHero(graphics_t* gfx,hero_t* hero);
void undrawHero(int heronum, graphics_t* gfx, game_t* game);
void initTimer(L_timer* time, int rate);
void updateTimer(L_timer* time);
void rotateHero(hero_t* hero, float ms);
void updateScore(graphics_t* gfx, game_t* game);
void drawRecords(graphics_t* gfx, records_t* rtab);
#endif