mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-08 06:06:43 +01:00
some initial implementation of map state
This commit is contained in:
parent
ce46ffd402
commit
055a3d8c44
2 changed files with 64 additions and 12 deletions
6
main.h
6
main.h
|
@ -37,6 +37,11 @@ struct About {
|
||||||
ALLEGRO_BITMAP *fade_bitmap, *image;
|
ALLEGRO_BITMAP *fade_bitmap, *image;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct Map {
|
||||||
|
ALLEGRO_BITMAP *map, *background, *map_bg, *highlight;
|
||||||
|
int selected, available;
|
||||||
|
};
|
||||||
|
|
||||||
struct Intro {
|
struct Intro {
|
||||||
int position;
|
int position;
|
||||||
int page;
|
int page;
|
||||||
|
@ -58,6 +63,7 @@ struct Game {
|
||||||
struct Loading loading;
|
struct Loading loading;
|
||||||
struct Intro intro;
|
struct Intro intro;
|
||||||
struct About about;
|
struct About about;
|
||||||
|
struct Map map;
|
||||||
};
|
};
|
||||||
|
|
||||||
void PreloadGameState(struct Game *game);
|
void PreloadGameState(struct Game *game);
|
||||||
|
|
70
map.c
70
map.c
|
@ -1,19 +1,65 @@
|
||||||
#include <allegro5/allegro.h>
|
#include <allegro5/allegro.h>
|
||||||
#include <allegro5/allegro_font.h>
|
#include <allegro5/allegro_font.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
|
||||||
void Map_Draw(struct Game *game) {
|
void Map_Draw(struct Game *game) {
|
||||||
al_clear_to_color(al_map_rgb(0,0,0));
|
//al_clear_to_color(al_map_rgb(0,0,0));
|
||||||
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2, ALLEGRO_ALIGN_CENTRE, "Not implemented yet!");
|
//al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2, ALLEGRO_ALIGN_CENTRE, "Not implemented yet!");
|
||||||
DrawConsole(game);
|
//DrawConsole(game);
|
||||||
al_flip_display();
|
//al_flip_display();
|
||||||
al_rest(3.0);
|
//al_rest(3.0);
|
||||||
UnloadGameState(game);
|
//UnloadGameState(game);
|
||||||
game->gamestate = GAMESTATE_LOADING;
|
//game->gamestate = GAMESTATE_LOADING;
|
||||||
game->loadstate = GAMESTATE_MENU;
|
//game->loadstate = GAMESTATE_MENU;
|
||||||
|
al_draw_bitmap(game->map.map, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Map_Load(struct Game *game) {}
|
void Map_Load(struct Game *game) {
|
||||||
int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; }
|
ALLEGRO_EVENT ev;
|
||||||
void Map_Preload(struct Game *game) {}
|
for(int fadeloop=0; fadeloop<256; fadeloop+=10){
|
||||||
void Map_Unload(struct Game *game) {}
|
al_wait_for_event(game->event_queue, &ev);
|
||||||
|
al_draw_tinted_bitmap(game->map.map,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0);
|
||||||
|
DrawConsole(game);
|
||||||
|
al_flip_display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||||
|
//if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||||
|
UnloadGameState(game);
|
||||||
|
game->gamestate = GAMESTATE_LOADING;
|
||||||
|
game->loadstate = GAMESTATE_MENU;
|
||||||
|
return 0;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Map_Preload(struct Game *game) {
|
||||||
|
game->map.available = 6;
|
||||||
|
game->map.selected = game->map.available;
|
||||||
|
// ALLEGRO_BITMAP *map, *background, *map_bg, *highlight;
|
||||||
|
game->map.map = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||||
|
game->map.background = al_load_bitmap( "table.png" );
|
||||||
|
game->map.map_bg = al_load_bitmap( "map/background.png" );
|
||||||
|
//char* filename = "map/highlight1.png";
|
||||||
|
//sprintf(filename, "map/highlight%d.png", game->map.available);
|
||||||
|
//printf("%s\n", filename);
|
||||||
|
game->map.highlight = al_load_bitmap( "map/highlight6.png" );
|
||||||
|
al_set_target_bitmap(game->map.map);
|
||||||
|
al_draw_scaled_bitmap(game->map.background,0,0,al_get_bitmap_width(game->map.background),al_get_bitmap_height(game->map.background),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0);
|
||||||
|
al_draw_scaled_bitmap(game->map.map_bg,0,0,al_get_bitmap_width(game->map.map_bg),al_get_bitmap_height(game->map.map_bg),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0);
|
||||||
|
al_draw_scaled_bitmap(game->map.highlight,0,0,al_get_bitmap_width(game->map.highlight),al_get_bitmap_height(game->map.highlight),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0);
|
||||||
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
}
|
||||||
|
void Map_Unload(struct Game *game) {
|
||||||
|
ALLEGRO_EVENT ev;
|
||||||
|
for(int fadeloop=255; fadeloop>=0; fadeloop-=10){
|
||||||
|
al_wait_for_event(game->event_queue, &ev);
|
||||||
|
al_draw_tinted_bitmap(game->map.map, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0);
|
||||||
|
DrawConsole(game);
|
||||||
|
al_flip_display();
|
||||||
|
}
|
||||||
|
al_destroy_bitmap(game->map.map);
|
||||||
|
al_destroy_bitmap(game->map.background);
|
||||||
|
al_destroy_bitmap(game->map.map_bg);
|
||||||
|
al_destroy_bitmap(game->map.highlight);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue