mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-04-08 11:57:39 +02:00
added map state (not implemented yet :D)
This commit is contained in:
parent
e670d9d084
commit
1f8250972d
6 changed files with 54 additions and 4 deletions
7
intro.c
7
intro.c
|
@ -11,6 +11,7 @@ void Intro_Draw(struct Game *game) {
|
|||
else
|
||||
al_draw_bitmap(game->intro.table, -1*(game->intro.page)*al_get_display_width(game->display), 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 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->intro.font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.90, ALLEGRO_ALIGN_CENTRE, "Press any key to continue or escape to skip...");
|
||||
//PrintConsole(game, "drawing");
|
||||
if (game->intro.in_animation) {
|
||||
//PrintConsole(game, "animating");
|
||||
|
@ -23,7 +24,7 @@ void Intro_Draw(struct Game *game) {
|
|||
PrintConsole(game, "This was the last page.");
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MENU;
|
||||
game->loadstate = GAMESTATE_MAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +42,7 @@ int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MENU;
|
||||
game->loadstate = GAMESTATE_MAP;
|
||||
return 0;
|
||||
}
|
||||
if (!game->intro.in_animation) {
|
||||
|
@ -57,6 +58,7 @@ void Intro_Preload(struct Game *game) {
|
|||
game->intro.in_animation = false;
|
||||
game->intro.table_bitmap = al_load_bitmap( "table.png" );
|
||||
game->intro.table = al_create_bitmap(al_get_display_width(game->display)*4, al_get_display_height(game->display));
|
||||
game->intro.font = al_load_ttf_font("ShadowsIntoLight.ttf",al_get_display_height(game->display)*0.045,0 );
|
||||
al_set_target_bitmap(game->intro.table);
|
||||
al_draw_bitmap(game->intro.table_bitmap, 0, 0, 0);
|
||||
//game->intro.table_bitmap = al_load_bitmap( "loading.png" );
|
||||
|
@ -83,4 +85,5 @@ void Intro_Unload(struct Game *game) {
|
|||
}
|
||||
al_destroy_bitmap(game->intro.table_bitmap);
|
||||
al_destroy_bitmap(game->intro.table);
|
||||
al_destroy_font(game->intro.font);
|
||||
}
|
||||
|
|
19
main.c
19
main.c
|
@ -3,6 +3,7 @@
|
|||
#include "loading.h"
|
||||
#include "about.h"
|
||||
#include "intro.h"
|
||||
#include "map.h"
|
||||
|
||||
float FPS = 60;
|
||||
int DISPLAY_WIDTH = 800;
|
||||
|
@ -45,6 +46,10 @@ void PreloadGameState(struct Game *game) {
|
|||
else if (game->loadstate==GAMESTATE_INTRO) {
|
||||
PrintConsole(game, "Preload GAMESTATE_INTRO...");
|
||||
Intro_Preload(game);
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_MAP) {
|
||||
PrintConsole(game, "Preload GAMESTATE_MAP...");
|
||||
Map_Preload(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to preload unknown gamestate!");
|
||||
}
|
||||
|
@ -67,6 +72,10 @@ void UnloadGameState(struct Game *game) {
|
|||
else if (game->gamestate==GAMESTATE_INTRO) {
|
||||
PrintConsole(game, "Unload GAMESTATE_INTRO...");
|
||||
Intro_Unload(game);
|
||||
}
|
||||
else if (game->gamestate==GAMESTATE_MAP) {
|
||||
PrintConsole(game, "Unload GAMESTATE_MAP...");
|
||||
Map_Unload(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate!");
|
||||
}
|
||||
|
@ -89,6 +98,10 @@ void LoadGameState(struct Game *game) {
|
|||
else if (game->loadstate==GAMESTATE_INTRO) {
|
||||
PrintConsole(game, "Load GAMESTATE_INTRO...");
|
||||
Intro_Load(game);
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_MAP) {
|
||||
PrintConsole(game, "Load GAMESTATE_MAP...");
|
||||
Map_Load(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to load unknown gamestate!");
|
||||
}
|
||||
|
@ -215,6 +228,9 @@ int main(int argc, char **argv){
|
|||
else if (game.gamestate==GAMESTATE_INTRO) {
|
||||
if (Intro_Keydown(&game, &ev)) break;
|
||||
}
|
||||
else if (game.gamestate==GAMESTATE_MAP) {
|
||||
if (Map_Keydown(&game, &ev)) break;
|
||||
}
|
||||
else {
|
||||
game.showconsole = true;
|
||||
PrintConsole(&game, "ERROR: Keystroke in unknown gamestate! (5 sec sleep)");
|
||||
|
@ -240,6 +256,9 @@ int main(int argc, char **argv){
|
|||
}
|
||||
else if (game.gamestate==GAMESTATE_INTRO) {
|
||||
Intro_Draw(&game);
|
||||
}
|
||||
else if (game.gamestate==GAMESTATE_MAP) {
|
||||
Map_Draw(&game);
|
||||
}
|
||||
else {
|
||||
game.showconsole = true;
|
||||
|
|
4
main.h
4
main.h
|
@ -12,7 +12,8 @@ enum gamestate_enum {
|
|||
GAMESTATE_LOADING,
|
||||
GAMESTATE_MENU,
|
||||
GAMESTATE_ABOUT,
|
||||
GAMESTATE_INTRO
|
||||
GAMESTATE_INTRO,
|
||||
GAMESTATE_MAP
|
||||
};
|
||||
|
||||
struct Menu {
|
||||
|
@ -37,6 +38,7 @@ struct Intro {
|
|||
int page;
|
||||
bool in_animation;
|
||||
ALLEGRO_BITMAP *table, *table_bitmap;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
||||
|
||||
struct Game {
|
||||
|
|
2
make
2
make
|
@ -1,2 +1,2 @@
|
|||
#!/bin/sh
|
||||
gcc loading.c main.c menu.c about.c intro.c -o superderpy -lallegro -lallegro_audio -lallegro_acodec -lallegro_image -lallegro_font -lallegro_ttf -std=gnu99 -g && ./superderpy
|
||||
gcc loading.c main.c menu.c about.c intro.c map.c -o superderpy -lallegro -lallegro_audio -lallegro_acodec -lallegro_image -lallegro_font -lallegro_ttf -std=gnu99 -g && ./superderpy
|
||||
|
|
19
map.c
Normal file
19
map.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include "map.h"
|
||||
|
||||
void Map_Draw(struct Game *game) {
|
||||
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!");
|
||||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
al_rest(5.0);
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MENU;
|
||||
}
|
||||
|
||||
void Map_Load(struct Game *game) {}
|
||||
int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; }
|
||||
void Map_Preload(struct Game *game) {}
|
||||
void Map_Unload(struct Game *game) {}
|
7
map.h
Normal file
7
map.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "main.h"
|
||||
|
||||
void Map_Draw(struct Game *game);
|
||||
void Map_Preload(struct Game *game);
|
||||
void Map_Unload(struct Game *game);
|
||||
void Map_Load(struct Game *game);
|
||||
int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
Loading…
Add table
Reference in a new issue