mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
introduce timeline manager, split moonwalk code from level code
This commit is contained in:
parent
c4ca72d875
commit
90c20b0c1c
7 changed files with 301 additions and 126 deletions
2
Makefile
2
Makefile
|
@ -6,7 +6,7 @@ SRCDIR=src
|
||||||
ODIR=obj
|
ODIR=obj
|
||||||
LIBS=-lallegro -lallegro_audio -lallegro_acodec -lallegro_image -lallegro_font -lallegro_ttf -lm
|
LIBS=-lallegro -lallegro_audio -lallegro_acodec -lallegro_image -lallegro_font -lallegro_ttf -lm
|
||||||
|
|
||||||
_OBJ = config.o main.o about.o intro.o loading.o map.o menu.o level.o pause.o
|
_OBJ = config.o main.o about.o intro.o loading.o map.o menu.o level.o moonwalk.o pause.o timeline.o
|
||||||
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
|
||||||
|
|
||||||
OUTPUTDIR = bin
|
OUTPUTDIR = bin
|
||||||
|
|
137
src/level.c
137
src/level.c
|
@ -19,142 +19,33 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include "moonwalk.h"
|
||||||
#include "pause.h"
|
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
#include "config.h"
|
|
||||||
|
|
||||||
void Level_Draw(struct Game *game) {
|
void Level_Draw(struct Game *game) {
|
||||||
if (!al_get_sample_instance_playing(game->level.music) && (game->loadstate==GAMESTATE_LEVEL)) {
|
Moonwalk_Draw(game);
|
||||||
al_set_sample_instance_playing(game->level.music, true);
|
|
||||||
al_set_sample_instance_position(game->level.music, game->level.music_pos);
|
|
||||||
}
|
|
||||||
al_set_target_bitmap(game->level.derpy);
|
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
|
||||||
al_draw_bitmap_region(game->level.derpy_walkcycle,al_get_bitmap_width(game->level.derpy)*(game->level.derpy_frame%6),al_get_bitmap_height(game->level.derpy)*(game->level.derpy_frame/6),al_get_bitmap_width(game->level.derpy), al_get_bitmap_height(game->level.derpy),0,0,0);
|
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
|
||||||
|
|
||||||
game->level.derpy_pos=game->level.derpy_pos+tps(game, 60*0.00092);
|
|
||||||
if (game->level.derpy_pos>1) { UnloadGameState(game);
|
|
||||||
if (game->level.current_level<6) {
|
|
||||||
|
|
||||||
int available = atoi(GetConfigOptionDefault("MuffinAttack", "level", "1"));
|
|
||||||
available++;
|
|
||||||
if ((available<2) || (available>7)) available=1;
|
|
||||||
if (available==(game->level.current_level+1)) {
|
|
||||||
char* text = malloc(2*sizeof(char));
|
|
||||||
sprintf(text, "%d", available);
|
|
||||||
SetConfigOption("MuffinAttack", "level", text);
|
|
||||||
free(text);
|
|
||||||
}
|
|
||||||
game->gamestate = GAMESTATE_LOADING;
|
|
||||||
game->loadstate = GAMESTATE_MAP;
|
|
||||||
//LoadGameState(game);
|
|
||||||
} else {
|
|
||||||
game->gamestate = GAMESTATE_LOADING;
|
|
||||||
game->loadstate = GAMESTATE_ABOUT;
|
|
||||||
//LoadGameState(game);
|
|
||||||
}
|
|
||||||
return; }
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < tps(game, 60); i++ ) {
|
|
||||||
game->level.derpy_frame_tmp++;
|
|
||||||
if (game->level.derpy_frame_tmp%3==0) {
|
|
||||||
if (game->level.derpy_frame_tmp%5==0) game->level.derpy_frame++;
|
|
||||||
if (game->level.derpy_frame_tmp%22==21) game->level.derpy_frame--;
|
|
||||||
game->level.derpy_frame++;
|
|
||||||
if (game->level.derpy_frame>=24) game->level.derpy_frame=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
al_draw_scaled_bitmap(game->level.image,0,0,al_get_bitmap_width(game->level.image),al_get_bitmap_height(game->level.image),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0);
|
|
||||||
al_draw_bitmap(game->level.derpy, game->level.derpy_pos*al_get_display_width(game->display), al_get_display_height(game->display)-al_get_bitmap_height(game->level.derpy), ALLEGRO_FLIP_HORIZONTAL);
|
|
||||||
al_draw_textf(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", game->level.current_level);
|
|
||||||
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level_Load(struct Game *game) {
|
void Level_Load(struct Game *game) {
|
||||||
game->level.derpy_frame = 0;
|
Moonwalk_Load(game);
|
||||||
game->level.derpy_frame_tmp = 0;
|
|
||||||
game->level.derpy_pos = -0.2;
|
|
||||||
al_play_sample_instance(game->level.music);
|
|
||||||
ALLEGRO_EVENT ev;
|
|
||||||
int fadeloop;
|
|
||||||
for(fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)){
|
|
||||||
al_wait_for_event(game->event_queue, &ev);
|
|
||||||
al_draw_tinted_bitmap(game->level.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->level.fade_bitmap);
|
|
||||||
Level_Draw(game);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Level_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
int Level_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||||
if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
return Moonwalk_Keydown(game, ev);
|
||||||
game->level.music_pos = al_get_sample_instance_position(game->level.music);
|
|
||||||
al_set_sample_instance_playing(game->level.music, false);
|
|
||||||
game->gamestate = GAMESTATE_PAUSE;
|
|
||||||
game->loadstate = GAMESTATE_LEVEL;
|
|
||||||
Pause_Load(game);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Level_PreloadBitmaps(struct Game *game) {
|
|
||||||
game->level.image =LoadScaledBitmap("table.png", al_get_display_width(game->display), al_get_display_height(game->display));
|
|
||||||
game->level.derpy_walkcycle = LoadScaledBitmap("derpcycle.png", al_get_display_width(game->display)*0.1953125*6, al_get_display_height(game->display)*0.25*4);
|
|
||||||
|
|
||||||
game->level.derpy = al_create_bitmap(al_get_display_width(game->display)*0.1953125, al_get_display_height(game->display)*0.25);
|
|
||||||
|
|
||||||
game->level.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
|
||||||
al_set_target_bitmap(game->level.fade_bitmap);
|
|
||||||
al_draw_bitmap(game->level.image,0,0,0);
|
|
||||||
al_draw_textf(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", game->level.current_level);
|
|
||||||
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level_Preload(struct Game *game) {
|
void Level_Preload(struct Game *game) {
|
||||||
PrintConsole(game, "Initializing level %d...", game->level.current_level);
|
Moonwalk_Preload(game);
|
||||||
game->level.sample = al_load_sample( "data/moonwalk.flac" );
|
|
||||||
game->level.music = al_create_sample_instance(game->level.sample);
|
|
||||||
al_attach_sample_instance_to_mixer(game->level.music, game->audio.music);
|
|
||||||
al_set_sample_instance_playmode(game->level.music, ALLEGRO_PLAYMODE_LOOP);
|
|
||||||
|
|
||||||
if (!game->level.sample){
|
|
||||||
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Level_PreloadBitmaps(game);
|
|
||||||
Pause_Preload(game);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Level_UnloadBitmaps(struct Game *game) {
|
|
||||||
al_destroy_bitmap(game->level.image);
|
|
||||||
al_destroy_bitmap(game->level.derpy);
|
|
||||||
al_destroy_bitmap(game->level.derpy_walkcycle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level_Unload(struct Game *game) {
|
void Level_Unload(struct Game *game) {
|
||||||
Pause_Unload_Real(game);
|
Moonwalk_Unload(game);
|
||||||
ALLEGRO_EVENT ev;
|
}
|
||||||
game->level.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
|
||||||
al_set_target_bitmap(game->level.fade_bitmap);
|
void Level_UnloadBitmaps(struct Game *game) {
|
||||||
al_draw_bitmap(game->level.image,0,0,0);
|
Moonwalk_UnloadBitmaps(game);
|
||||||
al_draw_bitmap(game->level.derpy, game->level.derpy_pos*al_get_display_width(game->display), al_get_display_height(game->display)-al_get_bitmap_height(game->level.derpy), ALLEGRO_FLIP_HORIZONTAL);
|
}
|
||||||
al_draw_textf(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", game->level.current_level);
|
|
||||||
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
void Level_PreloadBitmaps(struct Game *game) {
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
Moonwalk_PreloadBitmaps(game);
|
||||||
int fadeloop;
|
|
||||||
for(fadeloop=255; fadeloop>=0; fadeloop-=tps(game, 600)){
|
|
||||||
al_wait_for_event(game->event_queue, &ev);
|
|
||||||
al_draw_tinted_bitmap(game->level.fade_bitmap, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0);
|
|
||||||
DrawConsole(game);
|
|
||||||
al_flip_display();
|
|
||||||
}
|
|
||||||
Level_UnloadBitmaps(game);
|
|
||||||
al_destroy_bitmap(game->level.fade_bitmap);
|
|
||||||
al_destroy_sample_instance(game->level.music);
|
|
||||||
al_destroy_sample(game->level.sample);
|
|
||||||
}
|
}
|
||||||
|
|
10
src/main.h
10
src/main.h
|
@ -41,8 +41,8 @@ enum gamestate_enum {
|
||||||
GAMESTATE_LEVEL
|
GAMESTATE_LEVEL
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! \brief Resources used by Level state. */
|
/*! \brief Resources used by moonwalk level placeholder. */
|
||||||
struct Level {
|
struct Moonwalk {
|
||||||
ALLEGRO_BITMAP *fade_bitmap; /*!< Bitmap used on fade-in and fade-out animations. */
|
ALLEGRO_BITMAP *fade_bitmap; /*!< Bitmap used on fade-in and fade-out animations. */
|
||||||
ALLEGRO_BITMAP *image; /*!< Background texture. */
|
ALLEGRO_BITMAP *image; /*!< Background texture. */
|
||||||
ALLEGRO_BITMAP *derpy_walkcycle; /*!< Derpy walk cycle spritesheet. */
|
ALLEGRO_BITMAP *derpy_walkcycle; /*!< Derpy walk cycle spritesheet. */
|
||||||
|
@ -56,6 +56,12 @@ struct Level {
|
||||||
double derpy_pos; /*!< Position of Derpy on screen. */
|
double derpy_pos; /*!< Position of Derpy on screen. */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*! \brief Resources used by Level state. */
|
||||||
|
struct Level {
|
||||||
|
int current_level;
|
||||||
|
struct Moonwalk moonwalk;
|
||||||
|
};
|
||||||
|
|
||||||
/*! \brief Enum of menu states in Menu and Pause game states. */
|
/*! \brief Enum of menu states in Menu and Pause game states. */
|
||||||
enum menustate_enum {
|
enum menustate_enum {
|
||||||
MENUSTATE_MAIN,
|
MENUSTATE_MAIN,
|
||||||
|
|
160
src/moonwalk.c
Normal file
160
src/moonwalk.c
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
/*! \file level.c
|
||||||
|
* \brief Playable Level code.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* 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 <math.h>
|
||||||
|
#include "pause.h"
|
||||||
|
#include "moonwalk.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
void Moonwalk_Draw(struct Game *game) {
|
||||||
|
if (!al_get_sample_instance_playing(game->level.moonwalk.music) && (game->loadstate==GAMESTATE_LEVEL)) {
|
||||||
|
al_set_sample_instance_playing(game->level.moonwalk.music, true);
|
||||||
|
al_set_sample_instance_position(game->level.moonwalk.music, game->level.moonwalk.music_pos);
|
||||||
|
}
|
||||||
|
al_set_target_bitmap(game->level.moonwalk.derpy);
|
||||||
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
|
al_draw_bitmap_region(game->level.moonwalk.derpy_walkcycle,al_get_bitmap_width(game->level.moonwalk.derpy)*(game->level.moonwalk.derpy_frame%6),al_get_bitmap_height(game->level.moonwalk.derpy)*(game->level.moonwalk.derpy_frame/6),al_get_bitmap_width(game->level.moonwalk.derpy), al_get_bitmap_height(game->level.moonwalk.derpy),0,0,0);
|
||||||
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
|
||||||
|
game->level.moonwalk.derpy_pos=game->level.moonwalk.derpy_pos+tps(game, 60*0.00092);
|
||||||
|
if (game->level.moonwalk.derpy_pos>1) { UnloadGameState(game);
|
||||||
|
if (game->level.current_level<6) {
|
||||||
|
|
||||||
|
int available = atoi(GetConfigOptionDefault("MuffinAttack", "level", "1"));
|
||||||
|
available++;
|
||||||
|
if ((available<2) || (available>7)) available=1;
|
||||||
|
if (available==(game->level.current_level+1)) {
|
||||||
|
char* text = malloc(2*sizeof(char));
|
||||||
|
sprintf(text, "%d", available);
|
||||||
|
SetConfigOption("MuffinAttack", "level", text);
|
||||||
|
free(text);
|
||||||
|
}
|
||||||
|
game->gamestate = GAMESTATE_LOADING;
|
||||||
|
game->loadstate = GAMESTATE_MAP;
|
||||||
|
//LoadGameState(game);
|
||||||
|
} else {
|
||||||
|
game->gamestate = GAMESTATE_LOADING;
|
||||||
|
game->loadstate = GAMESTATE_ABOUT;
|
||||||
|
//LoadGameState(game);
|
||||||
|
}
|
||||||
|
return; }
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < tps(game, 60); i++ ) {
|
||||||
|
game->level.moonwalk.derpy_frame_tmp++;
|
||||||
|
if (game->level.moonwalk.derpy_frame_tmp%3==0) {
|
||||||
|
if (game->level.moonwalk.derpy_frame_tmp%5==0) game->level.moonwalk.derpy_frame++;
|
||||||
|
if (game->level.moonwalk.derpy_frame_tmp%22==21) game->level.moonwalk.derpy_frame--;
|
||||||
|
game->level.moonwalk.derpy_frame++;
|
||||||
|
if (game->level.moonwalk.derpy_frame>=24) game->level.moonwalk.derpy_frame=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
al_draw_scaled_bitmap(game->level.moonwalk.image,0,0,al_get_bitmap_width(game->level.moonwalk.image),al_get_bitmap_height(game->level.moonwalk.image),0,0,al_get_display_width(game->display), al_get_display_height(game->display),0);
|
||||||
|
al_draw_bitmap(game->level.moonwalk.derpy, game->level.moonwalk.derpy_pos*al_get_display_width(game->display), al_get_display_height(game->display)-al_get_bitmap_height(game->level.moonwalk.derpy), ALLEGRO_FLIP_HORIZONTAL);
|
||||||
|
al_draw_textf(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", game->level.current_level);
|
||||||
|
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moonwalk_Load(struct Game *game) {
|
||||||
|
game->level.moonwalk.derpy_frame = 0;
|
||||||
|
game->level.moonwalk.derpy_frame_tmp = 0;
|
||||||
|
game->level.moonwalk.derpy_pos = -0.2;
|
||||||
|
al_play_sample_instance(game->level.moonwalk.music);
|
||||||
|
ALLEGRO_EVENT ev;
|
||||||
|
int fadeloop;
|
||||||
|
for(fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)){
|
||||||
|
al_wait_for_event(game->event_queue, &ev);
|
||||||
|
al_draw_tinted_bitmap(game->level.moonwalk.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->level.moonwalk.fade_bitmap);
|
||||||
|
Moonwalk_Draw(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Moonwalk_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||||
|
if (ev->keyboard.keycode==ALLEGRO_KEY_ESCAPE) {
|
||||||
|
game->level.moonwalk.music_pos = al_get_sample_instance_position(game->level.moonwalk.music);
|
||||||
|
al_set_sample_instance_playing(game->level.moonwalk.music, false);
|
||||||
|
game->gamestate = GAMESTATE_PAUSE;
|
||||||
|
game->loadstate = GAMESTATE_LEVEL;
|
||||||
|
Pause_Load(game);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moonwalk_PreloadBitmaps(struct Game *game) {
|
||||||
|
game->level.moonwalk.image =LoadScaledBitmap("table.png", al_get_display_width(game->display), al_get_display_height(game->display));
|
||||||
|
game->level.moonwalk.derpy_walkcycle = LoadScaledBitmap("derpcycle.png", al_get_display_width(game->display)*0.1953125*6, al_get_display_height(game->display)*0.25*4);
|
||||||
|
|
||||||
|
game->level.moonwalk.derpy = al_create_bitmap(al_get_display_width(game->display)*0.1953125, al_get_display_height(game->display)*0.25);
|
||||||
|
|
||||||
|
game->level.moonwalk.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||||
|
al_set_target_bitmap(game->level.moonwalk.fade_bitmap);
|
||||||
|
al_draw_bitmap(game->level.moonwalk.image,0,0,0);
|
||||||
|
al_draw_textf(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", game->level.current_level);
|
||||||
|
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||||
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moonwalk_Preload(struct Game *game) {
|
||||||
|
PrintConsole(game, "Initializing level %d...", game->level.current_level);
|
||||||
|
game->level.moonwalk.sample = al_load_sample( "data/moonwalk.flac" );
|
||||||
|
game->level.moonwalk.music = al_create_sample_instance(game->level.moonwalk.sample);
|
||||||
|
al_attach_sample_instance_to_mixer(game->level.moonwalk.music, game->audio.music);
|
||||||
|
al_set_sample_instance_playmode(game->level.moonwalk.music, ALLEGRO_PLAYMODE_LOOP);
|
||||||
|
|
||||||
|
if (!game->level.moonwalk.sample){
|
||||||
|
fprintf(stderr, "Audio clip sample not loaded!\n" );
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Moonwalk_PreloadBitmaps(game);
|
||||||
|
Pause_Preload(game);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moonwalk_UnloadBitmaps(struct Game *game) {
|
||||||
|
al_destroy_bitmap(game->level.moonwalk.image);
|
||||||
|
al_destroy_bitmap(game->level.moonwalk.derpy);
|
||||||
|
al_destroy_bitmap(game->level.moonwalk.derpy_walkcycle);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Moonwalk_Unload(struct Game *game) {
|
||||||
|
Pause_Unload_Real(game);
|
||||||
|
ALLEGRO_EVENT ev;
|
||||||
|
game->level.moonwalk.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||||
|
al_set_target_bitmap(game->level.moonwalk.fade_bitmap);
|
||||||
|
al_draw_bitmap(game->level.moonwalk.image,0,0,0);
|
||||||
|
al_draw_bitmap(game->level.moonwalk.derpy, game->level.moonwalk.derpy_pos*al_get_display_width(game->display), al_get_display_height(game->display)-al_get_bitmap_height(game->level.moonwalk.derpy), ALLEGRO_FLIP_HORIZONTAL);
|
||||||
|
al_draw_textf(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", game->level.current_level);
|
||||||
|
al_draw_text(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||||
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
int fadeloop;
|
||||||
|
for(fadeloop=255; fadeloop>=0; fadeloop-=tps(game, 600)){
|
||||||
|
al_wait_for_event(game->event_queue, &ev);
|
||||||
|
al_draw_tinted_bitmap(game->level.moonwalk.fade_bitmap, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0);
|
||||||
|
DrawConsole(game);
|
||||||
|
al_flip_display();
|
||||||
|
}
|
||||||
|
Moonwalk_UnloadBitmaps(game);
|
||||||
|
al_destroy_bitmap(game->level.moonwalk.fade_bitmap);
|
||||||
|
al_destroy_sample_instance(game->level.moonwalk.music);
|
||||||
|
al_destroy_sample(game->level.moonwalk.sample);
|
||||||
|
}
|
29
src/moonwalk.h
Normal file
29
src/moonwalk.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*! \file level.h
|
||||||
|
* \brief Playable Level 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 Moonwalk_Draw(struct Game *game);
|
||||||
|
void Moonwalk_Preload(struct Game *game);
|
||||||
|
void Moonwalk_Unload(struct Game *game);
|
||||||
|
void Moonwalk_Load(struct Game *game);
|
||||||
|
int Moonwalk_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||||
|
void Moonwalk_UnloadBitmaps(struct Game *game);
|
||||||
|
void Moonwalk_PreloadBitmaps(struct Game *game);
|
56
src/timeline.c
Normal file
56
src/timeline.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*! \file timeline.c
|
||||||
|
* \brief Timeline Manager framework code.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* 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 <allegro5/allegro.h>
|
||||||
|
#include "timeline.h"
|
||||||
|
|
||||||
|
int lastid;
|
||||||
|
|
||||||
|
void TM_Init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM_AddAction(void *func, struct TM_Arguments* args) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM_AddBackgroundAction(void *func, struct TM_Arguments* args, int delay) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM_AddDelay(int delay) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM_Pause(bool pause) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM_Destroy() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TM_Arguments* TM_AddToArgs() {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM_DestroyArgs(struct TM_Arguments* args) {
|
||||||
|
|
||||||
|
}
|
33
src/timeline.h
Normal file
33
src/timeline.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*! \file timeline.h
|
||||||
|
* \brief Timeline Manager framework.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct TM_Arguments {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
void TM_Init();
|
||||||
|
void TM_AddAction(void *func, struct TM_Arguments* args);
|
||||||
|
void TM_AddBackgroundAction(void *func, struct TM_Arguments* args, int delay);
|
||||||
|
void TM_AddDelay(int delay);
|
||||||
|
void TM_Pause(bool pause);
|
||||||
|
void TM_Destroy();
|
||||||
|
struct TM_Arguments* TM_AddToArgs();
|
||||||
|
void TM_DestroyArgs(struct TM_Arguments* args);
|
Loading…
Reference in a new issue