mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 19:16:44 +01:00
fix fullscreen switching with obstracles rendered
This commit is contained in:
parent
62c7a3cd98
commit
9959c1c6fe
2 changed files with 14 additions and 14 deletions
|
@ -110,7 +110,7 @@ bool GenerateObstracles(struct Game *game, struct TM_Action *action, enum TM_Act
|
||||||
obst->x = 100;
|
obst->x = 100;
|
||||||
obst->y = (rand()%91)-1;
|
obst->y = (rand()%91)-1;
|
||||||
obst->speed = 0;
|
obst->speed = 0;
|
||||||
obst->bitmap = game->level.obst_bmps.pie;
|
obst->bitmap = &(game->level.obst_bmps.pie);
|
||||||
obst->callback = NULL;
|
obst->callback = NULL;
|
||||||
obst->data = NULL;
|
obst->data = NULL;
|
||||||
if (rand()%100<=50) obst->callback=Obst_MoveUpDown;
|
if (rand()%100<=50) obst->callback=Obst_MoveUpDown;
|
||||||
|
@ -194,12 +194,12 @@ void Level_Draw(struct Game *game) {
|
||||||
bool col = false;
|
bool col = false;
|
||||||
int x = (tmp->x/100.0)*al_get_display_width(game->display);
|
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 y = (tmp->y/100.0)*al_get_display_height(game->display);
|
||||||
int w = al_get_bitmap_width(tmp->bitmap);
|
int w = al_get_bitmap_width(*(tmp->bitmap));
|
||||||
int h = al_get_bitmap_height(tmp->bitmap);
|
int h = al_get_bitmap_height(*(tmp->bitmap));
|
||||||
if ((((x>=derpyx) && (x<=derpyx+derpyw)) || ((x+w>=derpyx) && (x+w<=derpyx+derpyw))) &&
|
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))))
|
(((y>=derpyy) && (y<=derpyy+derpyh)) || ((y+h>=derpyy) && (y+h<=derpyy+derpyh))))
|
||||||
col = true;
|
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;
|
if (col) colision = true;
|
||||||
tmp->x -= game->level.speed*310;
|
tmp->x -= game->level.speed*310;
|
||||||
if (tmp->callback) tmp->callback(game, tmp);
|
if (tmp->callback) tmp->callback(game, tmp);
|
||||||
|
|
20
src/main.h
20
src/main.h
|
@ -30,6 +30,8 @@
|
||||||
#include <allegro5/allegro_font.h>
|
#include <allegro5/allegro_font.h>
|
||||||
#include <allegro5/allegro_ttf.h>
|
#include <allegro5/allegro_ttf.h>
|
||||||
|
|
||||||
|
struct Game;
|
||||||
|
|
||||||
/*! \brief Enum of all available gamestates. */
|
/*! \brief Enum of all available gamestates. */
|
||||||
enum gamestate_enum {
|
enum gamestate_enum {
|
||||||
GAMESTATE_PAUSE,
|
GAMESTATE_PAUSE,
|
||||||
|
@ -50,7 +52,14 @@ struct Moonwalk {
|
||||||
double derpy_pos; /*!< Position of Derpy on screen. */
|
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. */
|
/*! \brief Resources used by Level state. */
|
||||||
struct Level {
|
struct Level {
|
||||||
|
@ -217,15 +226,6 @@ struct Game {
|
||||||
} audio;
|
} 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.
|
/*! \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,
|
* Draws given text two times: once with color (0,0,0,128) and 1px off in both x and y axis,
|
||||||
|
|
Loading…
Reference in a new issue