diff --git a/src/levels/modules/dodger/actions.c b/src/levels/modules/dodger/actions.c index 3a89f77..5a1da5c 100644 --- a/src/levels/modules/dodger/actions.c +++ b/src/levels/modules/dodger/actions.c @@ -149,7 +149,8 @@ bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_Acti } else { obst->callback = &Obst_MoveUpDown; obst->bitmap = &(game->level.dodger.obst_bmps.screwball); - obst->data = (void*)(rand()%2); // FIXME: not portable! + obst->data = malloc(sizeof(bool)); + *((bool*)obst->data) = rand()%2; obst->rows = 4; obst->cols = 4; obst->speed = 1.1; diff --git a/src/levels/modules/dodger/callbacks.c b/src/levels/modules/dodger/callbacks.c index d5c1bab..394cf48 100644 --- a/src/levels/modules/dodger/callbacks.c +++ b/src/levels/modules/dodger/callbacks.c @@ -23,15 +23,15 @@ #include "callbacks.h" void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle) { - if (obstacle->data) { + if (*((bool*)obstacle->data)) { obstacle->y -= 0.5; if (obstacle->y<=0) { - obstacle->data=NULL; + *((bool*)obstacle->data)=false; } } else { obstacle->y += 0.5; if (obstacle->y>=((game->viewportHeight-al_get_bitmap_height(*(obstacle->bitmap))/obstacle->rows)/(float)game->viewportHeight)*100) { - obstacle->data++; + *((bool*)obstacle->data)=true; } } }