mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 09:11:27 +01:00
bring back Menu gamestate
This commit is contained in:
parent
08c9506aeb
commit
7293ed191a
6 changed files with 351 additions and 324 deletions
|
@ -63,7 +63,7 @@ void LoadGamestate(struct Game *game, const char* name) {
|
|||
struct Gamestate *gs = FindGamestate(game, name);
|
||||
if (gs) {
|
||||
if (gs->loaded) {
|
||||
PrintConsole(game, "Gamestate %s already loaded.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" already loaded.", name);
|
||||
return;
|
||||
}
|
||||
gs->pending_load = true;
|
||||
|
@ -74,20 +74,21 @@ void LoadGamestate(struct Game *game, const char* name) {
|
|||
gs->fade_counter = 0;
|
||||
gs->pending_load = true;
|
||||
}
|
||||
PrintConsole(game, "Gamestate %s marked to be LOADED.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" marked to be LOADED.", name);
|
||||
}
|
||||
|
||||
void UnloadGamestate(struct Game *game, const char* name) {
|
||||
struct Gamestate *gs = FindGamestate(game, name);
|
||||
if (gs) {
|
||||
if (!gs->loaded) {
|
||||
PrintConsole(game, "Gamestate %s already unloaded.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" already unloaded.", name);
|
||||
return;
|
||||
}
|
||||
if (gs->started) gs->pending_start=true;
|
||||
gs->pending_load = true;
|
||||
PrintConsole(game, "Gamestate %s marked to be UNLOADED.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" marked to be UNLOADED.", name);
|
||||
} else {
|
||||
PrintConsole(game, "Tried to unload nonexisitent gamestate %s", name);
|
||||
PrintConsole(game, "Tried to unload nonexisitent gamestate \"%s\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,13 +96,13 @@ void StartGamestate(struct Game *game, const char* name) {
|
|||
struct Gamestate *gs = FindGamestate(game, name);
|
||||
if (gs) {
|
||||
if (gs->started) {
|
||||
PrintConsole(game, "Gamestate %s already started.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" already started.", name);
|
||||
return;
|
||||
}
|
||||
gs->pending_start = true;
|
||||
PrintConsole(game, "Gamestate %s marked to be STARTED.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" marked to be STARTED.", name);
|
||||
} else {
|
||||
PrintConsole(game, "Tried to start nonexisitent gamestate %s", name);
|
||||
PrintConsole(game, "Tried to start nonexisitent gamestate \"%s\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,13 +110,13 @@ void StopGamestate(struct Game *game, const char* name) {
|
|||
struct Gamestate *gs = FindGamestate(game, name);
|
||||
if (gs) {
|
||||
if (!gs->started) {
|
||||
PrintConsole(game, "Gamestate %s already stopped.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" already stopped.", name);
|
||||
return;
|
||||
}
|
||||
gs->pending_start = true;
|
||||
PrintConsole(game, "Gamestate %s marked to be STOPPED.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" marked to be STOPPED.", name);
|
||||
} else {
|
||||
PrintConsole(game, "Tried to stop nonexisitent gamestate %s", name);
|
||||
PrintConsole(game, "Tried to stop nonexisitent gamestate \"%s\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -123,17 +124,17 @@ void PauseGamestate(struct Game *game, const char* name) {
|
|||
struct Gamestate *gs = FindGamestate(game, name);
|
||||
if (gs) {
|
||||
if (!gs->started) {
|
||||
PrintConsole(game, "Tried to pause gamestate %s which is not started.", name);
|
||||
PrintConsole(game, "Tried to pause gamestate \"%s\" which is not started.", name);
|
||||
return;
|
||||
}
|
||||
if (gs->paused) {
|
||||
PrintConsole(game, "Gamestate %s already paused.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" already paused.", name);
|
||||
return;
|
||||
}
|
||||
gs->paused = true;
|
||||
PrintConsole(game, "Gamestate %s paused.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" paused.", name);
|
||||
} else {
|
||||
PrintConsole(game, "Tried to pause nonexisitent gamestate %s", name);
|
||||
PrintConsole(game, "Tried to pause nonexisitent gamestate \"%s\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,17 +142,17 @@ void ResumeGamestate(struct Game *game, const char* name) {
|
|||
struct Gamestate *gs = FindGamestate(game, name);
|
||||
if (gs) {
|
||||
if (!gs->started) {
|
||||
PrintConsole(game, "Tried to resume gamestate %s which is not started.", name);
|
||||
PrintConsole(game, "Tried to resume gamestate \"%s\" which is not started.", name);
|
||||
return;
|
||||
}
|
||||
if (!gs->paused) {
|
||||
PrintConsole(game, "Gamestate %s already resumed.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" already resumed.", name);
|
||||
return;
|
||||
}
|
||||
gs->paused = false;
|
||||
PrintConsole(game, "Gamestate %s resumed.", name);
|
||||
PrintConsole(game, "Gamestate \"%s\" resumed.", name);
|
||||
} else {
|
||||
PrintConsole(game, "Tried to resume nonexisitent gamestate %s", name);
|
||||
PrintConsole(game, "Tried to resume nonexisitent gamestate \"%s\"", name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ MACRO(GAMESTATE name)
|
|||
|
||||
ENDMACRO()
|
||||
|
||||
#GAMESTATE("menu")
|
||||
GAMESTATE("menu")
|
||||
GAMESTATE("disclaimer")
|
||||
GAMESTATE("intro")
|
||||
GAMESTATE("map")
|
||||
|
|
|
@ -174,7 +174,9 @@ void Gamestate_Draw(struct Game *game, struct IntroResources* data) {
|
|||
PrintConsole(game, "This was the last page.");
|
||||
data->in_animation = false;
|
||||
data->page--;
|
||||
SwitchGamestate(game, "intro", "map");
|
||||
StopGamestate(game, "intro");
|
||||
LoadGamestate(game, "map");
|
||||
StartGamestate(game, "map");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +189,9 @@ void Gamestate_Start(struct Game *game, struct IntroResources* data) {
|
|||
void Gamestate_ProcessEvent(struct Game *game, struct IntroResources* data, ALLEGRO_EVENT *ev) {
|
||||
if (ev->type != ALLEGRO_EVENT_KEY_DOWN) return;
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, "intro", "map");
|
||||
StopGamestate(game, "intro");
|
||||
LoadGamestate(game, "map");
|
||||
StartGamestate(game, "map");
|
||||
return;
|
||||
}
|
||||
if (!data->in_animation) {
|
||||
|
|
|
@ -20,52 +20,56 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <allegro5/allegro_ttf.h>
|
||||
#include "../config.h"
|
||||
#include "../utils.h"
|
||||
#include "menu.h"
|
||||
|
||||
void DrawMenuState(struct Game *game) {
|
||||
int Gamestate_ProgressCount = 0;
|
||||
|
||||
void DrawMenuState(struct Game *game, struct MenuResources *data) {
|
||||
ALLEGRO_FONT *font;
|
||||
char* text = malloc(255*sizeof(char));
|
||||
struct ALLEGRO_COLOR color;
|
||||
switch (game->menu.menustate) {
|
||||
switch (data->menustate) {
|
||||
case MENUSTATE_MAIN:
|
||||
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, "Start game");
|
||||
font = game->menu.font; if (game->menu.selected==1) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, "Options");
|
||||
font = game->menu.font; if (game->menu.selected==2) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.7, ALLEGRO_ALIGN_CENTRE, "About");
|
||||
font = game->menu.font; if (game->menu.selected==3) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
|
||||
font = data->font; if (data->selected==0) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Start game");
|
||||
font = data->font; if (data->selected==1) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "Options");
|
||||
font = data->font; if (data->selected==2) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.7, ALLEGRO_ALIGN_CENTRE, "About");
|
||||
font = data->font; if (data->selected==3) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
|
||||
break;
|
||||
case MENUSTATE_OPTIONS:
|
||||
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, "Control settings");
|
||||
font = game->menu.font; if (game->menu.selected==1) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, "Video settings");
|
||||
font = game->menu.font; if (game->menu.selected==2) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.7, ALLEGRO_ALIGN_CENTRE, "Audio settings");
|
||||
font = game->menu.font; if (game->menu.selected==3) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
font = data->font; if (data->selected==0) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Control settings");
|
||||
font = data->font; if (data->selected==1) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "Video settings");
|
||||
font = data->font; if (data->selected==2) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.7, ALLEGRO_ALIGN_CENTRE, "Audio settings");
|
||||
font = data->font; if (data->selected==3) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
break;
|
||||
case MENUSTATE_AUDIO:
|
||||
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
|
||||
if (game->music) sprintf(text, "Music volume: %d0%%", game->music);
|
||||
font = data->font; if (data->selected==0) font = data->font_selected;
|
||||
if (game->config.music) sprintf(text, "Music volume: %d0%%", game->config.music);
|
||||
else sprintf(text, "Music disabled");
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = game->menu.font; if (game->menu.selected==1) font = game->menu.font_selected;
|
||||
if (game->fx) sprintf(text, "Effects volume: %d0%%", game->fx);
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = data->font; if (data->selected==1) font = data->font_selected;
|
||||
if (game->config.fx) sprintf(text, "Effects volume: %d0%%", game->config.fx);
|
||||
else sprintf(text, "Effects disabled");
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = game->menu.font; if (game->menu.selected==2) font = game->menu.font_selected;
|
||||
if (game->voice) sprintf(text, "Voice volume: %d0%%", game->voice);
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = data->font; if (data->selected==2) font = data->font_selected;
|
||||
if (game->config.voice) sprintf(text, "Voice volume: %d0%%", game->config.voice);
|
||||
else sprintf(text, "Voice disabled");
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.7, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = game->menu.font; if (game->menu.selected==3) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.7, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = data->font; if (data->selected==3) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
break;
|
||||
case MENUSTATE_VIDEO:
|
||||
if (game->menu.options.fullscreen) {
|
||||
if (data->options.fullscreen) {
|
||||
sprintf(text, "Fullscreen: yes");
|
||||
color = al_map_rgba(0,0,0,128);
|
||||
}
|
||||
|
@ -73,77 +77,72 @@ void DrawMenuState(struct Game *game) {
|
|||
sprintf(text, "Fullscreen: no");
|
||||
color = al_map_rgba(255,255,255,255);
|
||||
}
|
||||
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = game->menu.font; if (game->menu.selected==1) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, color, game->viewportWidth*0.5, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, "Resolution: 800x500");
|
||||
font = game->menu.font; if (game->menu.selected==2) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.7, ALLEGRO_ALIGN_CENTRE, "FPS: 60");
|
||||
font = game->menu.font; if (game->menu.selected==3) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
font = data->font; if (data->selected==0) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, text);
|
||||
font = data->font; if (data->selected==1) font = data->font_selected;
|
||||
DrawTextWithShadow(font, color, game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "Resolution: 800x500");
|
||||
font = data->font; if (data->selected==2) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.7, ALLEGRO_ALIGN_CENTRE, "FPS: 60");
|
||||
font = data->font; if (data->selected==3) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Back");
|
||||
break;
|
||||
case MENUSTATE_PAUSE:
|
||||
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, "Resume game");
|
||||
font = game->menu.font; if (game->menu.selected==1) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, "Return to map");
|
||||
font = game->menu.font; if (game->menu.selected==2) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.7, ALLEGRO_ALIGN_CENTRE, "Options");
|
||||
font = game->menu.font; if (game->menu.selected==3) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
|
||||
font = data->font; if (data->selected==0) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Resume game");
|
||||
font = data->font; if (data->selected==1) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.6, ALLEGRO_ALIGN_CENTRE, "Return to map");
|
||||
font = data->font; if (data->selected==2) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.7, ALLEGRO_ALIGN_CENTRE, "Options");
|
||||
font = data->font; if (data->selected==3) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
|
||||
break;
|
||||
default:
|
||||
game->menu.selected=0;
|
||||
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
|
||||
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, "Not implemented yet");
|
||||
data->selected=0;
|
||||
font = data->font; if (data->selected==0) font = data->font_selected;
|
||||
DrawTextWithShadow(font, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.5, ALLEGRO_ALIGN_CENTRE, "Not implemented yet");
|
||||
break;
|
||||
}
|
||||
free(text);
|
||||
}
|
||||
|
||||
void Menu_Draw(struct Game *game) {
|
||||
if (!game->menu.loaded) {
|
||||
game->gamestate=GAMESTATE_LOADING;
|
||||
game->loadstate=GAMESTATE_MENU;
|
||||
return;
|
||||
}
|
||||
void Gamestate_Draw(struct Game *game, struct MenuResources* data) {
|
||||
|
||||
al_set_target_bitmap(game->menu.pinkcloud_bitmap);
|
||||
al_set_target_bitmap(data->pinkcloud_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
float x = 1.5;
|
||||
int minus;
|
||||
if (game->menu.cloud_position>0) minus=1; else minus=-1;
|
||||
al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*5+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.7, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.88+(fmod(-1.8*(game->menu.cloud_position+80), 6))/20.0), 0);
|
||||
al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*3+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/3.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.78+(fmod(-2.8*(game->menu.cloud_position+80), 4))/18.0), 0);
|
||||
al_draw_scaled_bitmap(game->menu.rain_bitmap, 0, 0, al_get_bitmap_width(game->menu.rain_bitmap), al_get_bitmap_height(game->menu.rain_bitmap), fmod(minus*game->menu.cloud_position,3)*x*6+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.87+(fmod(-4.9*(game->menu.cloud_position+80), 8))/26.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.08, 0);
|
||||
al_draw_bitmap(game->menu.pinkcloud, 0, 0, 0);
|
||||
if (data->cloud_position>0) minus=1; else minus=-1;
|
||||
al_draw_bitmap(data->rain_bitmap, fmod(minus*data->cloud_position,3)*x*5+al_get_bitmap_width(data->pinkcloud_bitmap)/2.7, al_get_bitmap_height(data->pinkcloud_bitmap)*(0.88+(fmod(-1.8*(data->cloud_position+80), 6))/20.0), 0);
|
||||
al_draw_bitmap(data->rain_bitmap, fmod(minus*data->cloud_position,3)*x*3+al_get_bitmap_width(data->pinkcloud_bitmap)/3.1, al_get_bitmap_height(data->pinkcloud_bitmap)*(0.78+(fmod(-2.8*(data->cloud_position+80), 4))/18.0), 0);
|
||||
al_draw_scaled_bitmap(data->rain_bitmap, 0, 0, al_get_bitmap_width(data->rain_bitmap), al_get_bitmap_height(data->rain_bitmap), fmod(minus*data->cloud_position,3)*x*6+al_get_bitmap_width(data->pinkcloud_bitmap)/2.1, al_get_bitmap_height(data->pinkcloud_bitmap)*(0.87+(fmod(-4.9*(data->cloud_position+80), 8))/26.0), al_get_bitmap_width(data->pinkcloud_bitmap)*0.4, al_get_bitmap_height(data->pinkcloud_bitmap)*0.08, 0);
|
||||
al_draw_bitmap(data->pinkcloud, 0, 0, 0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_clear_to_color(al_map_rgb(183,234,193));
|
||||
float tint = (sin((game->menu.cloud_position-80)/15)+1)/2;
|
||||
if (tint < 0.000004) { PrintConsole(game, "random tint %f", tint); game->menu.mountain_position = (game->viewportWidth*(rand()/(float)RAND_MAX)/2)+game->viewportWidth/2; }
|
||||
al_draw_tinted_bitmap(game->menu.mountain,al_map_rgba_f(tint,tint,tint,tint),game->menu.mountain_position, 0,0);
|
||||
al_draw_scaled_bitmap(game->menu.cloud,0,0,al_get_bitmap_width(game->menu.cloud), al_get_bitmap_height(game->menu.cloud), game->viewportWidth*(sin((game->menu.cloud_position/40)-4.5)-0.3), game->viewportHeight*0.35, al_get_bitmap_width(game->menu.cloud)/2, al_get_bitmap_height(game->menu.cloud)/2,0);
|
||||
al_draw_bitmap(game->menu.cloud2,game->viewportWidth*(game->menu.cloud2_position/100.0), game->viewportHeight-(game->viewportWidth*(1240.0/3910.0))*0.7,0);
|
||||
al_draw_bitmap(game->menu.image,0, game->viewportHeight-(game->viewportWidth*(1240.0/3910.0)),0);
|
||||
float tint = (sin((data->cloud_position-80)/15)+1)/2;
|
||||
if (tint < 0.000004) { PrintConsole(game, "random tint %f", tint); data->mountain_position = (game->viewport.width*(rand()/(float)RAND_MAX)/2)+game->viewport.width/2; }
|
||||
al_draw_tinted_bitmap(data->mountain,al_map_rgba_f(tint,tint,tint,tint),data->mountain_position, 0,0);
|
||||
al_draw_scaled_bitmap(data->cloud,0,0,al_get_bitmap_width(data->cloud), al_get_bitmap_height(data->cloud), game->viewport.width*(sin((data->cloud_position/40)-4.5)-0.3), game->viewport.height*0.35, al_get_bitmap_width(data->cloud)/2, al_get_bitmap_height(data->cloud)/2,0);
|
||||
al_draw_bitmap(data->cloud2,game->viewport.width*(data->cloud2_position/100.0), game->viewport.height-(game->viewport.width*(1240.0/3910.0))*0.7,0);
|
||||
al_draw_bitmap(data->image,0, game->viewport.height-(game->viewport.width*(1240.0/3910.0)),0);
|
||||
|
||||
al_draw_bitmap(game->menu.pinkcloud_bitmap,(game->viewportWidth*0.12) + (cos((game->menu.cloud_position/25+80)*1.74444))*40, 0,0);
|
||||
al_draw_bitmap(game->menu.cloud,game->viewportWidth*game->menu.cloud_position/100, game->viewportHeight*0.1,0);
|
||||
al_draw_bitmap(data->pinkcloud_bitmap,(game->viewport.width*0.12) + (cos((data->cloud_position/25+80)*1.74444))*40, 0,0);
|
||||
al_draw_bitmap(data->cloud,game->viewport.width*data->cloud_position/100, game->viewport.height*0.1,0);
|
||||
|
||||
al_draw_bitmap(game->menu.pie_bitmap, game->viewportWidth/2, game->viewportHeight*(game->menu.cloud_position)/10,0);
|
||||
al_draw_bitmap(data->pie_bitmap, game->viewport.width/2, game->viewport.height*(data->cloud_position)/10,0);
|
||||
|
||||
/* GLASS EFFECT */
|
||||
al_set_target_bitmap(game->menu.blurbg);
|
||||
al_set_target_bitmap(data->blurbg);
|
||||
|
||||
al_clear_to_color(al_map_rgb(183,234,193));
|
||||
al_draw_scaled_bitmap(game->menu.cloud,0,0,al_get_bitmap_width(game->menu.cloud), al_get_bitmap_height(game->menu.cloud), game->viewportWidth*(sin((game->menu.cloud_position/40)-4.5)-0.3) - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), game->viewportHeight*0.35-(game->viewportHeight*0.1), al_get_bitmap_width(game->menu.cloud)/2, al_get_bitmap_height(game->menu.cloud)/2,0);
|
||||
al_draw_bitmap(game->menu.pinkcloud_bitmap,(game->viewportWidth*0.12) + (cos((game->menu.cloud_position/25+80)*1.74444))*40 - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), -(game->viewportHeight*0.1),0);
|
||||
al_draw_bitmap(game->menu.cloud,game->viewportWidth*game->menu.cloud_position/100 - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), game->viewportHeight*0.1-(game->viewportHeight*0.1),0);
|
||||
al_draw_bitmap(game->menu.pie_bitmap, game->viewportWidth/2 - (game->viewportWidth/2)+(al_get_bitmap_width(game->menu.logo)/2), game->viewportHeight*(game->menu.cloud_position)/10 -(game->viewportHeight*0.1),0);
|
||||
al_draw_scaled_bitmap(data->cloud,0,0,al_get_bitmap_width(data->cloud), al_get_bitmap_height(data->cloud), game->viewport.width*(sin((data->cloud_position/40)-4.5)-0.3) - (game->viewport.width/2)+(al_get_bitmap_width(data->logo)/2), game->viewport.height*0.35-(game->viewport.height*0.1), al_get_bitmap_width(data->cloud)/2, al_get_bitmap_height(data->cloud)/2,0);
|
||||
al_draw_bitmap(data->pinkcloud_bitmap,(game->viewport.width*0.12) + (cos((data->cloud_position/25+80)*1.74444))*40 - (game->viewport.width/2)+(al_get_bitmap_width(data->logo)/2), -(game->viewport.height*0.1),0);
|
||||
al_draw_bitmap(data->cloud,game->viewport.width*data->cloud_position/100 - (game->viewport.width/2)+(al_get_bitmap_width(data->logo)/2), game->viewport.height*0.1-(game->viewport.height*0.1),0);
|
||||
al_draw_bitmap(data->pie_bitmap, game->viewport.width/2 - (game->viewport.width/2)+(al_get_bitmap_width(data->logo)/2), game->viewport.height*(data->cloud_position)/10 -(game->viewport.height*0.1),0);
|
||||
|
||||
/*al_draw_bitmap_region(al_get_backbuffer(game->display), (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2), (game->viewportHeight*0.1), al_get_bitmap_width(game->menu.logo), al_get_bitmap_height(game->menu.logo), 0, 0, 0);*/
|
||||
/*al_draw_bitmap_region(al_get_backbuffer(game->display), (game->viewport.width/2)-(al_get_bitmap_width(data->logo)/2), (game->viewport.height*0.1), al_get_bitmap_width(data->logo), al_get_bitmap_height(data->logo), 0, 0, 0);*/
|
||||
|
||||
al_set_target_bitmap(game->menu.blurbg2);
|
||||
al_set_target_bitmap(data->blurbg2);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
|
||||
float alpha = (1.0/8.0);
|
||||
|
@ -152,55 +151,51 @@ void Menu_Draw(struct Game *game) {
|
|||
for (by = -2; by <= 2; by++) {
|
||||
for (bx = -2; bx <= 2; bx++) {
|
||||
if (sqrt(bx*bx+by*by) <= 2)
|
||||
al_draw_tinted_bitmap(game->menu.blurbg, color, bx*2, by*2, 0);
|
||||
al_draw_tinted_bitmap(data->blurbg, color, bx*2, by*2, 0);
|
||||
}
|
||||
}
|
||||
al_draw_bitmap(game->menu.glass, 0, 0, 0);
|
||||
al_draw_bitmap(data->glass, 0, 0, 0);
|
||||
al_set_blender(ALLEGRO_ADD, ALLEGRO_ZERO, ALLEGRO_ALPHA);
|
||||
al_draw_bitmap(game->menu.logo, 0, 0, 0);
|
||||
al_draw_bitmap(data->logo, 0, 0, 0);
|
||||
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
al_draw_bitmap(game->menu.blurbg2, (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2), (game->viewportHeight*0.1), 0);
|
||||
al_draw_bitmap(data->blurbg2, (game->viewport.width/2)-(al_get_bitmap_width(data->logo)/2), (game->viewport.height*0.1), 0);
|
||||
|
||||
al_draw_bitmap(game->menu.logoblur, (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2)-2, (game->viewportHeight*0.1)-2, 0);
|
||||
al_draw_tinted_bitmap(game->menu.logo, al_map_rgba_f(0.1, 0.1, 0.1, 0.1), (game->viewportWidth/2)-(al_get_bitmap_width(game->menu.logo)/2), (game->viewportHeight*0.1), 0);
|
||||
al_draw_bitmap(data->logoblur, (game->viewport.width/2)-(al_get_bitmap_width(data->logo)/2)-2, (game->viewport.height*0.1)-2, 0);
|
||||
al_draw_tinted_bitmap(data->logo, al_map_rgba_f(0.1, 0.1, 0.1, 0.1), (game->viewport.width/2)-(al_get_bitmap_width(data->logo)/2), (game->viewport.height*0.1), 0);
|
||||
/* END OF GLASS EFFECT */
|
||||
|
||||
al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.1, ALLEGRO_ALIGN_CENTRE, "Super Derpy");
|
||||
al_draw_text_with_shadow(game->menu.font_subtitle, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.275, ALLEGRO_ALIGN_CENTRE, "Muffin Attack");
|
||||
DrawTextWithShadow(data->font_title, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.1, ALLEGRO_ALIGN_CENTRE, "Super Derpy");
|
||||
DrawTextWithShadow(data->font_subtitle, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.275, ALLEGRO_ALIGN_CENTRE, "Muffin Attack");
|
||||
|
||||
DrawMenuState(game);
|
||||
DrawMenuState(game, data);
|
||||
}
|
||||
|
||||
void Menu_Logic(struct Game *game) {
|
||||
game->menu.cloud_position-=0.1;
|
||||
game->menu.cloud2_position-=0.025;
|
||||
if (game->menu.cloud_position<-80) { game->menu.cloud_position=100; PrintConsole(game, "cloud_position"); }
|
||||
if (game->menu.cloud2_position<0) { game->menu.cloud2_position=100; PrintConsole(game, "cloud2_position"); }
|
||||
void Gamestate_Logic(struct Game *game, struct MenuResources* data) {
|
||||
data->cloud_position-=0.1;
|
||||
data->cloud2_position-=0.025;
|
||||
if (data->cloud_position<-80) { data->cloud_position=100; PrintConsole(game, "cloud_position"); }
|
||||
if (data->cloud2_position<0) { data->cloud2_position=100; PrintConsole(game, "cloud2_position"); }
|
||||
}
|
||||
|
||||
void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
PROGRESS_INIT(16);
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
game->menu.options.fullscreen = game->fullscreen;
|
||||
game->menu.options.fps = game->fps;
|
||||
game->menu.options.width = game->width;
|
||||
game->menu.options.height = game->height;
|
||||
game->menu.loaded = true;
|
||||
game->menu.image = LoadScaledBitmap( "menu/menu.png", game->viewportWidth, game->viewportWidth*(1240.0/3910.0));
|
||||
PROGRESS;
|
||||
game->menu.mountain = LoadScaledBitmap( "menu/mountain.png", game->viewportHeight*1.6*0.055, game->viewportHeight/9 );
|
||||
PROGRESS;
|
||||
game->menu.cloud = LoadScaledBitmap( "menu/cloud.png", game->viewportHeight*1.6*0.5, game->viewportHeight*0.25 );
|
||||
PROGRESS;
|
||||
game->menu.cloud2 = LoadScaledBitmap( "menu/cloud2.png", game->viewportHeight*1.6*0.2, game->viewportHeight*0.1 );
|
||||
PROGRESS;
|
||||
game->menu.logo = LoadScaledBitmap( "menu/logo.png", game->viewportHeight*1.6*0.3, game->viewportHeight*0.35 );
|
||||
game->menu.blurbg = al_create_bitmap(game->viewportHeight*1.6*0.3, game->viewportHeight*0.35);
|
||||
game->menu.blurbg2 = al_create_bitmap(game->viewportHeight*1.6*0.3, game->viewportHeight*0.35);
|
||||
PROGRESS;
|
||||
game->menu.logoblur = al_create_bitmap(game->viewportHeight*1.6*0.3+4, game->viewportHeight*0.35+4);
|
||||
al_set_target_bitmap(game->menu.logoblur);
|
||||
struct MenuResources *data = malloc(sizeof(struct MenuResources));
|
||||
|
||||
data->options.fullscreen = game->config.fullscreen;
|
||||
data->options.fps = game->config.fps;
|
||||
data->options.width = game->config.width;
|
||||
data->options.height = game->config.height;
|
||||
data->loaded = true;
|
||||
data->image = LoadScaledBitmap(game, "menu/menu.png", game->viewport.width, game->viewport.width*(1240.0/3910.0));
|
||||
data->mountain = LoadScaledBitmap(game, "menu/mountain.png", game->viewport.height*1.6*0.055, game->viewport.height/9 );
|
||||
data->cloud = LoadScaledBitmap(game, "menu/cloud.png", game->viewport.height*1.6*0.5, game->viewport.height*0.25 );
|
||||
data->cloud2 = LoadScaledBitmap(game, "menu/cloud2.png", game->viewport.height*1.6*0.2, game->viewport.height*0.1 );
|
||||
data->logo = LoadScaledBitmap(game, "menu/logo.png", game->viewport.height*1.6*0.3, game->viewport.height*0.35 );
|
||||
data->blurbg = al_create_bitmap(game->viewport.height*1.6*0.3, game->viewport.height*0.35);
|
||||
data->blurbg2 = al_create_bitmap(game->viewport.height*1.6*0.3, game->viewport.height*0.35);
|
||||
data->logoblur = al_create_bitmap(game->viewport.height*1.6*0.3+4, game->viewport.height*0.35+4);
|
||||
al_set_target_bitmap(data->logoblur);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
float alpha = (1.0/40.0);
|
||||
ALLEGRO_COLOR color = al_map_rgba_f(alpha, alpha, alpha, alpha);
|
||||
|
@ -208,271 +203,269 @@ void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
|
|||
for (by = -2; by <= 2; by++) {
|
||||
for (bx = -2; bx <= 2; bx++) {
|
||||
if (sqrt(bx*bx+by*by) <= 2)
|
||||
al_draw_tinted_bitmap(game->menu.logo, color, bx, by, 0);
|
||||
al_draw_tinted_bitmap(data->logo, color, bx, by, 0);
|
||||
}
|
||||
}
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
PROGRESS;
|
||||
game->menu.glass = LoadScaledBitmap( "menu/glass.png", game->viewportHeight*1.6*0.3, game->viewportHeight*0.35 );
|
||||
PROGRESS;
|
||||
//game->menu.pinkcloud = LoadScaledBitmap( "menu/pinkcloud.png", game->viewportWidth*0.33125, game->viewportHeight*0.8122);
|
||||
game->menu.pinkcloud = LoadScaledBitmap( "menu/pinkcloud.png", game->viewportHeight*0.8122*(1171.0/2218.0), game->viewportHeight*0.8122);
|
||||
PROGRESS;
|
||||
data->glass = LoadScaledBitmap(game, "menu/glass.png", game->viewport.height*1.6*0.3, game->viewport.height*0.35 );
|
||||
//data->pinkcloud = LoadScaledBitmap(game, "menu/pinkcloud.png", game->viewport.width*0.33125, game->viewport.height*0.8122);
|
||||
data->pinkcloud = LoadScaledBitmap(game, "menu/pinkcloud.png", game->viewport.height*0.8122*(1171.0/2218.0), game->viewport.height*0.8122);
|
||||
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
|
||||
game->menu.rain = al_load_bitmap( GetDataFilePath("menu/rain.png") );
|
||||
PROGRESS;
|
||||
game->menu.pie = al_load_bitmap( GetDataFilePath("menu/pie.png") );
|
||||
data->rain = al_load_bitmap( GetDataFilePath("menu/rain.png") );
|
||||
data->pie = al_load_bitmap( GetDataFilePath("menu/pie.png") );
|
||||
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
|
||||
PROGRESS;
|
||||
|
||||
game->menu.sample = al_load_sample( GetDataFilePath("menu/menu.flac") );
|
||||
PROGRESS;
|
||||
game->menu.rain_sample = al_load_sample( GetDataFilePath("menu/rain.flac") );
|
||||
PROGRESS;
|
||||
game->menu.click_sample = al_load_sample( GetDataFilePath("menu/click.flac") );
|
||||
PROGRESS;
|
||||
game->menu.mountain_position = game->viewportWidth*0.7;
|
||||
data->sample = al_load_sample( GetDataFilePath("menu/menu.flac") );
|
||||
data->rain_sample = al_load_sample( GetDataFilePath("menu/rain.flac") );
|
||||
data->click_sample = al_load_sample( GetDataFilePath("menu/click.flac") );
|
||||
data->mountain_position = game->viewport.width*0.7;
|
||||
|
||||
game->menu.music = al_create_sample_instance(game->menu.sample);
|
||||
al_attach_sample_instance_to_mixer(game->menu.music, game->audio.music);
|
||||
al_set_sample_instance_playmode(game->menu.music, ALLEGRO_PLAYMODE_LOOP);
|
||||
data->music = al_create_sample_instance(data->sample);
|
||||
al_attach_sample_instance_to_mixer(data->music, game->audio.music);
|
||||
al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
game->menu.rain_sound = al_create_sample_instance(game->menu.rain_sample);
|
||||
al_attach_sample_instance_to_mixer(game->menu.rain_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(game->menu.rain_sound, ALLEGRO_PLAYMODE_LOOP);
|
||||
data->rain_sound = al_create_sample_instance(data->rain_sample);
|
||||
al_attach_sample_instance_to_mixer(data->rain_sound, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->rain_sound, ALLEGRO_PLAYMODE_LOOP);
|
||||
|
||||
game->menu.click = al_create_sample_instance(game->menu.click_sample);
|
||||
al_attach_sample_instance_to_mixer(game->menu.click, game->audio.fx);
|
||||
al_set_sample_instance_playmode(game->menu.click, ALLEGRO_PLAYMODE_ONCE);
|
||||
data->click = al_create_sample_instance(data->click_sample);
|
||||
al_attach_sample_instance_to_mixer(data->click, game->audio.fx);
|
||||
al_set_sample_instance_playmode(data->click, ALLEGRO_PLAYMODE_ONCE);
|
||||
|
||||
game->menu.font_title = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewportHeight*0.16,0 );
|
||||
game->menu.font_subtitle = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewportHeight*0.08,0 );
|
||||
game->menu.font = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewportHeight*0.05,0 );
|
||||
game->menu.font_selected = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewportHeight*0.065,0 );
|
||||
PROGRESS;
|
||||
data->font_title = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.16,0 );
|
||||
data->font_subtitle = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.08,0 );
|
||||
data->font = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.05,0 );
|
||||
data->font_selected = al_load_ttf_font(GetDataFilePath("fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.065,0 );
|
||||
|
||||
if (!game->menu.sample){
|
||||
if (!data->sample){
|
||||
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!game->menu.rain_sample){
|
||||
if (!data->rain_sample){
|
||||
fprintf(stderr, "Audio clip sample#2 not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (!game->menu.click_sample){
|
||||
if (!data->click_sample){
|
||||
fprintf(stderr, "Audio clip sample#3 not loaded!\n" );
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
game->menu.pinkcloud_bitmap = al_create_bitmap(game->viewportHeight*0.8122*(1171.0/2218.0), game->viewportHeight);
|
||||
data->pinkcloud_bitmap = al_create_bitmap(game->viewport.height*0.8122*(1171.0/2218.0), game->viewport.height);
|
||||
|
||||
game->menu.pie_bitmap = al_create_bitmap(game->viewportHeight*0.8, game->viewportHeight);
|
||||
al_set_target_bitmap(game->menu.pie_bitmap);
|
||||
data->pie_bitmap = al_create_bitmap(game->viewport.height*0.8, game->viewport.height);
|
||||
al_set_target_bitmap(data->pie_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.5, 0, game->viewportHeight*1.6*0.11875, game->viewportHeight*0.0825, 0);
|
||||
al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.1, al_get_bitmap_height(game->menu.pie_bitmap)*0.3, game->viewportHeight*1.6*0.09, game->viewportHeight*0.06, ALLEGRO_FLIP_HORIZONTAL);
|
||||
al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.3, al_get_bitmap_height(game->menu.pie_bitmap)*0.6, game->viewportHeight*1.6*0.13, game->viewportHeight*0.1, 0);
|
||||
al_destroy_bitmap(game->menu.pie);
|
||||
PROGRESS;
|
||||
al_draw_scaled_bitmap(data->pie, 0, 0, al_get_bitmap_width(data->pie), al_get_bitmap_height(data->pie), al_get_bitmap_width(data->pie_bitmap)*0.5, 0, game->viewport.height*1.6*0.11875, game->viewport.height*0.0825, 0);
|
||||
al_draw_scaled_bitmap(data->pie, 0, 0, al_get_bitmap_width(data->pie), al_get_bitmap_height(data->pie), al_get_bitmap_width(data->pie_bitmap)*0.1, al_get_bitmap_height(data->pie_bitmap)*0.3, game->viewport.height*1.6*0.09, game->viewport.height*0.06, ALLEGRO_FLIP_HORIZONTAL);
|
||||
al_draw_scaled_bitmap(data->pie, 0, 0, al_get_bitmap_width(data->pie), al_get_bitmap_height(data->pie), al_get_bitmap_width(data->pie_bitmap)*0.3, al_get_bitmap_height(data->pie_bitmap)*0.6, game->viewport.height*1.6*0.13, game->viewport.height*0.1, 0);
|
||||
al_destroy_bitmap(data->pie);
|
||||
|
||||
al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP);
|
||||
game->menu.rain_bitmap = al_create_bitmap(al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.5, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.1);
|
||||
data->rain_bitmap = al_create_bitmap(al_get_bitmap_width(data->pinkcloud_bitmap)*0.5, al_get_bitmap_height(data->pinkcloud_bitmap)*0.1);
|
||||
al_set_new_bitmap_flags(ALLEGRO_MIN_LINEAR | ALLEGRO_MAG_LINEAR);
|
||||
al_set_target_bitmap(game->menu.rain_bitmap);
|
||||
al_set_target_bitmap(data->rain_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
al_draw_scaled_bitmap(game->menu.rain,0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 0, 0, al_get_bitmap_width(game->menu.rain_bitmap), al_get_bitmap_height(game->menu.rain_bitmap),0);
|
||||
al_destroy_bitmap(game->menu.rain);
|
||||
PROGRESS;
|
||||
al_draw_scaled_bitmap(data->rain,0, 0, al_get_bitmap_width(data->rain), al_get_bitmap_height(data->rain), 0, 0, al_get_bitmap_width(data->rain_bitmap), al_get_bitmap_height(data->rain_bitmap),0);
|
||||
al_destroy_bitmap(data->rain);
|
||||
|
||||
al_set_target_backbuffer(game->display);
|
||||
return data;
|
||||
}
|
||||
|
||||
void Menu_Stop(struct Game* game) {
|
||||
FadeGameState(game, false);
|
||||
al_stop_sample_instance(game->menu.music);
|
||||
al_stop_sample_instance(game->menu.rain_sound);
|
||||
void Gamestate_Stop(struct Game *game, struct MenuResources* data) {
|
||||
FadeGamestate(game, false);
|
||||
al_stop_sample_instance(data->music);
|
||||
al_stop_sample_instance(data->rain_sound);
|
||||
}
|
||||
|
||||
void ChangeMenuState(struct Game *game, enum menustate_enum state) {
|
||||
game->menu.menustate=state;
|
||||
game->menu.selected=0;
|
||||
void ChangeMenuState(struct Game *game, struct MenuResources* data, enum menustate_enum state) {
|
||||
data->menustate=state;
|
||||
data->selected=0;
|
||||
PrintConsole(game, "menu state changed %d", state);
|
||||
}
|
||||
|
||||
void Menu_Unload(struct Game *game) {
|
||||
if (!game->menu.loaded) return;
|
||||
if (game->gamestate==GAMESTATE_MENU) Menu_Stop(game);
|
||||
al_destroy_bitmap(game->menu.pinkcloud);
|
||||
al_destroy_bitmap(game->menu.image);
|
||||
al_destroy_bitmap(game->menu.cloud);
|
||||
al_destroy_bitmap(game->menu.cloud2);
|
||||
al_destroy_bitmap(game->menu.pinkcloud_bitmap);
|
||||
al_destroy_bitmap(game->menu.rain_bitmap);
|
||||
al_destroy_bitmap(game->menu.mountain);
|
||||
al_destroy_bitmap(game->menu.pie_bitmap);
|
||||
al_destroy_bitmap(game->menu.logo);
|
||||
al_destroy_bitmap(game->menu.logoblur);
|
||||
al_destroy_bitmap(game->menu.glass);
|
||||
al_destroy_bitmap(game->menu.blurbg);
|
||||
al_destroy_bitmap(game->menu.blurbg2);
|
||||
al_destroy_font(game->menu.font_title);
|
||||
al_destroy_font(game->menu.font_subtitle);
|
||||
al_destroy_font(game->menu.font);
|
||||
al_destroy_font(game->menu.font_selected);
|
||||
al_destroy_sample_instance(game->menu.music);
|
||||
al_destroy_sample_instance(game->menu.rain_sound);
|
||||
al_destroy_sample_instance(game->menu.click);
|
||||
al_destroy_sample(game->menu.sample);
|
||||
al_destroy_sample(game->menu.rain_sample);
|
||||
al_destroy_sample(game->menu.click_sample);
|
||||
game->menu.loaded = false;
|
||||
void Gamestate_Unload(struct Game *game, struct MenuResources* data) {
|
||||
al_destroy_bitmap(data->pinkcloud);
|
||||
al_destroy_bitmap(data->image);
|
||||
al_destroy_bitmap(data->cloud);
|
||||
al_destroy_bitmap(data->cloud2);
|
||||
al_destroy_bitmap(data->pinkcloud_bitmap);
|
||||
al_destroy_bitmap(data->rain_bitmap);
|
||||
al_destroy_bitmap(data->mountain);
|
||||
al_destroy_bitmap(data->pie_bitmap);
|
||||
al_destroy_bitmap(data->logo);
|
||||
al_destroy_bitmap(data->logoblur);
|
||||
al_destroy_bitmap(data->glass);
|
||||
al_destroy_bitmap(data->blurbg);
|
||||
al_destroy_bitmap(data->blurbg2);
|
||||
al_destroy_font(data->font_title);
|
||||
al_destroy_font(data->font_subtitle);
|
||||
al_destroy_font(data->font);
|
||||
al_destroy_font(data->font_selected);
|
||||
al_destroy_sample_instance(data->music);
|
||||
al_destroy_sample_instance(data->rain_sound);
|
||||
al_destroy_sample_instance(data->click);
|
||||
al_destroy_sample(data->sample);
|
||||
al_destroy_sample(data->rain_sample);
|
||||
al_destroy_sample(data->click_sample);
|
||||
data->loaded = false;
|
||||
}
|
||||
|
||||
void Menu_Load(struct Game *game) {
|
||||
if (!game->menu.loaded) return;
|
||||
void Gamestate_Start(struct Game *game, struct MenuResources* data) {
|
||||
|
||||
game->menu.cloud_position = 100;
|
||||
game->menu.cloud2_position = 100;
|
||||
ChangeMenuState(game,MENUSTATE_MAIN);
|
||||
data->cloud_position = 100;
|
||||
data->cloud2_position = 100;
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
|
||||
al_play_sample_instance(game->menu.music);
|
||||
al_play_sample_instance(game->menu.rain_sound);
|
||||
FadeGameState(game, true);
|
||||
al_play_sample_instance(data->music);
|
||||
al_play_sample_instance(data->rain_sound);
|
||||
FadeGamestate(game, true);
|
||||
}
|
||||
|
||||
int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct MenuResources* data, ALLEGRO_EVENT *ev) {
|
||||
|
||||
if (ev->type != ALLEGRO_EVENT_KEY_DOWN) return;
|
||||
|
||||
if (ev->keyboard.keycode==ALLEGRO_KEY_UP) {
|
||||
game->menu.selected--;
|
||||
if ((game->menu.menustate==MENUSTATE_VIDEO) && (game->menu.selected==1) && (game->menu.options.fullscreen)) game->menu.selected--;
|
||||
al_play_sample_instance(game->menu.click);
|
||||
data->selected--;
|
||||
if ((data->menustate==MENUSTATE_VIDEO) && (data->selected==1) && (data->options.fullscreen)) data->selected--;
|
||||
al_play_sample_instance(data->click);
|
||||
} else if (ev->keyboard.keycode==ALLEGRO_KEY_DOWN) {
|
||||
game->menu.selected++;
|
||||
if ((game->menu.menustate==MENUSTATE_VIDEO) && (game->menu.selected==1) && (game->menu.options.fullscreen)) game->menu.selected++;
|
||||
al_play_sample_instance(game->menu.click);
|
||||
data->selected++;
|
||||
if ((data->menustate==MENUSTATE_VIDEO) && (data->selected==1) && (data->options.fullscreen)) data->selected++;
|
||||
al_play_sample_instance(data->click);
|
||||
}
|
||||
|
||||
if (ev->keyboard.keycode==ALLEGRO_KEY_ENTER) {
|
||||
char *text;
|
||||
al_play_sample_instance(game->menu.click);
|
||||
switch (game->menu.menustate) {
|
||||
al_play_sample_instance(data->click);
|
||||
switch (data->menustate) {
|
||||
case MENUSTATE_MAIN:
|
||||
switch (game->menu.selected) {
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_DISCLAIMER;
|
||||
LoadGamestate(game, "disclaimer");
|
||||
LoadGamestate(game, "intro");
|
||||
LoadGamestate(game, "map");
|
||||
StopGamestate(game, "menu");
|
||||
StartGamestate(game, "disclaimer");
|
||||
break;
|
||||
case 1:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case 2:
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_ABOUT;
|
||||
StopGamestate(game, "menu");
|
||||
LoadGamestate(game, "about");
|
||||
StartGamestate(game, "about");
|
||||
break;
|
||||
case 3:
|
||||
return 1;
|
||||
UnloadGamestate(game, "menu");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_AUDIO:
|
||||
text = malloc(255*sizeof(char));
|
||||
switch (game->menu.selected) {
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
game->music--;
|
||||
if (game->music<0) game->music=10;
|
||||
sprintf(text, "%d", game->music);
|
||||
SetConfigOption("SuperDerpy", "music", text);
|
||||
al_set_mixer_gain(game->audio.music, game->music/10.0);
|
||||
game->config.music--;
|
||||
if (game->config.music<0) game->config.music=10;
|
||||
sprintf(text, "%d", game->config.music);
|
||||
SetConfigOption(game, "SuperDerpy", "music", text);
|
||||
al_set_mixer_gain(game->audio.music, game->config.music/10.0);
|
||||
break;
|
||||
case 1:
|
||||
game->fx--;
|
||||
if (game->fx<0) game->fx=10;
|
||||
sprintf(text, "%d", game->fx);
|
||||
SetConfigOption("SuperDerpy", "fx", text);
|
||||
al_set_mixer_gain(game->audio.fx, game->fx/10.0);
|
||||
game->config.fx--;
|
||||
if (game->config.fx<0) game->config.fx=10;
|
||||
sprintf(text, "%d", game->config.fx);
|
||||
SetConfigOption(game, "SuperDerpy", "fx", text);
|
||||
al_set_mixer_gain(game->audio.fx, game->config.fx/10.0);
|
||||
break;
|
||||
case 2:
|
||||
game->voice--;
|
||||
if (game->voice<0) game->voice=10;
|
||||
sprintf(text, "%d", game->voice);
|
||||
SetConfigOption("SuperDerpy", "voice", text);
|
||||
al_set_mixer_gain(game->audio.voice, game->voice/10.0);
|
||||
game->config.voice--;
|
||||
if (game->config.voice<0) game->config.voice=10;
|
||||
sprintf(text, "%d", game->config.voice);
|
||||
SetConfigOption(game, "SuperDerpy", "voice", text);
|
||||
al_set_mixer_gain(game->audio.voice, game->config.voice/10.0);
|
||||
break;
|
||||
case 3:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
}
|
||||
free(text);
|
||||
break;
|
||||
case MENUSTATE_OPTIONS:
|
||||
switch (game->menu.selected) {
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
ChangeMenuState(game,MENUSTATE_CONTROLS);
|
||||
ChangeMenuState(game,data,MENUSTATE_CONTROLS);
|
||||
break;
|
||||
case 1:
|
||||
ChangeMenuState(game,MENUSTATE_VIDEO);
|
||||
ChangeMenuState(game,data,MENUSTATE_VIDEO);
|
||||
break;
|
||||
case 2:
|
||||
ChangeMenuState(game,MENUSTATE_AUDIO);
|
||||
ChangeMenuState(game,data,MENUSTATE_AUDIO);
|
||||
break;
|
||||
case 3:
|
||||
ChangeMenuState(game,MENUSTATE_MAIN);
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_PAUSE:
|
||||
switch (game->menu.selected){
|
||||
case MENUSTATE_PAUSE: //TODO: REMOVE ME
|
||||
switch (data->selected){
|
||||
case 0:
|
||||
PrintConsole(game,"Game resumed.");
|
||||
//al_destroy_bitmap(game->pause.bitmap);
|
||||
//game->pause.bitmap = NULL;
|
||||
ResumeGameState(game);
|
||||
game->gamestate = game->loadstate;
|
||||
|
||||
//ResumeGamestate(game);
|
||||
//game->gamestate = game->loadstate;
|
||||
break;
|
||||
case 1:
|
||||
game->gamestate=game->loadstate;
|
||||
// TODO:
|
||||
SwitchGamestate(game, "pause", "map");
|
||||
/*game->gamestate=game->loadstate;
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MAP;
|
||||
game->loadstate = GAMESTATE_MAP;*/
|
||||
break;
|
||||
case 2:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case 3:
|
||||
return 1;
|
||||
UnloadGamestate(game, "menu");
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_CONTROLS:
|
||||
switch (game->menu.selected) {
|
||||
switch (data->selected) {
|
||||
case 3:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MENUSTATE_VIDEO:
|
||||
switch (game->menu.selected) {
|
||||
switch (data->selected) {
|
||||
case 0:
|
||||
game->menu.options.fullscreen = !game->menu.options.fullscreen;
|
||||
if (game->menu.options.fullscreen)
|
||||
SetConfigOption("SuperDerpy", "fullscreen", "1");
|
||||
data->options.fullscreen = !data->options.fullscreen;
|
||||
if (data->options.fullscreen)
|
||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "1");
|
||||
else
|
||||
SetConfigOption("SuperDerpy", "fullscreen", "0");
|
||||
SetConfigOption(game, "SuperDerpy", "fullscreen", "0");
|
||||
break;
|
||||
case 3:
|
||||
if ((game->menu.options.fullscreen==game->fullscreen) && (game->menu.options.fps==game->fps) && (game->menu.options.width==game->width) && (game->menu.options.height==game->height)) {
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
if ((data->options.fullscreen==game->config.fullscreen) && (data->options.fps==game->config.fps) && (data->options.width==game->config.width) && (data->options.height==game->config.height)) {
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
} else {
|
||||
PrintConsole(game, "video settings changed, restarting...");
|
||||
game->restart = true;
|
||||
return 1;
|
||||
UnloadGamestate(game, "menu");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -480,37 +473,43 @@ int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
}
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
UnloadGamestate(game, "menu");
|
||||
return;
|
||||
break;
|
||||
}
|
||||
} else if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
||||
switch (game->menu.menustate) {
|
||||
switch (data->menustate) {
|
||||
case MENUSTATE_OPTIONS:
|
||||
ChangeMenuState(game,MENUSTATE_MAIN);
|
||||
ChangeMenuState(game,data,MENUSTATE_MAIN);
|
||||
break;
|
||||
case MENUSTATE_VIDEO:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case MENUSTATE_AUDIO:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case MENUSTATE_CONTROLS:
|
||||
ChangeMenuState(game,MENUSTATE_OPTIONS);
|
||||
ChangeMenuState(game,data,MENUSTATE_OPTIONS);
|
||||
break;
|
||||
case MENUSTATE_PAUSE:
|
||||
PrintConsole(game,"Game resumed.");
|
||||
//al_destroy_bitmap(game->pause.bitmap);
|
||||
//game->pause.bitmap = NULL;
|
||||
ResumeGameState(game);
|
||||
game->gamestate = game->loadstate;
|
||||
//ResumeGameState(game);
|
||||
//game->gamestate = game->loadstate;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
break;
|
||||
UnloadGamestate(game, "menu");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (game->menu.selected==-1) game->menu.selected=3;
|
||||
if (game->menu.selected==4) game->menu.selected=0;
|
||||
return 0;
|
||||
if (data->selected==-1) data->selected=3;
|
||||
if (data->selected==4) data->selected=0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct IntroResources* data) {}
|
||||
void Gamestate_Resume(struct Game *game, struct IntroResources* data) {}
|
||||
void Gamestate_Reload(struct Game *game, struct IntroResources* data) {}
|
||||
|
|
|
@ -18,7 +18,10 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include "../main.h"
|
||||
|
||||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include <allegro5/allegro_audio.h>
|
||||
|
||||
/*! \brief Enum of menu states in Menu and Pause game states. */
|
||||
enum menustate_enum {
|
||||
|
@ -31,7 +34,7 @@ enum menustate_enum {
|
|||
};
|
||||
|
||||
/*! \brief Resources used by Menu state. */
|
||||
struct Menu {
|
||||
struct MenuResources {
|
||||
ALLEGRO_BITMAP *image; /*!< Bitmap with lower portion of menu landscape. */
|
||||
ALLEGRO_BITMAP *cloud; /*!< Bitmap with bigger cloud. */
|
||||
ALLEGRO_BITMAP *cloud2; /*!< Bitmap with small cloud. */
|
||||
|
@ -71,12 +74,5 @@ struct Menu {
|
|||
} options; /*!< Options which can be changed in menu. */
|
||||
};
|
||||
|
||||
void DrawMenuState(struct Game *game);
|
||||
void Menu_Draw(struct Game *game);
|
||||
void Menu_Logic(struct Game *game);
|
||||
void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float));
|
||||
void Menu_Stop(struct Game *game);
|
||||
void Menu_Unload(struct Game *game);
|
||||
void Menu_Load(struct Game *game);
|
||||
int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void ChangeMenuState(struct Game *game, enum menustate_enum state);
|
||||
//void DrawMenuState(struct Game *game);
|
||||
//void ChangeMenuState(struct Game *game, enum menustate_enum state);
|
||||
|
|
63
src/main.c
63
src/main.c
|
@ -283,7 +283,7 @@ int main(int argc, char **argv){
|
|||
game.shuttingdown = false;
|
||||
game.restart = false;
|
||||
|
||||
char* gamestate = strdup("disclaimer"); // FIXME: don't hardcore gamestate
|
||||
char* gamestate = strdup("menu"); // FIXME: don't hardcore gamestate
|
||||
|
||||
int c;
|
||||
while ((c = getopt (argc, argv, "l:s:")) != -1)
|
||||
|
@ -310,26 +310,41 @@ int main(int argc, char **argv){
|
|||
if (redraw && al_is_event_queue_empty(game._priv.event_queue)) {
|
||||
|
||||
struct Gamestate *tmp = game._priv.gamestates;
|
||||
bool gameActive = false;
|
||||
|
||||
// FIXME: move to function
|
||||
// TODO: support dependences
|
||||
while (tmp) {
|
||||
if ((tmp->pending_start) && (tmp->started)) {
|
||||
PrintConsole(&game, "Stopping gamestate \"%s\"...", tmp->name);
|
||||
al_clear_to_color(al_map_rgb(255,255,0));
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
(*tmp->api.Gamestate_Stop)(&game, tmp->data);
|
||||
tmp->started = false;
|
||||
tmp->pending_start = false;
|
||||
} else if ((tmp->pending_load) && (tmp->loaded)) {
|
||||
}
|
||||
|
||||
tmp=tmp->next;
|
||||
}
|
||||
|
||||
tmp = game._priv.gamestates;
|
||||
// FIXME: move to function
|
||||
// TODO: support dependences
|
||||
while (tmp) {
|
||||
if ((tmp->pending_load) && (tmp->loaded)) {
|
||||
PrintConsole(&game, "Unloading gamestate \"%s\"...", tmp->name);
|
||||
al_clear_to_color(al_map_rgb(255,0,0));
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
tmp->loaded = false;
|
||||
tmp->pending_load = false;
|
||||
(*tmp->api.Gamestate_Unload)(&game, tmp->data);
|
||||
dlclose(tmp->handle);
|
||||
tmp->handle = NULL;
|
||||
}
|
||||
if ((tmp->pending_load) && (!tmp->loaded)) {
|
||||
} else if ((tmp->pending_load) && (!tmp->loaded)) {
|
||||
PrintConsole(&game, "Loading gamestate \"%s\"...", tmp->name);
|
||||
al_clear_to_color(al_map_rgb(0,0,255));
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
// TODO: take proper game name
|
||||
char libname[1024];
|
||||
sprintf(libname, "libsuperderpy-%s-%s.so", "muffinattack", tmp->name);
|
||||
|
@ -365,20 +380,27 @@ int main(int argc, char **argv){
|
|||
tmp->loaded = true;
|
||||
tmp->pending_load = false;
|
||||
}
|
||||
} else if ((tmp->pending_start) && (!tmp->started)) {
|
||||
if (!tmp->loaded) {
|
||||
PrintConsole(&game, "Tried to start not loaded gamestate \"%s\"!", tmp->name);
|
||||
tmp->pending_start = false;
|
||||
} else {
|
||||
PrintConsole(&game, "Starting gamestate \"%s\"...", tmp->name);
|
||||
(*tmp->api.Gamestate_Start)(&game, tmp->data);
|
||||
tmp->started = true;
|
||||
tmp->pending_start = false;
|
||||
}
|
||||
}
|
||||
|
||||
tmp=tmp->next;
|
||||
}
|
||||
|
||||
bool gameActive = false;
|
||||
tmp=game._priv.gamestates;
|
||||
|
||||
while (tmp) {
|
||||
|
||||
if ((tmp->pending_start) && (!tmp->started) && (tmp->loaded)) {
|
||||
PrintConsole(&game, "Starting gamestate \"%s\"...", tmp->name);
|
||||
al_clear_to_color(al_map_rgb(0,255,255));
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
(*tmp->api.Gamestate_Start)(&game, tmp->data);
|
||||
tmp->started = true;
|
||||
tmp->pending_start = false;
|
||||
}
|
||||
|
||||
if ((tmp->started) || (tmp->pending_start) || (tmp->pending_load)) gameActive = true;
|
||||
|
||||
tmp=tmp->next;
|
||||
}
|
||||
|
||||
|
@ -387,7 +409,6 @@ int main(int argc, char **argv){
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
DrawGamestates(&game);
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
|
@ -452,11 +473,17 @@ int main(int argc, char **argv){
|
|||
while (tmp) {
|
||||
if (tmp->started) {
|
||||
PrintConsole(&game, "Stopping gamestate \"%s\"...", tmp->name);
|
||||
al_clear_to_color(al_map_rgb(255,255,0));
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
(*tmp->api.Gamestate_Stop)(&game, tmp->data);
|
||||
tmp->started = false;
|
||||
}
|
||||
if (tmp->loaded) {
|
||||
PrintConsole(&game, "Unloading gamestate \"%s\"...", tmp->name);
|
||||
al_clear_to_color(al_map_rgb(255,0,0));
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
(*tmp->api.Gamestate_Unload)(&game, tmp->data);
|
||||
dlclose(tmp->handle);
|
||||
tmp->loaded = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue