mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-03-04 09:11:27 +01:00
working all moonwalk levels, compiling dodger module (not usable yet), some small tweaks and fixes
This commit is contained in:
parent
e85fcdf8a6
commit
69966ada03
17 changed files with 533 additions and 343 deletions
|
@ -173,7 +173,7 @@ void SetCharacterPosition(struct Game *game, struct Character *character, float
|
|||
}
|
||||
|
||||
void AdvanceLevel(struct Game *game, int current_level, bool last) {
|
||||
if (last) {
|
||||
if (!last) {
|
||||
int available = atoi(GetConfigOptionDefault(game, "MuffinAttack", "level", "1"));
|
||||
available++;
|
||||
if ((available<2) || (available>7)) available=1;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
add_library("libsuperderpy-muffinattack-levels" SHARED "actions.c" "../gamestates/level.c" "modules/moonwalk.c")
|
||||
add_library("libsuperderpy-muffinattack-levels" SHARED "actions.c" "../gamestates/level.c" "modules/moonwalk.c" "modules/dodger.c")
|
||||
|
||||
SET_TARGET_PROPERTIES("libsuperderpy-muffinattack-levels" PROPERTIES PREFIX "")
|
||||
|
||||
|
@ -21,7 +21,7 @@ ENDMACRO()
|
|||
|
||||
#GAMESTATE("level1")
|
||||
GAMESTATE("level2")
|
||||
#GAMESTATE("level3")
|
||||
#GAMESTATE("level4")
|
||||
#GAMESTATE("level5")
|
||||
#GAMESTATE("level6")
|
||||
GAMESTATE("level3")
|
||||
GAMESTATE("level4")
|
||||
GAMESTATE("level5")
|
||||
GAMESTATE("level6")
|
||||
|
|
|
@ -192,7 +192,7 @@ bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState sta
|
|||
*stream = al_load_audio_stream(GetDataFilePath(game, "levels/1/letter.flac"), 4, 1024);
|
||||
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
|
||||
al_set_audio_stream_playing(*stream, false);
|
||||
al_set_audio_stream_gain(*stream, 2.00);
|
||||
al_set_audio_stream_gain(*stream, 2.00); // FIXME: fix audio file instead of gaining it here...
|
||||
action->arguments = TM_AddToArgs(action->arguments, (void*)f);
|
||||
action->arguments = TM_AddToArgs(action->arguments, (void*)stream);
|
||||
action->arguments->next->next = NULL;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "actions.h"
|
||||
#include "modules/dodger.h"
|
||||
#include "modules/dodger/actions.h"
|
||||
#include "level1.h"
|
||||
|
||||
void Level1_Load(struct Game *game) {
|
||||
Dodger_Load(game);
|
||||
|
@ -56,11 +57,11 @@ void Level1_Load(struct Game *game) {
|
|||
// cutscene goes here */
|
||||
TM_AddAction(&PassLevel, NULL, "passlevel");
|
||||
|
||||
// init level specific obstacle for Dodger module
|
||||
// init level specific obstacle (owl) for Dodger module
|
||||
struct Obstacle *obst = malloc(sizeof(struct Obstacle));
|
||||
obst->prev = NULL;
|
||||
obst->next = NULL;
|
||||
obst->x = (game->viewportHeight*1.33625)/game->viewportWidth*100;
|
||||
obst->x = (game->viewport.height*1.33625)/game->viewport.width*100;
|
||||
obst->y = 55;
|
||||
obst->speed = 1;
|
||||
obst->points = 0;
|
||||
|
@ -99,16 +100,16 @@ inline int Level1_PreloadSteps(void) {
|
|||
|
||||
void Level1_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
PROGRESS_INIT(Level1_PreloadSteps());
|
||||
game->level.level1.owl = LoadScaledBitmap("levels/1/owl.png", game->viewportHeight*0.1275, game->viewportHeight*0.1275);
|
||||
game->level.level1.owl = LoadScaledBitmap("levels/1/owl.png", game->viewport.height*0.1275, game->viewport.height*0.1275);
|
||||
PROGRESS;
|
||||
game->level.letter_font = al_load_ttf_font(GetDataFilePath("fonts/DejaVuSans.ttf"),game->viewportHeight*0.0225,0 );
|
||||
game->level.letter_font = al_load_ttf_font(GetDataFilePath("fonts/DejaVuSans.ttf"),game->viewport.height*0.0225,0 );
|
||||
PROGRESS;
|
||||
game->level.letter = LoadScaledBitmap("levels/1/letter.png", game->viewportHeight*1.3, game->viewportHeight*1.2);
|
||||
game->level.letter = LoadScaledBitmap("levels/1/letter.png", game->viewport.height*1.3, game->viewport.height*1.2);
|
||||
al_set_target_bitmap(game->level.letter);
|
||||
float y = 0.20;
|
||||
float x = 0.19;
|
||||
void draw_text(char* text) {
|
||||
al_draw_text(game->level.letter_font, al_map_rgb(0,0,0), al_get_bitmap_width(game->level.letter)*x, game->viewportHeight*y, ALLEGRO_ALIGN_LEFT, text);
|
||||
al_draw_text(game->level.letter_font, al_map_rgb(0,0,0), al_get_bitmap_width(game->level.letter)*x, game->viewport.height*y, ALLEGRO_ALIGN_LEFT, text);
|
||||
y+=0.028;
|
||||
}
|
||||
draw_text("Dear Derpy,");
|
||||
|
@ -148,8 +149,8 @@ void Level1_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, flo
|
|||
|
||||
al_set_target_bitmap(game->level.welcome);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
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, "Level 1");
|
||||
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, "Fluttershy");
|
||||
al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.1, ALLEGRO_ALIGN_CENTRE, "Level 1");
|
||||
al_draw_text_with_shadow(game->menu.font_subtitle, al_map_rgb(255,255,255), game->viewport.width*0.5, game->viewport.height*0.275, ALLEGRO_ALIGN_CENTRE, "Fluttershy");
|
||||
PROGRESS;
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*! \file level2.c
|
||||
* \brief Level 2 code.
|
||||
/*! \file levelX.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
|
@ -19,6 +19,18 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define LEVEL 2
|
||||
|
||||
//macro magic
|
||||
#define CONCAT_REAL(a,b) a ## b
|
||||
#define STRINGIZE_REAL(A) #A
|
||||
#define CONCAT(a,b) CONCAT_REAL(a,b)
|
||||
#define STRINGIZE(A) STRINGIZE_REAL(A)
|
||||
|
||||
#define LevelXResources CONCAT(CONCAT(Level,LEVEL),Resources)
|
||||
#define levelx STRINGIZE(CONCAT(level,LEVEL))
|
||||
#define levelxh STRINGIZE(CONCAT(level,LEVEL).h)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../gamestates/level.h"
|
||||
|
@ -26,18 +38,18 @@
|
|||
#include "../timeline.h"
|
||||
#include "actions.h"
|
||||
#include "../utils.h"
|
||||
#include "level2.h"
|
||||
#include levelxh
|
||||
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct Level2Resources *data = malloc(sizeof(struct Level2Resources));
|
||||
data->moonwalk = Moonwalk_Load(game, 2);
|
||||
struct LevelXResources *data = malloc(sizeof(struct LevelXResources));
|
||||
data->moonwalk = Moonwalk_Load(game, LEVEL);
|
||||
(*progress)(game);
|
||||
|
||||
struct TM_Arguments *args = TM_AddToArgs(NULL, strdup("level2"));
|
||||
struct TM_Arguments *args = TM_AddToArgs(NULL, strdup(levelx));
|
||||
int* level = malloc(sizeof(int));
|
||||
*level=2;
|
||||
*level=LEVEL;
|
||||
TM_AddToArgs(args, level);
|
||||
TM_AddAction(&PassLevel, args, "passlevel");
|
||||
(*progress)(game);
|
||||
|
@ -48,48 +60,48 @@ void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
|||
return data;
|
||||
}
|
||||
|
||||
void Gamestate_Unload(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Unload(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Unload(game, data->moonwalk);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Gamestate_Start(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Start(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Start(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Stop(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Stop(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Stop(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Draw(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Draw(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Draw(game, data->moonwalk);
|
||||
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", 2);
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", LEVEL);
|
||||
al_draw_text(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||
}
|
||||
|
||||
void Gamestate_Logic(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Logic(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Logic(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct Level2Resources* data, ALLEGRO_EVENT *ev) {
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelXResources* data, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, data->moonwalk, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, "level2", "menu");
|
||||
SwitchGamestate(game, levelx, "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Gamestate_Resume(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Resume(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Resume(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Pause(struct Game *game, struct Level2Resources* data) {
|
||||
void Gamestate_Pause(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Pause(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Gamestate_Reload(struct Game *game, struct Level2Resources* data) {}
|
||||
void Gamestate_Reload(struct Game *game, struct LevelXResources* data) {}
|
||||
|
||||
int Gamestate_ProgressCount = 3;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*! \file level3.c
|
||||
* \brief Level 3 code.
|
||||
/*! \file levelX.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
|
@ -18,62 +18,90 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define LEVEL 3
|
||||
|
||||
//macro magic
|
||||
#define CONCAT_REAL(a,b) a ## b
|
||||
#define STRINGIZE_REAL(A) #A
|
||||
#define CONCAT(a,b) CONCAT_REAL(a,b)
|
||||
#define STRINGIZE(A) STRINGIZE_REAL(A)
|
||||
|
||||
#define LevelXResources CONCAT(CONCAT(Level,LEVEL),Resources)
|
||||
#define levelx STRINGIZE(CONCAT(level,LEVEL))
|
||||
#define levelxh STRINGIZE(CONCAT(level,LEVEL).h)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "modules/moonwalk.h"
|
||||
#include "../timeline.h"
|
||||
#include "actions.h"
|
||||
#include "level3.h"
|
||||
#include "../utils.h"
|
||||
#include levelxh
|
||||
|
||||
void Level3_Load(struct Game *game) {
|
||||
Moonwalk_Load(game);
|
||||
TM_AddAction(&DoMoonwalk, NULL, "moonwalk");
|
||||
TM_AddAction(&PassLevel, NULL, "passlevel");
|
||||
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
|
||||
FadeGameState(game, true);
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct LevelXResources *data = malloc(sizeof(struct LevelXResources));
|
||||
data->moonwalk = Moonwalk_Load(game, LEVEL);
|
||||
(*progress)(game);
|
||||
|
||||
struct TM_Arguments *args = TM_AddToArgs(NULL, strdup(levelx));
|
||||
int* level = malloc(sizeof(int));
|
||||
*level=LEVEL;
|
||||
TM_AddToArgs(args, level);
|
||||
TM_AddAction(&PassLevel, args, "passlevel");
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.09,0 );
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Level3_Unload(struct Game *game) {
|
||||
Moonwalk_Unload(game);
|
||||
void Gamestate_Unload(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Unload(game, data->moonwalk);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Level3_UnloadBitmaps(struct Game *game) {
|
||||
Moonwalk_UnloadBitmaps(game);
|
||||
void Gamestate_Start(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Start(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level3_Preload(struct Game *game) {
|
||||
Moonwalk_Preload(game);
|
||||
void Gamestate_Stop(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Stop(game, data->moonwalk);
|
||||
}
|
||||
|
||||
inline int Level3_PreloadSteps(void) {
|
||||
return 0+Moonwalk_PreloadSteps();
|
||||
void Gamestate_Draw(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Draw(game, data->moonwalk);
|
||||
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", LEVEL);
|
||||
al_draw_text(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||
}
|
||||
|
||||
void Level3_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
//PROGRESS_INIT(Level3_PreloadSteps());
|
||||
Moonwalk_PreloadBitmaps(game, progress);
|
||||
void Gamestate_Logic(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Logic(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level3_Draw(struct Game *game) {
|
||||
Moonwalk_Draw(game);
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelXResources* data, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, data->moonwalk, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, levelx, "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Level3_Logic(struct Game *game) {
|
||||
Moonwalk_Logic(game);
|
||||
void Gamestate_Resume(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Resume(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level3_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_Keydown(game, ev);
|
||||
void Gamestate_Pause(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Pause(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level3_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, ev);
|
||||
}
|
||||
void Gamestate_Reload(struct Game *game, struct LevelXResources* data) {}
|
||||
|
||||
void Level3_Resume(struct Game *game) {
|
||||
Moonwalk_Resume(game);
|
||||
}
|
||||
|
||||
void Level3_Pause(struct Game *game) {
|
||||
Moonwalk_Pause(game);
|
||||
}
|
||||
int Gamestate_ProgressCount = 3;
|
||||
|
|
|
@ -20,15 +20,8 @@
|
|||
*/
|
||||
#include "../main.h"
|
||||
|
||||
void Level3_Load(struct Game *game);
|
||||
void Level3_Unload(struct Game *game);
|
||||
void Level3_UnloadBitmaps(struct Game *game);
|
||||
void Level3_Preload(struct Game *game);
|
||||
void Level3_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float));
|
||||
inline int Level3_PreloadSteps(void);
|
||||
void Level3_Draw(struct Game *game);
|
||||
void Level3_Logic(struct Game *game);
|
||||
void Level3_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level3_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level3_Resume(struct Game *game);
|
||||
void Level3_Pause(struct Game *game);
|
||||
struct Moonwalk;
|
||||
struct Level3Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*! \file level4.c
|
||||
* \brief Level 4 code.
|
||||
/*! \file levelX.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
|
@ -18,62 +18,90 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define LEVEL 4
|
||||
|
||||
//macro magic
|
||||
#define CONCAT_REAL(a,b) a ## b
|
||||
#define STRINGIZE_REAL(A) #A
|
||||
#define CONCAT(a,b) CONCAT_REAL(a,b)
|
||||
#define STRINGIZE(A) STRINGIZE_REAL(A)
|
||||
|
||||
#define LevelXResources CONCAT(CONCAT(Level,LEVEL),Resources)
|
||||
#define levelx STRINGIZE(CONCAT(level,LEVEL))
|
||||
#define levelxh STRINGIZE(CONCAT(level,LEVEL).h)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "modules/moonwalk.h"
|
||||
#include "../timeline.h"
|
||||
#include "actions.h"
|
||||
#include "level4.h"
|
||||
#include "../utils.h"
|
||||
#include levelxh
|
||||
|
||||
void Level4_Load(struct Game *game) {
|
||||
Moonwalk_Load(game);
|
||||
TM_AddAction(&DoMoonwalk, NULL, "moonwalk");
|
||||
TM_AddAction(&PassLevel, NULL, "passlevel");
|
||||
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
|
||||
FadeGameState(game, true);
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct LevelXResources *data = malloc(sizeof(struct LevelXResources));
|
||||
data->moonwalk = Moonwalk_Load(game, LEVEL);
|
||||
(*progress)(game);
|
||||
|
||||
struct TM_Arguments *args = TM_AddToArgs(NULL, strdup(levelx));
|
||||
int* level = malloc(sizeof(int));
|
||||
*level=LEVEL;
|
||||
TM_AddToArgs(args, level);
|
||||
TM_AddAction(&PassLevel, args, "passlevel");
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.09,0 );
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Level4_Unload(struct Game *game) {
|
||||
Moonwalk_Unload(game);
|
||||
void Gamestate_Unload(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Unload(game, data->moonwalk);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Level4_UnloadBitmaps(struct Game *game) {
|
||||
Moonwalk_UnloadBitmaps(game);
|
||||
void Gamestate_Start(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Start(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level4_Preload(struct Game *game) {
|
||||
Moonwalk_Preload(game);
|
||||
void Gamestate_Stop(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Stop(game, data->moonwalk);
|
||||
}
|
||||
|
||||
inline int Level4_PreloadSteps(void) {
|
||||
return 0+Moonwalk_PreloadSteps();
|
||||
void Gamestate_Draw(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Draw(game, data->moonwalk);
|
||||
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", LEVEL);
|
||||
al_draw_text(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||
}
|
||||
|
||||
void Level4_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
//PROGRESS_INIT(Level4_PreloadSteps());
|
||||
Moonwalk_PreloadBitmaps(game, progress);
|
||||
void Gamestate_Logic(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Logic(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level4_Draw(struct Game *game) {
|
||||
Moonwalk_Draw(game);
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelXResources* data, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, data->moonwalk, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, levelx, "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Level4_Logic(struct Game *game) {
|
||||
Moonwalk_Logic(game);
|
||||
void Gamestate_Resume(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Resume(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level4_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_Keydown(game, ev);
|
||||
void Gamestate_Pause(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Pause(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level4_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, ev);
|
||||
}
|
||||
void Gamestate_Reload(struct Game *game, struct LevelXResources* data) {}
|
||||
|
||||
void Level4_Resume(struct Game *game) {
|
||||
Moonwalk_Resume(game);
|
||||
}
|
||||
|
||||
void Level4_Pause(struct Game *game) {
|
||||
Moonwalk_Pause(game);
|
||||
}
|
||||
int Gamestate_ProgressCount = 3;
|
||||
|
|
|
@ -20,15 +20,8 @@
|
|||
*/
|
||||
#include "../main.h"
|
||||
|
||||
void Level4_Load(struct Game *game);
|
||||
void Level4_Unload(struct Game *game);
|
||||
void Level4_UnloadBitmaps(struct Game *game);
|
||||
void Level4_Preload(struct Game *game);
|
||||
void Level4_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float));
|
||||
inline int Level4_PreloadSteps(void);
|
||||
void Level4_Draw(struct Game *game);
|
||||
void Level4_Logic(struct Game *game);
|
||||
void Level4_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level4_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level4_Resume(struct Game *game);
|
||||
void Level4_Pause(struct Game *game);
|
||||
struct Moonwalk;
|
||||
struct Level4Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*! \file level5.c
|
||||
* \brief Level 5 code.
|
||||
/*! \file levelX.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
|
@ -18,62 +18,90 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define LEVEL 5
|
||||
|
||||
//macro magic
|
||||
#define CONCAT_REAL(a,b) a ## b
|
||||
#define STRINGIZE_REAL(A) #A
|
||||
#define CONCAT(a,b) CONCAT_REAL(a,b)
|
||||
#define STRINGIZE(A) STRINGIZE_REAL(A)
|
||||
|
||||
#define LevelXResources CONCAT(CONCAT(Level,LEVEL),Resources)
|
||||
#define levelx STRINGIZE(CONCAT(level,LEVEL))
|
||||
#define levelxh STRINGIZE(CONCAT(level,LEVEL).h)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "modules/moonwalk.h"
|
||||
#include "../timeline.h"
|
||||
#include "actions.h"
|
||||
#include "level5.h"
|
||||
#include "../utils.h"
|
||||
#include levelxh
|
||||
|
||||
void Level5_Load(struct Game *game) {
|
||||
Moonwalk_Load(game);
|
||||
TM_AddAction(&DoMoonwalk, NULL, "moonwalk");
|
||||
TM_AddAction(&PassLevel, NULL, "passlevel");
|
||||
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
|
||||
FadeGameState(game, true);
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct LevelXResources *data = malloc(sizeof(struct LevelXResources));
|
||||
data->moonwalk = Moonwalk_Load(game, LEVEL);
|
||||
(*progress)(game);
|
||||
|
||||
struct TM_Arguments *args = TM_AddToArgs(NULL, strdup(levelx));
|
||||
int* level = malloc(sizeof(int));
|
||||
*level=LEVEL;
|
||||
TM_AddToArgs(args, level);
|
||||
TM_AddAction(&PassLevel, args, "passlevel");
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.09,0 );
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Level5_Unload(struct Game *game) {
|
||||
Moonwalk_Unload(game);
|
||||
void Gamestate_Unload(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Unload(game, data->moonwalk);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Level5_UnloadBitmaps(struct Game *game) {
|
||||
Moonwalk_UnloadBitmaps(game);
|
||||
void Gamestate_Start(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Start(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level5_Preload(struct Game *game) {
|
||||
Moonwalk_Preload(game);
|
||||
void Gamestate_Stop(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Stop(game, data->moonwalk);
|
||||
}
|
||||
|
||||
inline int Level5_PreloadSteps(void) {
|
||||
return 0+Moonwalk_PreloadSteps();
|
||||
void Gamestate_Draw(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Draw(game, data->moonwalk);
|
||||
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", LEVEL);
|
||||
al_draw_text(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||
}
|
||||
|
||||
void Level5_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
//PROGRESS_INIT(Level5_PreloadSteps());
|
||||
Moonwalk_PreloadBitmaps(game, progress);
|
||||
void Gamestate_Logic(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Logic(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level5_Draw(struct Game *game) {
|
||||
Moonwalk_Draw(game);
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelXResources* data, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, data->moonwalk, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, levelx, "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Level5_Logic(struct Game *game) {
|
||||
Moonwalk_Logic(game);
|
||||
void Gamestate_Resume(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Resume(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level5_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_Keydown(game, ev);
|
||||
void Gamestate_Pause(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Pause(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level5_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, ev);
|
||||
}
|
||||
void Gamestate_Reload(struct Game *game, struct LevelXResources* data) {}
|
||||
|
||||
void Level5_Resume(struct Game *game) {
|
||||
Moonwalk_Resume(game);
|
||||
}
|
||||
|
||||
void Level5_Pause(struct Game *game) {
|
||||
Moonwalk_Pause(game);
|
||||
}
|
||||
int Gamestate_ProgressCount = 3;
|
||||
|
|
|
@ -20,15 +20,8 @@
|
|||
*/
|
||||
#include "../main.h"
|
||||
|
||||
void Level5_Load(struct Game *game);
|
||||
void Level5_Unload(struct Game *game);
|
||||
void Level5_UnloadBitmaps(struct Game *game);
|
||||
void Level5_Preload(struct Game *game);
|
||||
void Level5_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float));
|
||||
inline int Level5_PreloadSteps(void);
|
||||
void Level5_Draw(struct Game *game);
|
||||
void Level5_Logic(struct Game *game);
|
||||
void Level5_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level5_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level5_Resume(struct Game *game);
|
||||
void Level5_Pause(struct Game *game);
|
||||
struct Moonwalk;
|
||||
struct Level5Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*! \file level6.c
|
||||
* \brief Level 6 code.
|
||||
/*! \file levelX.c
|
||||
* \brief Level placeholder code.
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) Sebastian Krzyszkowiak <dos@dosowisko.net>
|
||||
|
@ -18,62 +18,90 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define LEVEL 6
|
||||
|
||||
//macro magic
|
||||
#define CONCAT_REAL(a,b) a ## b
|
||||
#define STRINGIZE_REAL(A) #A
|
||||
#define CONCAT(a,b) CONCAT_REAL(a,b)
|
||||
#define STRINGIZE(A) STRINGIZE_REAL(A)
|
||||
|
||||
#define LevelXResources CONCAT(CONCAT(Level,LEVEL),Resources)
|
||||
#define levelx STRINGIZE(CONCAT(level,LEVEL))
|
||||
#define levelxh STRINGIZE(CONCAT(level,LEVEL).h)
|
||||
|
||||
#include <stdio.h>
|
||||
#include "allegro5/allegro_ttf.h"
|
||||
#include "../gamestates/level.h"
|
||||
#include "modules/moonwalk.h"
|
||||
#include "../timeline.h"
|
||||
#include "actions.h"
|
||||
#include "level6.h"
|
||||
#include "../utils.h"
|
||||
#include levelxh
|
||||
|
||||
void Level6_Load(struct Game *game) {
|
||||
Moonwalk_Load(game);
|
||||
TM_AddAction(&DoMoonwalk, NULL, "moonwalk");
|
||||
TM_AddBackgroundAction(&DoMoonwalk, NULL, 5000, "moonwalkDerp");
|
||||
TM_AddBackgroundAction(&PassLevel, NULL, 10000, "passlevel");
|
||||
FadeGameState(game, true);
|
||||
|
||||
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
|
||||
|
||||
struct LevelXResources *data = malloc(sizeof(struct LevelXResources));
|
||||
data->moonwalk = Moonwalk_Load(game, LEVEL);
|
||||
(*progress)(game);
|
||||
|
||||
struct TM_Arguments *args = TM_AddToArgs(NULL, strdup(levelx));
|
||||
int* level = malloc(sizeof(int));
|
||||
*level=LEVEL;
|
||||
TM_AddToArgs(args, level);
|
||||
TM_AddAction(&PassLevel, args, "passlevel");
|
||||
(*progress)(game);
|
||||
|
||||
data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/ShadowsIntoLight.ttf"),game->viewport.height*0.09,0 );
|
||||
(*progress)(game);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void Level6_Unload(struct Game *game) {
|
||||
Moonwalk_Unload(game);
|
||||
void Gamestate_Unload(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Unload(game, data->moonwalk);
|
||||
al_destroy_font(data->font);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Level6_UnloadBitmaps(struct Game *game) {
|
||||
Moonwalk_UnloadBitmaps(game);
|
||||
void Gamestate_Start(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Start(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level6_Preload(struct Game *game) {
|
||||
Moonwalk_Preload(game);
|
||||
void Gamestate_Stop(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Stop(game, data->moonwalk);
|
||||
}
|
||||
|
||||
inline int Level6_PreloadSteps(void) {
|
||||
return 0+Moonwalk_PreloadSteps();
|
||||
void Gamestate_Draw(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Draw(game, data->moonwalk);
|
||||
|
||||
al_draw_textf(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/2.2, ALLEGRO_ALIGN_CENTRE, "Level %d: Not implemented yet!", LEVEL);
|
||||
al_draw_text(data->font, al_map_rgb(255,255,255), game->viewport.width/2, game->viewport.height/1.8, ALLEGRO_ALIGN_CENTRE, "Have some moonwalk instead.");
|
||||
}
|
||||
|
||||
void Level6_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
//PROGRESS_INIT(Level6_PreloadSteps());
|
||||
Moonwalk_PreloadBitmaps(game, progress);
|
||||
void Gamestate_Logic(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Logic(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level6_Draw(struct Game *game) {
|
||||
Moonwalk_Draw(game);
|
||||
void Gamestate_ProcessEvent(struct Game *game, struct LevelXResources* data, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, data->moonwalk, ev);
|
||||
if (ev->type == ALLEGRO_EVENT_KEY_DOWN) {
|
||||
if (ev->keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
|
||||
SwitchGamestate(game, levelx, "map");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Level6_Logic(struct Game *game) {
|
||||
Moonwalk_Logic(game);
|
||||
void Gamestate_Resume(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Resume(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level6_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_Keydown(game, ev);
|
||||
void Gamestate_Pause(struct Game *game, struct LevelXResources* data) {
|
||||
Moonwalk_Pause(game, data->moonwalk);
|
||||
}
|
||||
|
||||
void Level6_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
Moonwalk_ProcessEvent(game, ev);
|
||||
}
|
||||
void Gamestate_Reload(struct Game *game, struct LevelXResources* data) {}
|
||||
|
||||
void Level6_Resume(struct Game *game) {
|
||||
Moonwalk_Resume(game);
|
||||
}
|
||||
|
||||
void Level6_Pause(struct Game *game) {
|
||||
Moonwalk_Pause(game);
|
||||
}
|
||||
int Gamestate_ProgressCount = 3;
|
||||
|
|
|
@ -20,15 +20,8 @@
|
|||
*/
|
||||
#include "../main.h"
|
||||
|
||||
void Level6_Load(struct Game *game);
|
||||
void Level6_Unload(struct Game *game);
|
||||
void Level6_UnloadBitmaps(struct Game *game);
|
||||
void Level6_Preload(struct Game *game);
|
||||
void Level6_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float));
|
||||
inline int Level6_PreloadSteps(void);
|
||||
void Level6_Draw(struct Game *game);
|
||||
void Level6_Logic(struct Game *game);
|
||||
void Level6_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level6_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Level6_Resume(struct Game *game);
|
||||
void Level6_Pause(struct Game *game);
|
||||
struct Moonwalk;
|
||||
struct Level6Resources {
|
||||
struct Moonwalk *moonwalk;
|
||||
ALLEGRO_FONT *font;
|
||||
};
|
||||
|
|
|
@ -20,56 +20,58 @@
|
|||
*/
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <allegro5/allegro_primitives.h>
|
||||
#include "../../gamestates/level.h"
|
||||
#include "../../utils.h"
|
||||
#include "../actions.h"
|
||||
#include "dodger.h"
|
||||
#include "dodger/actions.h"
|
||||
|
||||
void Dodger_Logic(struct Game *game) {
|
||||
void Dodger_Logic(struct Game *game, struct Dodger* data) {
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
if (game->level.handle_input) {
|
||||
if (game->level.derpy_angle > 0) { game->level.derpy_angle -= 0.02; if (game->level.derpy_angle < 0) game->level.derpy_angle = 0; }
|
||||
if (game->level.derpy_angle < 0) { game->level.derpy_angle += 0.02; if (game->level.derpy_angle > 0) game->level.derpy_angle = 0; }
|
||||
if (data->handle_input) {
|
||||
if (data->derpy_angle > 0) { data->derpy_angle -= 0.02; if (data->derpy_angle < 0) data->derpy_angle = 0; }
|
||||
if (data->derpy_angle < 0) { data->derpy_angle += 0.02; if (data->derpy_angle > 0) data->derpy_angle = 0; }
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_UP)) {
|
||||
game->level.derpy_y -= 0.005;
|
||||
game->level.derpy_angle -= 0.03;
|
||||
if (game->level.derpy_angle < -0.15) game->level.derpy_angle = -0.15;
|
||||
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
||||
data->derpy_y -= 0.005;
|
||||
data->derpy_angle -= 0.03;
|
||||
if (data->derpy_angle < -0.15) data->derpy_angle = -0.15;
|
||||
/*PrintConsole(game, "Derpy Y position: %f", data->derpy_y);*/
|
||||
}
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_DOWN)) {
|
||||
game->level.derpy_y += 0.005;
|
||||
game->level.derpy_angle += 0.03;
|
||||
if (game->level.derpy_angle > 0.15) game->level.derpy_angle = 0.15;
|
||||
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
||||
data->derpy_y += 0.005;
|
||||
data->derpy_angle += 0.03;
|
||||
if (data->derpy_angle > 0.15) data->derpy_angle = 0.15;
|
||||
/*PrintConsole(game, "Derpy Y position: %f", data->derpy_y);*/
|
||||
}
|
||||
/*if ((game->level.derpy_y > 0.6) && (game->level.flying)) {
|
||||
/*if ((data->derpy_y > 0.6) && (data->flying)) {
|
||||
SelectDerpySpritesheet(game, "run");
|
||||
game->level.flying = false;
|
||||
game->level.sheet_speed = tps(game, 60*0.0020/game->level.speed);
|
||||
data->flying = false;
|
||||
data->sheet_speed = tps(game, 60*0.0020/data->speed);
|
||||
}
|
||||
else if ((game->level.derpy_y <= 0.6) && (!game->level.flying)) {
|
||||
else if ((data->derpy_y <= 0.6) && (!data->flying)) {
|
||||
SelectDerpySpritesheet(game, "fly");
|
||||
game->level.flying = true;
|
||||
game->level.sheet_speed = tps(game, 60*2.4);
|
||||
data->flying = true;
|
||||
data->sheet_speed = tps(game, 60*2.4);
|
||||
}
|
||||
if (!game->level.flying) game->level.sheet_speed = tps(game, 60*0.0020/game->level.speed); */
|
||||
if (game->level.derpy_y < 0) game->level.derpy_y=0;
|
||||
else if (game->level.derpy_y > 0.8) game->level.derpy_y=0.8;
|
||||
if (!data->flying) data->sheet_speed = tps(game, 60*0.0020/data->speed); */
|
||||
if (data->derpy_y < 0) data->derpy_y=0;
|
||||
else if (data->derpy_y > 0.8) data->derpy_y=0.8;
|
||||
|
||||
game->level.derpy_y += game->level.derpy_angle / 30;
|
||||
data->derpy_y += data->derpy_angle / 30;
|
||||
}
|
||||
|
||||
int derpyx = game->level.derpy_x*game->viewportHeight*1.6;
|
||||
int derpyy = game->level.derpy_y*game->viewportHeight;
|
||||
int derpyw = al_get_bitmap_width(game->level.derpy);
|
||||
int derpyh = al_get_bitmap_height(game->level.derpy);
|
||||
int derpyo = game->viewportHeight*1.6*0.1953125-al_get_bitmap_width(game->level.derpy); /* offset */
|
||||
struct Obstacle *tmp = game->level.dodger.obstacles;
|
||||
int derpyx = data->derpy_x*game->viewport.height*1.6;
|
||||
int derpyy = data->derpy_y*game->viewport.height;
|
||||
int derpyw = al_get_bitmap_width(data->derpy);
|
||||
int derpyh = al_get_bitmap_height(data->derpy);
|
||||
int derpyo = game->viewport.height*1.6*0.1953125-al_get_bitmap_width(data->derpy); /* offset */
|
||||
struct Obstacle *tmp = data->dodger.obstacles;
|
||||
while (tmp) {
|
||||
/*PrintConsole(game, "DRAWING %f %f", tmp->x, tmp->y);*/
|
||||
int x = (tmp->x/100.0)*game->viewportWidth;
|
||||
int y = (tmp->y/100.0)*game->viewportHeight;
|
||||
int x = (tmp->x/100.0)*game->viewport.width;
|
||||
int y = (tmp->y/100.0)*game->viewport.height;
|
||||
int w = 0, h = 0;
|
||||
if (tmp->bitmap) {
|
||||
w = al_get_bitmap_width(*(tmp->bitmap))/tmp->cols;
|
||||
|
@ -93,17 +95,17 @@ void Dodger_Logic(struct Game *game) {
|
|||
|
||||
if (tmp->hit) {
|
||||
if (tmp->points>0) tmp->bitmap = NULL;
|
||||
game->level.hp+=0.0002*tmp->points*(((1-game->level.speed_modifier)/2.0)+1);
|
||||
if (game->level.hp>1) game->level.hp=1;
|
||||
//PrintConsole(game, "POINTS: %d, %f", tmp->points, tps(game, 60*0.0002*tmp->points*game->level.speed_modifier));
|
||||
if ((game->level.hp<=0) && (!game->level.failed)) {
|
||||
game->level.failed = true;
|
||||
game->level.handle_input = false;
|
||||
game->level.speed_modifier = 1;
|
||||
data->hp+=0.0002*tmp->points*(((1-data->speed_modifier)/2.0)+1);
|
||||
if (data->hp>1) data->hp=1;
|
||||
//PrintConsole(game, "POINTS: %d, %f", tmp->points, tps(game, 60*0.0002*tmp->points*data->speed_modifier));
|
||||
if ((data->hp<=0) && (!data->failed)) {
|
||||
data->failed = true;
|
||||
data->handle_input = false;
|
||||
data->speed_modifier = 1;
|
||||
TM_AddBackgroundAction(&LevelFailed, NULL, 0, "levelfailed");
|
||||
}
|
||||
}
|
||||
tmp->x -= game->level.speed*game->level.speed_modifier*tmp->speed*100*al_get_bitmap_width(game->level.stage)/(float)game->viewportWidth;
|
||||
tmp->x -= data->speed*data->speed_modifier*tmp->speed*100*al_get_bitmap_width(data->stage)/(float)game->viewport.width;
|
||||
if (tmp->callback) tmp->callback(game, tmp);
|
||||
tmp = tmp->next;
|
||||
} else {
|
||||
|
@ -112,28 +114,28 @@ void Dodger_Logic(struct Game *game) {
|
|||
if (tmp->prev)
|
||||
tmp->prev->next = tmp->next;
|
||||
else
|
||||
game->level.dodger.obstacles = tmp->next;
|
||||
data->dodger.obstacles = tmp->next;
|
||||
struct Obstacle *t = tmp;
|
||||
tmp = tmp->next;
|
||||
free(t);
|
||||
}
|
||||
}
|
||||
/*if (colision) game->level.hp-=tps(game, 60*0.002);*/
|
||||
/*if (colision) data->hp-=tps(game, 60*0.002);*/
|
||||
|
||||
}
|
||||
|
||||
void Dodger_Draw(struct Game *game) {
|
||||
int derpyx = game->level.derpy_x*game->viewportHeight*1.6;
|
||||
int derpyy = game->level.derpy_y*game->viewportHeight;
|
||||
int derpyw = al_get_bitmap_width(game->level.derpy);
|
||||
int derpyh = al_get_bitmap_height(game->level.derpy);
|
||||
int derpyo = game->viewportHeight*1.6*0.1953125-al_get_bitmap_width(game->level.derpy); /* offset */
|
||||
void Dodger_Draw(struct Game *game, struct Dodger* data) {
|
||||
int derpyx = data->derpy_x*game->viewport.height*1.6;
|
||||
int derpyy = data->derpy_y*game->viewport.height;
|
||||
int derpyw = al_get_bitmap_width(data->derpy);
|
||||
int derpyh = al_get_bitmap_height(data->derpy);
|
||||
int derpyo = game->viewport.height*1.6*0.1953125-al_get_bitmap_width(data->derpy); /* offset */
|
||||
bool colision = false;
|
||||
struct Obstacle *tmp = game->level.dodger.obstacles;
|
||||
struct Obstacle *tmp = data->dodger.obstacles;
|
||||
while (tmp) {
|
||||
/*PrintConsole(game, "DRAWING %f %f", tmp->x, tmp->y);*/
|
||||
int x = (tmp->x/100.0)*game->viewportWidth;
|
||||
int y = (tmp->y/100.0)*game->viewportHeight;
|
||||
int x = (tmp->x/100.0)*game->viewport.width;
|
||||
int y = (tmp->y/100.0)*game->viewport.height;
|
||||
int w = 0, h = 0;
|
||||
if (tmp->bitmap) {
|
||||
w = al_get_bitmap_width(*(tmp->bitmap))/tmp->cols;
|
||||
|
@ -151,7 +153,7 @@ void Dodger_Draw(struct Game *game) {
|
|||
}
|
||||
|
||||
/*al_draw_bitmap(*(tmp->bitmap), x, y, 0);*/
|
||||
if (game->level.debug_show_sprite_frames) al_draw_rectangle(x, y, x+w, y+h, al_map_rgba(255,0,0,255), 3);
|
||||
if (data->debug_show_sprite_frames) al_draw_rectangle(x, y, x+w, y+h, al_map_rgba(255,0,0,255), 3);
|
||||
|
||||
tmp = tmp->next;
|
||||
} else {
|
||||
|
@ -160,59 +162,66 @@ void Dodger_Draw(struct Game *game) {
|
|||
if (tmp->prev)
|
||||
tmp->prev->next = tmp->next;
|
||||
else
|
||||
game->level.dodger.obstacles = tmp->next;
|
||||
data->dodger.obstacles = tmp->next;
|
||||
struct Obstacle *t = tmp;
|
||||
tmp = tmp->next;
|
||||
free(t);
|
||||
}
|
||||
}
|
||||
/*if (colision) game->level.hp-=tps(game, 60*0.002);*/
|
||||
/*if (colision) data->hp-=tps(game, 60*0.002);*/
|
||||
|
||||
al_set_target_bitmap(game->level.derpy);
|
||||
al_set_target_bitmap(data->derpy);
|
||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||
al_draw_bitmap_region(*(game->level.derpy_sheet),al_get_bitmap_width(game->level.derpy)*(game->level.sheet_pos%game->level.sheet_cols),al_get_bitmap_height(game->level.derpy)*(game->level.sheet_pos/game->level.sheet_cols),al_get_bitmap_width(game->level.derpy), al_get_bitmap_height(game->level.derpy),0,0,0);
|
||||
al_draw_bitmap_region(*(data->derpy_sheet),al_get_bitmap_width(data->derpy)*(data->sheet_pos%data->sheet_cols),al_get_bitmap_height(data->derpy)*(data->sheet_pos/data->sheet_cols),al_get_bitmap_width(data->derpy), al_get_bitmap_height(data->derpy),0,0,0);
|
||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_draw_tinted_rotated_bitmap(game->level.derpy, al_map_rgba(255,255-colision*255,255-colision*255,255), al_get_bitmap_width(game->level.derpy), al_get_bitmap_height(game->level.derpy)/2, derpyx+game->viewportHeight*1.6*0.1953125, derpyy + al_get_bitmap_height(game->level.derpy)/2, game->level.derpy_angle, 0);
|
||||
al_draw_tinted_rotated_bitmap(data->derpy, al_map_rgba(255,255-colision*255,255-colision*255,255), al_get_bitmap_width(data->derpy), al_get_bitmap_height(data->derpy)/2, derpyx+game->viewport.height*1.6*0.1953125, derpyy + al_get_bitmap_height(data->derpy)/2, data->derpy_angle, 0);
|
||||
|
||||
/* if ((((x>=derpyx+0.36*derpyw) && (x<=derpyx+0.94*derpyw)) || ((x+w>=derpyx+0.36*derpyw) && (x+w<=derpyx+0.94*derpyw))) &&
|
||||
(((y>=derpyy+0.26*derpyh) && (y<=derpyy+0.76*derpyh)) || ((y+h>=derpyy+0.26*derpyh) && (y+h<=derpyy+0.76*derpyh)))) {
|
||||
*/
|
||||
if (game->level.debug_show_sprite_frames) {
|
||||
if (data->debug_show_sprite_frames) {
|
||||
al_draw_rectangle(derpyx+derpyo, derpyy, derpyx+derpyw+derpyo, derpyy+derpyh, al_map_rgba(0,255,0,255), 3);
|
||||
al_draw_rectangle(derpyx+0.38*derpyw+derpyo, derpyy+0.26*derpyh, derpyx+0.94*derpyw+derpyo, derpyy+0.76*derpyh, al_map_rgba(0,0,255,255), 3);
|
||||
}
|
||||
}
|
||||
|
||||
void Dodger_Load(struct Game *game) {
|
||||
game->level.dodger.obstacles = NULL;
|
||||
struct Dodger* Dodger_Load(struct Game *game, int current_level) {
|
||||
struct Dodger *data = malloc(sizeof(struct Dodger));
|
||||
data->dodger.obstacles = NULL;
|
||||
data->character = CreateCharacter(game, "derpy");
|
||||
RegisterSpritesheet(game, data->character, "walk");
|
||||
RegisterSpritesheet(game, data->character, "stand");
|
||||
RegisterSpritesheet(game, data->character, "fly");
|
||||
RegisterSpritesheet(game, data->character, "run");
|
||||
return data;
|
||||
}
|
||||
|
||||
void Dodger_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
if (game->level.handle_input) {
|
||||
void Dodger_Keydown(struct Game *game, struct Dodger* data, ALLEGRO_EVENT *ev) {
|
||||
if (data->handle_input) {
|
||||
if (ev->keyboard.keycode==ALLEGRO_KEY_LEFT) {
|
||||
game->level.speed_modifier = 0.75;
|
||||
data->speed_modifier = 0.75;
|
||||
} else if (ev->keyboard.keycode==ALLEGRO_KEY_RIGHT) {
|
||||
game->level.speed_modifier = 1.3;
|
||||
data->speed_modifier = 1.3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Dodger_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev) {
|
||||
if (game->level.handle_input) {
|
||||
void Dodger_ProcessEvent(struct Game *game, struct Dodger* data, ALLEGRO_EVENT *ev) {
|
||||
if (data->handle_input) {
|
||||
if ((ev->type==ALLEGRO_EVENT_KEY_UP) && (ev->keyboard.keycode==ALLEGRO_KEY_LEFT)) {
|
||||
game->level.speed_modifier = 1;
|
||||
data->speed_modifier = 1;
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_RIGHT)) {
|
||||
game->level.speed_modifier = 1.3;
|
||||
data->speed_modifier = 1.3;
|
||||
}
|
||||
} else if ((ev->type==ALLEGRO_EVENT_KEY_UP) && (ev->keyboard.keycode==ALLEGRO_KEY_RIGHT)) {
|
||||
game->level.speed_modifier = 1;
|
||||
data->speed_modifier = 1;
|
||||
struct ALLEGRO_KEYBOARD_STATE keyboard;
|
||||
al_get_keyboard_state(&keyboard);
|
||||
if (al_key_down(&keyboard, ALLEGRO_KEY_LEFT)) {
|
||||
game->level.speed_modifier = 0.75;
|
||||
data->speed_modifier = 0.75;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -222,43 +231,36 @@ inline int Dodger_PreloadSteps(void) {
|
|||
return 7;
|
||||
}
|
||||
|
||||
void Dodger_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) {
|
||||
PROGRESS_INIT(Dodger_PreloadSteps());
|
||||
game->level.dodger.obst_bmps.pie1 = LoadScaledBitmap("levels/dodger/pie1.png", game->viewportHeight*1.6*0.1, game->viewportHeight*0.08);
|
||||
PROGRESS;
|
||||
game->level.dodger.obst_bmps.pie2 = LoadScaledBitmap("levels/dodger/pie2.png", game->viewportHeight*1.6*0.1, game->viewportHeight*0.08);
|
||||
PROGRESS;
|
||||
game->level.dodger.obst_bmps.pig = LoadScaledBitmap("levels/dodger/pig.png", (int)(game->viewportHeight*1.6*0.15)*3, (int)(game->viewportHeight*0.2)*3);
|
||||
PROGRESS;
|
||||
game->level.dodger.obst_bmps.screwball = LoadScaledBitmap("levels/dodger/screwball.png", (int)(game->viewportHeight*0.2)*4*1.4, (int)(game->viewportHeight*0.2)*4);
|
||||
PROGRESS;
|
||||
game->level.dodger.obst_bmps.muffin = LoadScaledBitmap("levels/dodger/muffin.png", game->viewportHeight*1.6*0.07, game->viewportHeight*0.1);
|
||||
PROGRESS;
|
||||
game->level.dodger.obst_bmps.cherry = LoadScaledBitmap("levels/dodger/cherry.png", game->viewportHeight*1.6*0.03, game->viewportHeight*0.08);
|
||||
PROGRESS;
|
||||
game->level.dodger.obst_bmps.badmuffin = LoadScaledBitmap("levels/dodger/badmuffin.png", game->viewportHeight*1.6*0.07, game->viewportHeight*0.1);
|
||||
PROGRESS;
|
||||
void Dodger_PreloadBitmaps(struct Game *game, struct Dodger* data, void (*progress)(struct Game*, float)) {
|
||||
//PROGRESS_INIT(Dodger_PreloadSteps());
|
||||
data->dodger.obst_bmps.pie1 = LoadScaledBitmap(game, "levels/dodger/pie1.png", game->viewport.height*1.6*0.1, game->viewport.height*0.08);
|
||||
|
||||
data->dodger.obst_bmps.pie2 = LoadScaledBitmap(game, "levels/dodger/pie2.png", game->viewport.height*1.6*0.1, game->viewport.height*0.08);
|
||||
|
||||
data->dodger.obst_bmps.pig = LoadScaledBitmap(game, "levels/dodger/pig.png", (int)(game->viewport.height*1.6*0.15)*3, (int)(game->viewport.height*0.2)*3);
|
||||
|
||||
data->dodger.obst_bmps.screwball = LoadScaledBitmap(game, "levels/dodger/screwball.png", (int)(game->viewport.height*0.2)*4*1.4, (int)(game->viewport.height*0.2)*4);
|
||||
|
||||
data->dodger.obst_bmps.muffin = LoadScaledBitmap(game, "levels/dodger/muffin.png", game->viewport.height*1.6*0.07, game->viewport.height*0.1);
|
||||
|
||||
data->dodger.obst_bmps.cherry = LoadScaledBitmap(game, "levels/dodger/cherry.png", game->viewport.height*1.6*0.03, game->viewport.height*0.08);
|
||||
|
||||
data->dodger.obst_bmps.badmuffin = LoadScaledBitmap(game, "levels/dodger/badmuffin.png", game->viewport.height*1.6*0.07, game->viewport.height*0.1);
|
||||
|
||||
}
|
||||
|
||||
void Dodger_Preload(struct Game *game) {
|
||||
RegisterDerpySpritesheet(game, "walk");
|
||||
RegisterDerpySpritesheet(game, "stand");
|
||||
RegisterDerpySpritesheet(game, "fly");
|
||||
RegisterDerpySpritesheet(game, "run");
|
||||
void Dodger_UnloadBitmaps(struct Game *game, struct Dodger* data) {
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.pie1);
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.pie2);
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.pig);
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.cherry);
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.muffin);
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.badmuffin);
|
||||
al_destroy_bitmap(data->dodger.obst_bmps.screwball);
|
||||
}
|
||||
|
||||
void Dodger_UnloadBitmaps(struct Game *game) {
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.pie1);
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.pie2);
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.pig);
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.cherry);
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.muffin);
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.badmuffin);
|
||||
al_destroy_bitmap(game->level.dodger.obst_bmps.screwball);
|
||||
}
|
||||
|
||||
void Dodger_Unload(struct Game *game) {
|
||||
struct Obstacle *t = game->level.dodger.obstacles;
|
||||
void Dodger_Unload(struct Game *game, struct Dodger* data) {
|
||||
struct Obstacle *t = data->dodger.obstacles;
|
||||
if (t) {
|
||||
while (t->next) {
|
||||
if (t->prev) free(t->prev);
|
||||
|
@ -266,14 +268,16 @@ void Dodger_Unload(struct Game *game) {
|
|||
}
|
||||
free(t);
|
||||
}
|
||||
struct Spritesheet *tmp, *s = game->level.derpy_sheets;
|
||||
struct Spritesheet *tmp, *s = data->derpy_sheets;
|
||||
tmp = s;
|
||||
while (s) {
|
||||
tmp = s;
|
||||
s = s->next;
|
||||
free(tmp);
|
||||
}
|
||||
DestroyCharacter(game, data->character);
|
||||
free(data);
|
||||
}
|
||||
|
||||
void Dodger_Resume(struct Game *game) {}
|
||||
void Dodger_Pause(struct Game *game) {}
|
||||
void Dodger_Resume(struct Game *game, struct Dodger* data) {}
|
||||
void Dodger_Pause(struct Game *game, struct Dodger* data) {}
|
||||
|
|
|
@ -20,15 +20,104 @@
|
|||
*/
|
||||
#include "../../main.h"
|
||||
|
||||
void Dodger_Draw(struct Game *game);
|
||||
void Dodger_Logic(struct Game *game);
|
||||
void Dodger_Preload(struct Game *game);
|
||||
void Dodger_Unload(struct Game *game);
|
||||
void Dodger_Load(struct Game *game);
|
||||
void Dodger_Keydown(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Dodger_UnloadBitmaps(struct Game *game);
|
||||
void Dodger_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float));
|
||||
void Dodger_ProcessEvent(struct Game *game, ALLEGRO_EVENT *ev);
|
||||
void Dodger_Resume(struct Game *game);
|
||||
void Dodger_Pause(struct Game *game);
|
||||
inline int Dodger_PreloadSteps(void);
|
||||
struct Dodger {
|
||||
|
||||
struct Character *character; /* TODO: move to level */
|
||||
|
||||
struct {
|
||||
struct {
|
||||
ALLEGRO_BITMAP *pie1; /*!< Pie bitmap. */
|
||||
ALLEGRO_BITMAP *pie2; /*!< Pie bitmap (crossed). */
|
||||
ALLEGRO_BITMAP *muffin; /*!< Good muffin bitmap. */
|
||||
ALLEGRO_BITMAP *badmuffin; /*!< Bad muffin bitmap. */
|
||||
ALLEGRO_BITMAP *cherry; /*!< Cherry bitmap. */
|
||||
ALLEGRO_BITMAP *pig; /*!< Pig spritesheet bitmap. */
|
||||
ALLEGRO_BITMAP *screwball; /*!< Screwball spritesheet bitmap. */
|
||||
} obst_bmps; /*!< Obstacle bitmaps. */
|
||||
struct Obstacle *obstacles; /*!< List of obstacles being currently rendered. */
|
||||
} dodger;
|
||||
|
||||
|
||||
struct {
|
||||
int current_level; /*!< Level number. */
|
||||
} input; /*!< Gamestate input data. */
|
||||
int current_level; /*!< Level number. */
|
||||
float speed; /*!< Speed of the player. */
|
||||
float speed_modifier; /*!< Modifier of the speed of the player. */
|
||||
float bg_pos; /*!< Position of the background layer of the scene. */
|
||||
float st_pos; /*!< Position of the stage layer of the scene. */
|
||||
float fg_pos; /*!< Position of the foreground layer of the scene. */
|
||||
float cl_pos; /*!< Position of the clouds layer of the scene. */
|
||||
float derpy_x; /*!< Horizontal position of Derpy (0-1). */
|
||||
float derpy_y; /*!< Vertical position of Derpy (0-1). */
|
||||
float derpy_angle; /*!< Angle of Derpy sprite on screen (radians). */
|
||||
float hp; /*!< Player health points (0-1). */
|
||||
bool handle_input; /*!< When false, player looses control over Derpy. */
|
||||
bool failed; /*!< Indicates if player failed level. */
|
||||
bool unloading; /*!< Indicated if level is already being unloaded. */
|
||||
float meter_alpha; /*!< Alpha level of HP meter. */
|
||||
int sheet_rows; /*!< Number of rows in current spritesheet. */
|
||||
int sheet_cols; /*!< Number of cols in current spritesheet. */
|
||||
int sheet_pos; /*!< Frame position in current spritesheet. */
|
||||
int sheet_blanks; /*!< Number of blank frames at the end of current spritesheet. */
|
||||
char* sheet_successor; /*!< Successor of current animation. If blank, then it's looped. */
|
||||
float sheet_tmp; /*!< Temporary counter used to slow down spritesheet animation. */
|
||||
float sheet_speed; /*!< Current speed of Derpy animation. */
|
||||
float sheet_speed_modifier; /*!< Modifier of speed, specified by current spritesheet. */
|
||||
float sheet_scale; /*!< Scale modifier of current spritesheet. */
|
||||
ALLEGRO_FONT *letter_font; /*!< Font used in letter from Twilight on first level. */
|
||||
ALLEGRO_SAMPLE *sample; /*!< Sample with background music. */
|
||||
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
|
||||
unsigned int music_pos; /*!< Position of sample instance. Used when pausing game. */
|
||||
ALLEGRO_BITMAP *background; /*!< Bitmap of the background layer of the scene. */
|
||||
ALLEGRO_BITMAP *stage; /*!< Bitmap of the stage layer of the scene. */
|
||||
ALLEGRO_BITMAP *foreground; /*!< Bitmap of the foreground layer of the scene. */
|
||||
ALLEGRO_BITMAP *clouds; /*!< Bitmap of the clouds layer of the scene. */
|
||||
ALLEGRO_BITMAP *welcome; /*!< Bitmap of the welcome text (for instance "Level 1: Fluttershy"). */
|
||||
ALLEGRO_BITMAP **derpy_sheet; /*!< Pointer to active Derpy sprite sheet. */
|
||||
ALLEGRO_BITMAP *derpy; /*!< Derpy sprite. */
|
||||
ALLEGRO_BITMAP *meter_bmp; /*!< Bitmap of the HP meter. */
|
||||
ALLEGRO_BITMAP *meter_image; /*!< Derpy image used in the HP meter. */
|
||||
ALLEGRO_BITMAP *letter; /*!< Bitmap with letter from Twilight. */
|
||||
bool debug_show_sprite_frames; /*!< When true, displays colorful borders around spritesheets and their active areas. */
|
||||
struct Spritesheet* derpy_sheets; /*!< List of spritesheets of Derpy character. */
|
||||
//struct Spritesheet* pony_sheets; /*!< List of spritesheets of character rescued by Derpy. */
|
||||
struct {
|
||||
ALLEGRO_BITMAP *owl; /*!< Owlicious bitmap. */
|
||||
} level1; /*!< Resources used by level 1. */
|
||||
};
|
||||
|
||||
/*! \brief Structure representing obstacles and power-ups flying through the level. */
|
||||
struct Obstacle {
|
||||
ALLEGRO_BITMAP **bitmap; /*!< Pointer to bitmap used by obstacle. */
|
||||
float x; /*!< Horizontal position on the screen, in range 0-100. */
|
||||
float y; /*!< Vertical position on the screen, in range 0-100. */
|
||||
float speed; /*!< Horizontal speed of obstracle. */
|
||||
float angle; /*!< Angle of bitmap rotation in radians. */
|
||||
int points; /*!< Number of points given when hit by player. Positive gives HP to power, negative takes it. */
|
||||
bool hit; /*!< Indicates if this obstacle was already hit by the player or not. */
|
||||
|
||||
int cols; /*!< Number of columns in spritesheet. */
|
||||
int rows; /*!< Number of rows in spritesheet. */
|
||||
int pos; /*!< Current position in spritesheet. */
|
||||
int blanks; /*!< Number of blank frames at the end of the spritesheet. */
|
||||
float tmp_pos; /*!< Temporary counter used to slow down spritesheet animation. */
|
||||
float anim_speed; /*!< Speed of spritesheet animation. */
|
||||
|
||||
void (*callback)(struct Game*, struct Obstacle*); /*!< Pointer to function called to update obstacle position, animate it, etc. */
|
||||
void *data; /*!< Pointer passed to callback function. */
|
||||
struct Obstacle *prev; /*!< Previous obstacle on the list. */
|
||||
struct Obstacle *next; /*!< Next obstacle on the list. */
|
||||
};
|
||||
|
||||
void Dodger_Draw(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Logic(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Start(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Stop(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Unload(struct Game *game, struct Dodger *data);
|
||||
struct Dodger* Dodger_Load(struct Game *game, int current_level);
|
||||
void Dodger_UnloadBitmaps(struct Game *game, struct Dodger *data);
|
||||
void Dodger_LoadBitmaps(struct Game *game, struct Dodger *data, void (*progress)(struct Game*, float));
|
||||
void Dodger_ProcessEvent(struct Game *game, struct Dodger *data, ALLEGRO_EVENT *ev);
|
||||
void Dodger_Resume(struct Game *game, struct Dodger *data);
|
||||
void Dodger_Pause(struct Game *game, struct Dodger *data);
|
||||
|
|
|
@ -244,7 +244,7 @@ int main(int argc, char **argv){
|
|||
return -1;
|
||||
}
|
||||
|
||||
game.audio.v = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_INT16, ALLEGRO_CHANNEL_CONF_2);
|
||||
game.audio.v = al_create_voice(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game.audio.mixer = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game.audio.fx = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
game.audio.music = al_create_mixer(44100, ALLEGRO_AUDIO_DEPTH_FLOAT32, ALLEGRO_CHANNEL_CONF_2);
|
||||
|
|
|
@ -172,7 +172,7 @@ void FatalError(struct Game *game, bool fatal, char* format, ...) {
|
|||
printf("%s\n", text);
|
||||
if (!game->_priv.font_console) exit(1);
|
||||
} else {
|
||||
PrintConsole(game, "Fatal Error, displaying BSOD...");
|
||||
PrintConsole(game, "Fatal Error, displaying Blue Screen of Derp...");
|
||||
va_list vl;
|
||||
va_start(vl, format);
|
||||
vsnprintf(text, 1024, format, vl);
|
||||
|
|
Loading…
Add table
Reference in a new issue