fix fullscreen switching with obstracles rendered

This commit is contained in:
Sebastian Krzyszkowiak 2012-05-03 13:20:25 +02:00
parent 62c7a3cd98
commit 9959c1c6fe
2 changed files with 14 additions and 14 deletions

View file

@ -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);

View file

@ -30,6 +30,8 @@
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_ttf.h>
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,