mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-05 00:38:00 +01:00
console
This commit is contained in:
parent
08d9c34cb1
commit
7cc3590780
6 changed files with 64 additions and 5 deletions
BIN
Courier_New.ttf
Normal file
BIN
Courier_New.ttf
Normal file
Binary file not shown.
1
about.c
1
about.c
|
@ -5,6 +5,7 @@
|
|||
void About_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);
|
||||
|
|
|
@ -7,16 +7,20 @@ void Loading_Draw(struct Game *game) {
|
|||
for(int fadeloop=0; fadeloop<256; fadeloop+=10){
|
||||
al_wait_for_event(game->event_queue, &ev);
|
||||
al_draw_tinted_bitmap(game->loading.loading_bitmap,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0);
|
||||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
}
|
||||
|
||||
|
||||
al_draw_bitmap(game->loading.loading_bitmap,0,0,0);
|
||||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
|
||||
|
||||
PreloadGameState(game);
|
||||
|
||||
for(int fadeloop=255; fadeloop>0; fadeloop-=10){
|
||||
al_wait_for_event(game->event_queue, &ev);
|
||||
al_draw_tinted_bitmap(game->loading.loading_bitmap,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0);
|
||||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
}
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
|
|
50
main.c
50
main.c
|
@ -7,40 +7,77 @@ float FPS = 60;
|
|||
int DISPLAY_WIDTH = 800;
|
||||
int DISPLAY_HEIGHT = 500;
|
||||
bool FULLSCREEN = true;
|
||||
bool DEBUG = false;
|
||||
|
||||
void PrintConsole(struct Game *game, char* text) {
|
||||
printf("%s\n", text);
|
||||
ALLEGRO_BITMAP *con = al_create_bitmap(al_get_bitmap_width(game->console), al_get_bitmap_height(game->console)*1.0);
|
||||
al_set_target_bitmap(con);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,80));
|
||||
al_draw_bitmap_region(game->console, 0, al_get_bitmap_height(game->console)*0.2, al_get_bitmap_width(game->console), al_get_bitmap_height(game->console)*0.8, 0, 0, 0);
|
||||
al_draw_text(game->font_console, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.005, al_get_bitmap_height(game->console)*0.8, ALLEGRO_ALIGN_LEFT, text);
|
||||
al_set_target_bitmap(game->console);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
//al_draw_bitmap_region(game->console, 0, al_get_bitmap_height(game->console)*0.2, al_get_bitmap_width(game->console), al_get_bitmap_height(game->console)*0.8, 0, 0, 0);
|
||||
al_draw_bitmap(con, 0, 0, 0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
}
|
||||
|
||||
void DrawConsole(struct Game *game) {
|
||||
if (DEBUG) al_draw_bitmap(game->console, 0, 0, 0);
|
||||
}
|
||||
|
||||
void PreloadGameState(struct Game *game) {
|
||||
if (game->loadstate==GAMESTATE_MENU) {
|
||||
PrintConsole(game, "Preload GAMESTATE_MENU...");
|
||||
Menu_Preload(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_LOADING) {
|
||||
PrintConsole(game, "Preload GAMESTATE_LOADING...");
|
||||
Loading_Preload(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_ABOUT) {
|
||||
PrintConsole(game, "Preload GAMESTATE_ABOUT...");
|
||||
About_Preload(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
}
|
||||
|
||||
void UnloadGameState(struct Game *game) {
|
||||
if (game->gamestate==GAMESTATE_MENU) {
|
||||
PrintConsole(game, "Unload GAMESTATE_MENU...");
|
||||
Menu_Unload(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
else if (game->gamestate==GAMESTATE_LOADING) {
|
||||
PrintConsole(game, "Unload GAMESTATE_LOADING...");
|
||||
Loading_Unload(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
else if (game->gamestate==GAMESTATE_ABOUT) {
|
||||
PrintConsole(game, "Unload GAMESTATE_ABOUT...");
|
||||
About_Unload(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
}
|
||||
|
||||
void LoadGameState(struct Game *game) {
|
||||
if (game->loadstate==GAMESTATE_MENU) {
|
||||
PrintConsole(game, "Load GAMESTATE_MENU...");
|
||||
Menu_Load(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_LOADING) {
|
||||
PrintConsole(game, "Load GAMESTATE_LOADING...");
|
||||
Loading_Load(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_ABOUT) {
|
||||
PrintConsole(game, "Load GAMESTATE_ABOUT...");
|
||||
About_Load(game);
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
game->gamestate = game->loadstate;
|
||||
game->loadstate = -1;
|
||||
|
@ -109,6 +146,7 @@ int main(int argc, char **argv){
|
|||
al_set_window_title(game.display, "Super Derpy: Muffin Attack");
|
||||
al_hide_mouse_cursor(game.display);
|
||||
game.font = al_load_ttf_font("ShadowsIntoLight.ttf",al_get_display_height(game.display)*0.09,0 );
|
||||
game.font_console = al_load_ttf_font("Courier_New.ttf",al_get_display_height(game.display)*0.018,0 );
|
||||
|
||||
game.event_queue = al_create_event_queue();
|
||||
if(!game.event_queue) {
|
||||
|
@ -121,6 +159,11 @@ int main(int argc, char **argv){
|
|||
al_register_event_source(game.event_queue, al_get_timer_event_source(game.timer));
|
||||
al_register_event_source(game.event_queue, al_get_keyboard_event_source());
|
||||
|
||||
game.console = al_create_bitmap(al_get_display_width(game.display), al_get_display_height(game.display)*0.12);
|
||||
al_set_target_bitmap(game.console);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,80));
|
||||
al_set_target_bitmap(al_get_backbuffer(game.display));
|
||||
|
||||
al_clear_to_color(al_map_rgb(0,0,0));
|
||||
al_flip_display();
|
||||
|
||||
|
@ -142,6 +185,9 @@ int main(int argc, char **argv){
|
|||
break;
|
||||
}
|
||||
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if ((ev.type == ALLEGRO_EVENT_KEY_DOWN) && (ev.keyboard.keycode == ALLEGRO_KEY_TILDE)) {
|
||||
DEBUG = !DEBUG;
|
||||
}
|
||||
if (game.gamestate==GAMESTATE_LOADING) {
|
||||
if (Loading_Keydown(&game, &ev)) break;
|
||||
}
|
||||
|
@ -164,14 +210,18 @@ int main(int argc, char **argv){
|
|||
else if (game.gamestate==GAMESTATE_ABOUT) {
|
||||
About_Draw(&game);
|
||||
}
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
}
|
||||
}
|
||||
|
||||
UnloadGameState(&game);
|
||||
al_rest(0.1);
|
||||
al_destroy_timer(game.timer);
|
||||
al_destroy_display(game.display);
|
||||
al_destroy_bitmap(game.loading.loading_bitmap);
|
||||
al_destroy_event_queue(game.event_queue);
|
||||
al_destroy_font(game.font);
|
||||
al_destroy_font(game.font_console);
|
||||
return 0;
|
||||
}
|
||||
|
|
5
main.h
5
main.h
|
@ -34,11 +34,12 @@ struct Loading {
|
|||
|
||||
struct Game {
|
||||
ALLEGRO_DISPLAY *display;
|
||||
ALLEGRO_FONT *font;
|
||||
ALLEGRO_FONT *font, *font_console;
|
||||
enum gamestate_enum gamestate;
|
||||
enum gamestate_enum loadstate;
|
||||
ALLEGRO_EVENT_QUEUE *event_queue;
|
||||
ALLEGRO_TIMER *timer;
|
||||
ALLEGRO_BITMAP *console;
|
||||
struct Menu menu;
|
||||
struct Loading loading;
|
||||
};
|
||||
|
@ -46,5 +47,7 @@ struct Game {
|
|||
void PreloadGameState(struct Game *game);
|
||||
void UnloadGameState(struct Game *game);
|
||||
void LoadGameState(struct Game *game);
|
||||
void PrintConsole(struct Game *game, char* text);
|
||||
void DrawConsole(struct Game *game);
|
||||
|
||||
#endif
|
5
menu.c
5
menu.c
|
@ -53,7 +53,6 @@ void Menu_Draw(struct Game *game) {
|
|||
game->menu.cloud2_position-=0.025;
|
||||
if (game->menu.cloud_position<-80) game->menu.cloud_position=100;
|
||||
if (game->menu.cloud2_position<0) game->menu.cloud2_position=100;
|
||||
al_flip_display();
|
||||
}
|
||||
|
||||
void Menu_Preload(struct Game *game) {
|
||||
|
@ -144,7 +143,7 @@ void Menu_Preload(struct Game *game) {
|
|||
al_draw_text(game->menu.font, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.7, ALLEGRO_ALIGN_CENTRE, "About");
|
||||
al_draw_text(game->menu.font, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
|
||||
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
}
|
||||
|
||||
void Menu_Unload(struct Game *game) {
|
||||
|
@ -154,6 +153,7 @@ void Menu_Unload(struct Game *game) {
|
|||
for(int fadeloop=255; fadeloop>=0; fadeloop-=10){
|
||||
al_wait_for_event(game->event_queue, &ev);
|
||||
al_draw_tinted_bitmap(game->menu.menu_fade_bitmap,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->menu.menu_fade_bitmap);
|
||||
|
@ -178,6 +178,7 @@ void Menu_Load(struct Game *game) {
|
|||
for(int fadeloop=0; fadeloop<256; fadeloop+=10){
|
||||
al_wait_for_event(game->event_queue, &ev);
|
||||
al_draw_tinted_bitmap(game->menu.menu_fade_bitmap,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0);
|
||||
DrawConsole(game);
|
||||
al_flip_display();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue