diff --git a/src/level.c b/src/level.c index f61b24c..eeeba93 100644 --- a/src/level.c +++ b/src/level.c @@ -110,7 +110,7 @@ bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_Act obst->x = 100; obst->y = (rand()%91)-1; obst->speed = 0; - obst->bitmap = game->level.obst_bmps.pie; + obst->bitmap = &(game->level.obst_bmps.pie); obst->callback = NULL; obst->data = NULL; if (rand()%100<=50) obst->callback=Obst_MoveUpDown; @@ -194,12 +194,12 @@ void Level_Draw(struct Game *game) { bool col = false; int x = (tmp->x/100.0)*al_get_display_width(game->display); int y = (tmp->y/100.0)*al_get_display_height(game->display); - int w = al_get_bitmap_width(tmp->bitmap); - int h = al_get_bitmap_height(tmp->bitmap); + int w = al_get_bitmap_width(*(tmp->bitmap)); + int h = al_get_bitmap_height(*(tmp->bitmap)); if ((((x>=derpyx) && (x<=derpyx+derpyw)) || ((x+w>=derpyx) && (x+w<=derpyx+derpyw))) && (((y>=derpyy) && (y<=derpyy+derpyh)) || ((y+h>=derpyy) && (y+h<=derpyy+derpyh)))) col = true; - al_draw_tinted_bitmap(tmp->bitmap, al_map_rgba_f(255,255-col*255,255-col*255,1), x, y, 0); + al_draw_tinted_bitmap(*(tmp->bitmap), al_map_rgba_f(255,255-col*255,255-col*255,1), x, y, 0); if (col) colision = true; tmp->x -= game->level.speed*310; if (tmp->callback) tmp->callback(game, tmp); diff --git a/src/main.h b/src/main.h index 0d8ca70..e91d038 100644 --- a/src/main.h +++ b/src/main.h @@ -30,6 +30,8 @@ #include #include +struct Game; + /*! \brief Enum of all available gamestates. */ enum gamestate_enum { GAMESTATE_PAUSE, @@ -50,7 +52,14 @@ struct Moonwalk { double derpy_pos; /*!< Position of Derpy on screen. */ }; -struct Obstracle; +struct Obstracle { + ALLEGRO_BITMAP **bitmap; + float x, y, speed; + int points; + void (*callback)(struct Game*, struct Obstracle*); + void *data; + struct Obstracle *prev, *next; +}; /*! \brief Resources used by Level state. */ struct Level { @@ -217,15 +226,6 @@ struct Game { } audio; }; -struct Obstracle { - ALLEGRO_BITMAP *bitmap; - float x, y, speed; - int points; - void (*callback)(struct Game*, struct Obstracle*); - void *data; - struct Obstracle *prev, *next; -}; - /*! \brief Draws text with shadow. * * Draws given text two times: once with color (0,0,0,128) and 1px off in both x and y axis,