Skip to content

Commit

Permalink
game state fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sebseb7 committed Sep 23, 2015
1 parent bcd1db8 commit 0ebee92
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
34 changes: 33 additions & 1 deletion bd_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ struct bd_game_struct_t* bd_game_initialize(int level,int difficulty)



bd_game->Won=0;
bd_game->Lost=0;
bd_game->Tick=0;
bd_game->DiamondsCollected=0;
bd_game->Cave=level;
bd_game->Difficulty=difficulty;
bd_game->DiamonValue=cavedata->DiamonValue;
bd_game->DiamonValueBonus=cavedata->DiamonValueBonus;
Expand Down Expand Up @@ -119,10 +122,39 @@ void bd_game_process(struct bd_game_struct_t* bd_game, int direction)
int fall_tick = tick%8;
int expl_tick = tick%3;

if(bd_game->Won ==1)
if(bd_game->Won > 0)
{
move_tick=1;
fall_tick=1;

bd_game->Won++;


if(bd_game->Won == 100)
{
int old_cave = bd_game->Cave;
int old_difficulty = bd_game->Difficulty;

old_cave++;

free(bd_game);
bd_game = bd_game_initialize(old_cave,old_difficulty);
}
}

if(bd_game->Lost > 0)
{
bd_game->Lost++;

if(bd_game->Lost == 100)
{
int old_cave = bd_game->Cave;
int old_difficulty = bd_game->Difficulty;

free(bd_game);

bd_game = bd_game_initialize(old_cave,old_difficulty);
}
}
//int uncovered = 1;

Expand Down
1 change: 1 addition & 0 deletions bd_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
struct bd_game_struct_t
{
int Tick;
int Cave;
int Difficulty;
int DiamonValue;
int DiamonValueBonus;
Expand Down
6 changes: 5 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ int main(int argc __attribute__((__unused__)), char *argv[] __attribute__((__unu

screen = SDL_SetVideoMode(CAVE_WIDTH*SDL_ZOOM,CAVE_HEIGHT*SDL_ZOOM,32, SDL_SWSURFACE | SDL_DOUBLEBUF);

struct bd_game_struct_t* bd_game = bd_game_initialize(0,0);
int curr_level = 0;
int curr_cave = 0;


struct bd_game_struct_t* bd_game = bd_game_initialize(curr_cave,curr_level);

/*
int idxtest=0;
Expand Down

0 comments on commit 0ebee92

Please sign in to comment.