add disclaimer screen about early development preview

This commit is contained in:
Sebastian Krzyszkowiak 2012-07-08 15:52:56 +02:00
parent 7842385b27
commit da13fcb41c
7 changed files with 109 additions and 3 deletions

View file

@ -6,7 +6,7 @@ SRCDIR=src
ODIR=obj
LIBS=-lallegro -lallegro_audio -lallegro_acodec -lallegro_image -lallegro_font -lallegro_main -lallegro_ttf -lallegro_primitives -lm
_OBJ = config.o main.o about.o intro.o loading.o map.o menu.o level.o moonwalk.o pause.o timeline.o allegro_utils.o levels/callbacks.o levels/actions.o
_OBJ = config.o main.o about.o intro.o disclaimer.o loading.o map.o menu.o level.o moonwalk.o pause.o timeline.o allegro_utils.o levels/callbacks.o levels/actions.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
OUTPUTDIR = bin

View file

@ -27,3 +27,5 @@ src/levels/actions.h
src/levels/callbacks.c
src/levels/actions.c
Makefile
src/disclaimer.h
src/disclaimer.c

70
src/disclaimer.c Normal file
View file

@ -0,0 +1,70 @@
/*! \file disclaimer.c
* \brief Disclaimer about early release preview.
*/
/*
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <stdio.h>
#include "intro.h"
#include "about.h"
void Disclaimer_Draw(struct Game *game) {
al_clear_to_color(al_map_rgb(0,0,0));
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.3, ALLEGRO_ALIGN_CENTRE, "This is an early development preview of the game.");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.4, ALLEGRO_ALIGN_CENTRE, "It's not supposed to be complete!");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.5, ALLEGRO_ALIGN_CENTRE, "Keep in mind that everything may be changed");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.6, ALLEGRO_ALIGN_CENTRE, "and many things surely will change.");
al_draw_text_with_shadow(game->menu.font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.9, ALLEGRO_ALIGN_CENTRE, "Press any key to continue...");
}
void Disclaimer_Load(struct Game *game) {
ALLEGRO_EVENT ev;
float fadeloop;
for (fadeloop=255; fadeloop>0; fadeloop-=tps(game, 600)) {
al_wait_for_event(game->event_queue, &ev);
Disclaimer_Draw(game);
al_draw_filled_rectangle(0,0,al_get_display_width(game->display),al_get_display_height(game->display),al_map_rgba(0,0,0,fadeloop));
DrawConsole(game);
al_flip_display();
}
Disclaimer_Draw(game);
}
int Disclaimer_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
UnloadGameState(game);
game->loadstate = GAMESTATE_INTRO;
LoadGameState(game);
return 0;
}
void Disclaimer_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
PrintConsole(game, "Preloading GAMESTATE_INTRO...");
Intro_Preload(game, progress);
}
void Disclaimer_Unload(struct Game *game) {
ALLEGRO_EVENT ev;
float fadeloop;
for (fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)) {
al_wait_for_event(game->event_queue, &ev);
Disclaimer_Draw(game);
al_draw_filled_rectangle(0,0,al_get_display_width(game->display),al_get_display_height(game->display),al_map_rgba(0,0,0,fadeloop));
DrawConsole(game);
al_flip_display();
}
al_clear_to_color(al_map_rgb(0,0,0));
}

27
src/disclaimer.h Normal file
View file

@ -0,0 +1,27 @@
/*! \file disclaimer.h
* \brief Disclaimer about early release preview - headers.
*/
/*
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* 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"
void Disclaimer_Draw(struct Game *game);
void Disclaimer_Preload(struct Game *game, void (*progress)(struct Game*, float));
void Disclaimer_Unload(struct Game *game);
void Disclaimer_Load(struct Game *game);
int Disclaimer_Keydown(struct Game *game, ALLEGRO_EVENT *ev);

View file

@ -30,6 +30,7 @@
#include "map.h"
#include "level.h"
#include "pause.h"
#include "disclaimer.h"
#include "config.h"
/*! \brief Macro for preloading gamestate.
@ -106,6 +107,7 @@ void PreloadGameState(struct Game *game, void (*progress)(struct Game*, float))
PRELOAD_STATE(GAMESTATE_INTRO, Intro)
PRELOAD_STATE(GAMESTATE_MAP, Map)
PRELOAD_STATE(GAMESTATE_LEVEL, Level)
PRELOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to preload unknown gamestate %d!", game->loadstate);
break;
@ -128,6 +130,7 @@ void UnloadGameState(struct Game *game) {
UNLOAD_STATE(GAMESTATE_INTRO, Intro)
UNLOAD_STATE(GAMESTATE_MAP, Map)
UNLOAD_STATE(GAMESTATE_LEVEL, Level)
UNLOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate %d!", game->gamestate);
break;
@ -143,6 +146,7 @@ void LoadGameState(struct Game *game) {
LOAD_STATE(GAMESTATE_INTRO, Intro)
LOAD_STATE(GAMESTATE_MAP, Map)
LOAD_STATE(GAMESTATE_LEVEL, Level)
LOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to load unknown gamestate %d!", game->loadstate);
}
@ -160,6 +164,7 @@ void DrawGameState(struct Game *game) {
DRAW_STATE(GAMESTATE_INTRO, Intro)
DRAW_STATE(GAMESTATE_MAP, Map)
DRAW_STATE(GAMESTATE_LEVEL, Level)
DRAW_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
game->showconsole = true;
PrintConsole(game, "ERROR: Unknown gamestate %d reached! (5 sec sleep)", game->gamestate);
@ -482,6 +487,7 @@ int main(int argc, char **argv){
KEYDOWN_STATE(GAMESTATE_INTRO, Intro)
KEYDOWN_STATE(GAMESTATE_MAP, Map)
KEYDOWN_STATE(GAMESTATE_LEVEL, Level)
KEYDOWN_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
else {
game.showconsole = true;
PrintConsole(&game, "ERROR: Keystroke in unknown (%d) gamestate! (5 sec sleep)", game.gamestate);

View file

@ -48,7 +48,8 @@ enum gamestate_enum {
GAMESTATE_ABOUT,
GAMESTATE_INTRO,
GAMESTATE_MAP,
GAMESTATE_LEVEL
GAMESTATE_LEVEL,
GAMESTATE_DISCLAIMER
};
/*! \brief Resources used by moonwalk level placeholder. */

View file

@ -376,7 +376,7 @@ int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
case 0:
UnloadGameState(game);
game->gamestate = GAMESTATE_LOADING;
game->loadstate = GAMESTATE_INTRO;
game->loadstate = GAMESTATE_DISCLAIMER;
break;
case 1:
ChangeMenuState(game,MENUSTATE_OPTIONS);