mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-08 06:06:43 +01:00
add intro state
This commit is contained in:
parent
04f145c2d5
commit
58dd22abfb
5 changed files with 67 additions and 15 deletions
19
intro.c
Normal file
19
intro.c
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include <allegro5/allegro.h>
|
||||
#include <allegro5/allegro_font.h>
|
||||
#include "intro.h"
|
||||
|
||||
void Intro_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 Intro_Load(struct Game *game) {}
|
||||
int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; }
|
||||
void Intro_Preload(struct Game *game) {}
|
||||
void Intro_Unload(struct Game *game) {}
|
7
intro.h
Normal file
7
intro.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#include "main.h"
|
||||
|
||||
void Intro_Draw(struct Game *game);
|
||||
void Intro_Preload(struct Game *game);
|
||||
void Intro_Unload(struct Game *game);
|
||||
void Intro_Load(struct Game *game);
|
||||
int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
44
main.c
44
main.c
|
@ -2,6 +2,7 @@
|
|||
#include "menu.h"
|
||||
#include "loading.h"
|
||||
#include "about.h"
|
||||
#include "intro.h"
|
||||
|
||||
float FPS = 60;
|
||||
int DISPLAY_WIDTH = 800;
|
||||
|
@ -31,54 +32,66 @@ 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");
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_INTRO) {
|
||||
PrintConsole(game, "Preload GAMESTATE_INTRO...");
|
||||
Intro_Preload(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to preload unknown gamestate!");
|
||||
}
|
||||
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");
|
||||
}
|
||||
else if (game->gamestate==GAMESTATE_INTRO) {
|
||||
PrintConsole(game, "Unload GAMESTATE_INTRO...");
|
||||
Intro_Unload(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate!");
|
||||
}
|
||||
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");
|
||||
}
|
||||
else if (game->loadstate==GAMESTATE_INTRO) {
|
||||
PrintConsole(game, "Load GAMESTATE_INTRO...");
|
||||
Intro_Load(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to load unknown gamestate!");
|
||||
}
|
||||
PrintConsole(game, "finished");
|
||||
game->gamestate = game->loadstate;
|
||||
game->loadstate = -1;
|
||||
}
|
||||
|
@ -210,6 +223,19 @@ int main(int argc, char **argv){
|
|||
}
|
||||
else if (game.gamestate==GAMESTATE_ABOUT) {
|
||||
About_Draw(&game);
|
||||
}
|
||||
else if (game.gamestate==GAMESTATE_INTRO) {
|
||||
Intro_Draw(&game);
|
||||
}
|
||||
else {
|
||||
game.showconsole = true;
|
||||
PrintConsole(&game, "ERROR: Unknown gamestate reached! (5 sec sleep)");
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
al_rest(5.0);
|
||||
PrintConsole(&game, "Returning to menu...");
|
||||
game.gamestate = GAMESTATE_LOADING;
|
||||
game.loadstate = GAMESTATE_MENU;
|
||||
}
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
|
|
2
make
2
make
|
@ -1,2 +1,2 @@
|
|||
#!/bin/sh
|
||||
gcc main.c about.c menu.c loading.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 -o superderpy -lallegro -lallegro_audio -lallegro_acodec -lallegro_image -lallegro_font -lallegro_ttf -std=gnu99 -g && ./superderpy
|
||||
|
|
10
menu.c
10
menu.c
|
@ -10,12 +10,12 @@ void Menu_Draw(struct Game *game) {
|
|||
//game->menu.pinkcloud_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.33125, al_get_display_height(game->display)); //*0.8122);
|
||||
al_set_target_bitmap(game->menu.pinkcloud_bitmap);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
float x = 2*(rand() / (float)RAND_MAX);
|
||||
float x = 1.5;//*(rand() / (float)RAND_MAX);
|
||||
int minus;
|
||||
if (game->menu.cloud_position>0) minus=1; else minus=-1;
|
||||
al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 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(-2*(game->menu.cloud_position+80), 3))/10.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.5, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.1, 0);
|
||||
al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 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(-3*(game->menu.cloud_position+80), 2))/10.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.5, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.1, 0);
|
||||
al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 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(-5*(game->menu.cloud_position+80), 4))/12.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.08, 0);
|
||||
al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 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(-2*(game->menu.cloud_position+80), 6))/20.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.5, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.1, 0);
|
||||
al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 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(-3*(game->menu.cloud_position+80), 4))/20.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.5, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.1, 0);
|
||||
al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 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(-5*(game->menu.cloud_position+80), 8))/24.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.08, 0);
|
||||
al_draw_scaled_bitmap(game->menu.pinkcloud,0, 0, al_get_bitmap_width(game->menu.pinkcloud), al_get_bitmap_height(game->menu.pinkcloud), 0, 0, al_get_bitmap_width(game->menu.pinkcloud_bitmap), al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.8122,0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
|
@ -193,7 +193,7 @@ int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
} else if ((ev->keyboard.keycode==ALLEGRO_KEY_ENTER) && (!game->menu.options) && (game->menu.selected==0)) {
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
game->loadstate = GAMESTATE_MENU;
|
||||
game->loadstate = GAMESTATE_INTRO;
|
||||
} else if ((ev->keyboard.keycode==ALLEGRO_KEY_ENTER) && (!game->menu.options) && (game->menu.selected==2)) {
|
||||
UnloadGameState(game);
|
||||
game->gamestate = GAMESTATE_LOADING;
|
||||
|
|
Loading…
Reference in a new issue