indentation fixes

This commit is contained in:
Sebastian Krzyszkowiak 2012-09-03 02:25:32 +02:00
parent 8420a5ca92
commit 4bbbd1958f
15 changed files with 715 additions and 715 deletions

View file

@ -74,7 +74,7 @@ void About_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
game->about.letter = LoadScaledBitmap("about/letter.png", game->viewportHeight*1.3, game->viewportHeight*1.3 );
PROGRESS;
game->about.sample = al_load_sample( GetDataFilePath("about/about.flac") );
game->about.sample = al_load_sample( GetDataFilePath("about/about.flac") );
PROGRESS;
game->about.music = al_create_sample_instance(game->about.sample);
@ -82,7 +82,7 @@ void About_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
al_set_sample_instance_playmode(game->about.music, ALLEGRO_PLAYMODE_LOOP);
al_set_sample_instance_position(game->about.music, game->music ? 420000 : 700000);
game->about.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.035,0 );
game->about.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.035,0 );
PROGRESS;
game->about.x = -0.1;
if (!game->about.sample){
@ -117,13 +117,13 @@ void About_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
draw_text(" Princess Celestia");
draw_text(" - Meredith Sims (Emichwan88)");
draw_text(" http://www.youtube.com/Emichwan88");
draw_text(" Fluttershy");
draw_text(" Fluttershy");
draw_text(" Twilight Sparkle");
/*draw_text(" - Hnilmik");
draw_text(" Rarity");
draw_text(" - Karen VO");
draw_text(" Applejack");*/
/* draw_text(" - Erica Mendez");
/* draw_text(" - Erica Mendez");
draw_text(" Rainbow Dash");
draw_text(" - Emily Fajardo");
draw_text(" Pinkie Pie");*/

View file

@ -27,7 +27,7 @@ void al_draw_vertical_gradient_rect(float x, float y, float w, float h, ALLEGRO_
{.x = x + w, .y = y, .z = 0, .color = top},
{.x = x, .y = y + h, .z = 0, .color = bottom},
{.x = x + w, .y = y + h, .z = 0, .color = bottom}};
al_draw_prim(v, NULL, NULL, 0, 4, ALLEGRO_PRIM_TRIANGLE_STRIP);
al_draw_prim(v, NULL, NULL, 0, 4, ALLEGRO_PRIM_TRIANGLE_STRIP);
}
void al_draw_horizontal_gradient_rect(float x, float y, float w, float h, ALLEGRO_COLOR left, ALLEGRO_COLOR right) {
@ -36,7 +36,7 @@ void al_draw_horizontal_gradient_rect(float x, float y, float w, float h, ALLEGR
{.x = x + w, .y = y, .z = 0, .color = right},
{.x = x, .y = y + h, .z = 0, .color = left},
{.x = x + w, .y = y + h, .z = 0, .color = right}};
al_draw_prim(v, NULL, NULL, 0, 4, ALLEGRO_PRIM_TRIANGLE_STRIP);
al_draw_prim(v, NULL, NULL, 0, 4, ALLEGRO_PRIM_TRIANGLE_STRIP);
}
void al_draw_text_with_shadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text) {

View file

@ -24,13 +24,13 @@
ALLEGRO_CONFIG *config;
void InitConfig() {
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
ALLEGRO_PATH *data = al_create_path("SuperDerpy.ini");
al_join_paths(path, data);
config = al_load_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
ALLEGRO_PATH *data = al_create_path("SuperDerpy.ini");
al_join_paths(path, data);
config = al_load_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
if (!config) config=al_create_config();
al_destroy_path(path);
al_destroy_path(data);
al_destroy_path(path);
al_destroy_path(data);
}
void SetConfigOption(char* section, char* name, char* value) {
@ -47,12 +47,12 @@ const char* GetConfigOptionDefault(char* section, char* name, const char* def) {
}
void DeinitConfig() {
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
ALLEGRO_PATH *data = al_create_path("SuperDerpy.ini");
al_make_directory(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
al_join_paths(path, data);
al_save_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), config);
al_destroy_path(path);
al_destroy_path(data);
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_USER_SETTINGS_PATH);
ALLEGRO_PATH *data = al_create_path("SuperDerpy.ini");
al_make_directory(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
al_join_paths(path, data);
al_save_config_file(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP), config);
al_destroy_path(path);
al_destroy_path(data);
al_destroy_config(config);
}

View file

@ -24,56 +24,56 @@
#include "about.h"
void Disclaimer_Draw(struct Game *game) {
al_clear_to_color(al_map_rgb(0,0,0));
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.3, ALLEGRO_ALIGN_CENTRE, "This is an early development preview of the game.");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.4, ALLEGRO_ALIGN_CENTRE, "It's not supposed to be complete!");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, "Keep in mind that everything may be changed");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, "and many things surely will change.");
al_draw_text_with_shadow(game->menu.font, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.9, ALLEGRO_ALIGN_CENTRE, "Press any key to continue...");
al_clear_to_color(al_map_rgb(0,0,0));
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.3, ALLEGRO_ALIGN_CENTRE, "This is an early development preview of the game.");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.4, ALLEGRO_ALIGN_CENTRE, "It's not supposed to be complete!");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.5, ALLEGRO_ALIGN_CENTRE, "Keep in mind that everything may be changed");
al_draw_text_with_shadow(game->menu.font_selected, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.6, ALLEGRO_ALIGN_CENTRE, "and many things surely will change.");
al_draw_text_with_shadow(game->menu.font, al_map_rgb(255,255,255), game->viewportWidth/2, game->viewportHeight*0.9, ALLEGRO_ALIGN_CENTRE, "Press any key to continue...");
}
void Disclaimer_Load(struct Game *game) {
ALLEGRO_EVENT ev;
float fadeloop;
for (fadeloop=255; fadeloop>0; fadeloop-=tps(game, 600)) {
al_wait_for_event(game->event_queue, &ev);
Disclaimer_Draw(game);
al_draw_filled_rectangle(0,0,game->viewportWidth,game->viewportHeight,al_map_rgba(0,0,0,fadeloop));
DrawConsole(game);
al_flip_display();
}
Disclaimer_Draw(game);
ALLEGRO_EVENT ev;
float fadeloop;
for (fadeloop=255; fadeloop>0; fadeloop-=tps(game, 600)) {
al_wait_for_event(game->event_queue, &ev);
Disclaimer_Draw(game);
al_draw_filled_rectangle(0,0,game->viewportWidth,game->viewportHeight,al_map_rgba(0,0,0,fadeloop));
DrawConsole(game);
al_flip_display();
}
Disclaimer_Draw(game);
}
int Disclaimer_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
UnloadGameState(game);
game->loadstate = GAMESTATE_INTRO;
LoadGameState(game);
UnloadGameState(game);
game->loadstate = GAMESTATE_INTRO;
LoadGameState(game);
return 0;
}
void Disclaimer_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
if (!game->menu.loaded) {
game->menu.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.05,0 );
game->menu.font_selected = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.065,0 );
}
PrintConsole(game, "Preloading GAMESTATE_INTRO...");
Intro_Preload(game, progress);
if (!game->menu.loaded) {
game->menu.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.05,0 );
game->menu.font_selected = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.065,0 );
}
PrintConsole(game, "Preloading GAMESTATE_INTRO...");
Intro_Preload(game, progress);
}
void Disclaimer_Unload(struct Game *game) {
ALLEGRO_EVENT ev;
float fadeloop;
for (fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)) {
al_wait_for_event(game->event_queue, &ev);
Disclaimer_Draw(game);
al_draw_filled_rectangle(0,0,game->viewportWidth,game->viewportHeight,al_map_rgba(0,0,0,fadeloop));
DrawConsole(game);
al_flip_display();
}
if (!game->menu.loaded) {
al_destroy_font(game->menu.font);
al_destroy_font(game->menu.font_selected);
}
al_clear_to_color(al_map_rgb(0,0,0));
ALLEGRO_EVENT ev;
float fadeloop;
for (fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)) {
al_wait_for_event(game->event_queue, &ev);
Disclaimer_Draw(game);
al_draw_filled_rectangle(0,0,game->viewportWidth,game->viewportHeight,al_map_rgba(0,0,0,fadeloop));
DrawConsole(game);
al_flip_display();
}
if (!game->menu.loaded) {
al_destroy_font(game->menu.font);
al_destroy_font(game->menu.font_selected);
}
al_clear_to_color(al_map_rgb(0,0,0));
}

View file

@ -24,13 +24,13 @@
#include "map.h"
void AnimPage(struct Game *game, int page, ALLEGRO_COLOR tint) {
int offset = 0;
int offset = 0;
if (game->intro.in_animation) offset = -1*game->viewportWidth + (cos(((-1*((game->intro.position)%game->viewportWidth))/(float)game->viewportWidth)*(ALLEGRO_PI))/2.0)*game->viewportWidth + game->viewportWidth/2.0;
int amount1 = 2, amount2 = 2;
float anim = game->intro.anim;
if (page==2) { amount1=4; amount2=3; }
if (page==2) { amount1=4; amount2=3; }
if (page==3) { amount1=3; amount2=3; }
if (page==5) { amount1=5; amount2=3; anim*=2; }
@ -38,7 +38,7 @@ void AnimPage(struct Game *game, int page, ALLEGRO_COLOR tint) {
amount1 = 2;
amount2 = 2;
if (page==1) { amount1=4; amount2=3; }
if (page==1) { amount1=4; amount2=3; }
if (page==2) { amount1=3; amount2=3; }
if (page==4) { amount1=5; amount2=3; anim*=2; }
@ -49,9 +49,9 @@ void AnimPage(struct Game *game, int page, ALLEGRO_COLOR tint) {
void FillPage(struct Game *game, int page) {
char filename[30] = { };
sprintf(filename, "intro/%d.flac", page);
sprintf(filename, "intro/%d.flac", page);
game->intro.audiostream = al_load_audio_stream(GetDataFilePath(filename), 4, 1024);
game->intro.audiostream = al_load_audio_stream(GetDataFilePath(filename), 4, 1024);
al_attach_audio_stream_to_mixer(game->intro.audiostream, game->audio.voice);
al_set_audio_stream_playing(game->intro.audiostream, false);
al_set_audio_stream_gain(game->intro.audiostream, 1.75);
@ -240,7 +240,7 @@ void Intro_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
game->intro.frame =LoadScaledBitmap("intro/frame.png", game->viewportWidth, game->viewportHeight);
PROGRESS;
game->intro.sample = al_load_sample( GetDataFilePath("intro/intro.flac") );
game->intro.sample = al_load_sample( GetDataFilePath("intro/intro.flac") );
PROGRESS;
game->intro.music = al_create_sample_instance(game->intro.sample);
@ -254,7 +254,7 @@ void Intro_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
}
game->intro.table = al_create_bitmap(game->viewportWidth*2, game->viewportHeight);
game->intro.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.04,0 );
game->intro.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.04,0 );
FillPage(game, 1);
PROGRESS;
@ -269,7 +269,7 @@ void Intro_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
}
void Intro_Unload(struct Game *game) {
if (game->intro.audiostream) {
if (game->intro.audiostream) {
al_set_audio_stream_playing(game->intro.audiostream, false);
al_destroy_audio_stream(game->intro.audiostream);
}

View file

@ -58,8 +58,8 @@ void SelectDerpySpritesheet(struct Game *game, char* name) {
void RegisterDerpySpritesheet(struct Game *game, char* name) {
char filename[255] = { };
sprintf(filename, "levels/derpy/%s.ini", name);
ALLEGRO_CONFIG *config = al_load_config_file(GetDataFilePath(filename));
sprintf(filename, "levels/derpy/%s.ini", name);
ALLEGRO_CONFIG *config = al_load_config_file(GetDataFilePath(filename));
struct Spritesheet *s = malloc(sizeof(struct Spritesheet));
s->name = malloc((strlen(name)+1)*sizeof(char));
strcpy(s->name, name);
@ -159,10 +159,10 @@ void Level_Draw(struct Game *game) {
}
if (x > -w) {
/*if (!tmp->hit)*/
if ((((x>=derpyx+0.38*derpyw+derpyo) && (x<=derpyx+0.94*derpyw+derpyo)) || ((x+w>=derpyx+0.38*derpyw+derpyo) && (x+w<=derpyx+0.94*derpyw+derpyo)) || ((x<=derpyx+0.38*derpyw+derpyo) && (x+w>=derpyx+0.94*derpyw+derpyo))) &&
if ((((x>=derpyx+0.38*derpyw+derpyo) && (x<=derpyx+0.94*derpyw+derpyo)) || ((x+w>=derpyx+0.38*derpyw+derpyo) && (x+w<=derpyx+0.94*derpyw+derpyo)) || ((x<=derpyx+0.38*derpyw+derpyo) && (x+w>=derpyx+0.94*derpyw+derpyo))) &&
(((y>=derpyy+0.26*derpyh) && (y<=derpyy+0.76*derpyh)) || ((y+h>=derpyy+0.26*derpyh) && (y+h<=derpyy+0.76*derpyh)) || ((y<=derpyy+0.26*derpyh) && (y+h>=derpyy+0.76*derpyh)))) {
tmp->hit=true;
}
tmp->hit=true;
}
if (tmp->bitmap) {
ALLEGRO_BITMAP* subbitmap = al_create_sub_bitmap(*(tmp->bitmap),w*(tmp->pos%tmp->cols), h*(tmp->pos/tmp->cols),w,h);
@ -227,7 +227,7 @@ void Level_Draw(struct Game *game) {
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->viewportWidth*0.1953125, derpyy + al_get_bitmap_height(game->level.derpy)/2, game->level.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))) &&
/* 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) {
@ -399,7 +399,7 @@ void Level_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
RegisterDerpySpritesheet(game, "stand");
if (game->level.current_level!=1) Moonwalk_Preload(game);
else {
game->level.sample = al_load_sample( GetDataFilePath("levels/1/music.flac") );
game->level.sample = al_load_sample( GetDataFilePath("levels/1/music.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);
@ -518,7 +518,7 @@ void Level_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, floa
PROGRESS;
game->level.owl = LoadScaledBitmap("levels/owl.png", game->viewportWidth*0.08, game->viewportWidth*0.08);
PROGRESS;
game->level.letter_font = al_load_ttf_font(GetDataFilePath("DejaVuSans.ttf"),game->viewportHeight*0.0225,0 );
game->level.letter_font = al_load_ttf_font(GetDataFilePath("DejaVuSans.ttf"),game->viewportHeight*0.0225,0 );
PROGRESS;
game->level.letter = LoadScaledBitmap("levels/letter.png", game->viewportHeight*1.3, game->viewportHeight*1.2);
al_set_target_bitmap(game->level.letter);

View file

@ -24,321 +24,321 @@
#include "../level.h"
bool LevelFailed(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_INIT) {
TM_AddBackgroundAction(&FadeOut, NULL, 3000, "fadeout");
} else if (state == TM_ACTIONSTATE_RUNNING) {
al_draw_filled_rectangle(0, 0, game->viewportWidth, game->viewportHeight, al_map_rgba(0,0,0,100));
al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.4, ALLEGRO_ALIGN_CENTRE, "Failed!");
game->level.speed-=0.00001;
return false;
}
return true;
if (state == TM_ACTIONSTATE_INIT) {
TM_AddBackgroundAction(&FadeOut, NULL, 3000, "fadeout");
} else if (state == TM_ACTIONSTATE_RUNNING) {
al_draw_filled_rectangle(0, 0, game->viewportWidth, game->viewportHeight, al_map_rgba(0,0,0,100));
al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.4, ALLEGRO_ALIGN_CENTRE, "Failed!");
game->level.speed-=0.00001;
return false;
}
return true;
}
bool Accelerate(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.speed+=0.000015;
if (game->level.speed<0.0025) return false;
return true;
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.speed+=0.000015;
if (game->level.speed<0.0025) return false;
return true;
}
bool Walk(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!(action->arguments)) SelectDerpySpritesheet(game, "walk");
action->arguments++;
game->level.derpy_x+=tps(game, 60*0.001);
if (game->level.derpy_x<0.05) return false;
return true;
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!(action->arguments)) SelectDerpySpritesheet(game, "walk");
action->arguments++;
game->level.derpy_x+=tps(game, 60*0.001);
if (game->level.derpy_x<0.05) return false;
return true;
}
bool Move(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.speed=0.00035;
if (game->level.st_pos<0.275) return false;
return true;
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.speed=0.00035;
if (game->level.st_pos<0.275) return false;
return true;
}
bool ShowMeter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.meter_alpha+=tps(game, 60*4);
if (game->level.meter_alpha>=255) {
game->level.meter_alpha=255;
return true;
}
return false;
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.meter_alpha+=tps(game, 60*4);
if (game->level.meter_alpha>=255) {
game->level.meter_alpha=255;
return true;
}
return false;
}
bool Fly(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!(action->arguments)) {
SelectDerpySpritesheet(game, "fly");
game->level.derpy_angle = tps(game, 60*-0.15);
/*game->level.gg = true;*/
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
action->arguments++;
}
game->level.derpy_y-=tps(game, 60*0.004);
if (game->level.derpy_y>0.2) return false;
game->level.handle_input=true;
return true;
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!(action->arguments)) {
SelectDerpySpritesheet(game, "fly");
game->level.derpy_angle = tps(game, 60*-0.15);
/*game->level.gg = true;*/
TM_AddBackgroundAction(&ShowMeter, NULL, 0, "showmeter");
action->arguments++;
}
game->level.derpy_y-=tps(game, 60*0.004);
if (game->level.derpy_y>0.2) return false;
game->level.handle_input=true;
return true;
}
bool Run(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!(action->arguments)) {
game->level.handle_input=false;
game->level.speed_modifier=1;
action->arguments++;
}
game->level.derpy_y+=tps(game, 60*0.0042);
if (game->level.derpy_angle > 0) { game->level.derpy_angle -= tps(game, 60*0.02); if (game->level.derpy_angle < 0) game->level.derpy_angle = 0; }
if (game->level.derpy_angle < 0) { game->level.derpy_angle += tps(game, 60*0.02); if (game->level.derpy_angle > 0) game->level.derpy_angle = 0; }
if (game->level.derpy_y<0.65) return false;
game->level.derpy_angle = 0;
SelectDerpySpritesheet(game, "run");
return true;
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!(action->arguments)) {
game->level.handle_input=false;
game->level.speed_modifier=1;
action->arguments++;
}
game->level.derpy_y+=tps(game, 60*0.0042);
if (game->level.derpy_angle > 0) { game->level.derpy_angle -= tps(game, 60*0.02); if (game->level.derpy_angle < 0) game->level.derpy_angle = 0; }
if (game->level.derpy_angle < 0) { game->level.derpy_angle += tps(game, 60*0.02); if (game->level.derpy_angle > 0) game->level.derpy_angle = 0; }
if (game->level.derpy_y<0.65) return false;
game->level.derpy_angle = 0;
SelectDerpySpritesheet(game, "run");
return true;
}
bool GenerateObstacles(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
/*float* tmp; bool* in;*/
int* count;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
/* action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(bool))); */
}
count = (int*)action->arguments->value;
/*tmp = (float*)action->arguments->value;
in = (bool*)action->arguments->next->value;*/
if (state == TM_ACTIONSTATE_INIT) {
*count = 0;
/* *tmp = 0;
*in = true;*/
}
else if (state == TM_ACTIONSTATE_RUNNING) {
if (rand()%(10000/(int)tps(game, 60*85*game->level.speed_modifier))<=3) {
PrintConsole(game, "OBSTACLE %d", *count);
(*count)++;
struct Obstacle *obst = malloc(sizeof(struct Obstacle));
obst->prev = NULL;
obst->x = 100;
obst->y = (rand()%91)-1;
obst->speed = 1;
obst->points = -10;
obst->hit = false;
obst->rows = 1;
obst->cols = 1;
obst->pos = 0;
obst->blanks = 0;
obst->anim_speed = 0;
obst->tmp_pos = 0;
obst->angle = 0;
if (rand()%100<=50) {
obst->callback= NULL;
obst->data = NULL;
obst->points = -5;
obst->bitmap = &(game->level.obst_bmps.badmuffin);
} else if (rand()%100<=12) {
obst->callback= &Obst_RotateSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->points = 8;
obst->bitmap = &(game->level.obst_bmps.muffin);
} else if (rand()%100<=12) {
obst->callback= &Obst_RotateSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->points = 4;
obst->bitmap = &(game->level.obst_bmps.cherry);
} else if (rand()%100<=65) {
obst->callback= &Obst_MoveUp;
if (rand()%100<=80) obst->bitmap = &(game->level.obst_bmps.pie1);
else {
obst->bitmap = &(game->level.obst_bmps.pie2);
obst->points = -12;
}
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0.25+(rand()%50/100.0);
obst->y*=1.8;
obst->angle = ((rand()%50)/100.0)-0.25;
} else if (rand()%100<=80) {
obst->callback = &Obst_MoveSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->bitmap = &(game->level.obst_bmps.pig);
obst->rows = 3;
obst->cols = 3;
obst->speed = 1.2;
obst->anim_speed = 2;
obst->points = -20;
} else {
obst->callback = &Obst_MoveUpDown;
obst->bitmap = &(game->level.obst_bmps.screwball);
obst->data = (void*)(rand()%2);
obst->rows = 4;
obst->cols = 4;
obst->speed = 1.1;
obst->anim_speed = 2;
obst->points = -25;
}
if (game->level.obstacles) {
game->level.obstacles->prev = obst;
obst->next = game->level.obstacles;
} else {
obst->next = NULL;
}
game->level.obstacles = obst;
if (*count > 128) return true;
}
} else {
free(action->arguments->value);
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
}
return false;
/*float* tmp; bool* in;*/
int* count;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(int)));
/* action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(bool))); */
}
count = (int*)action->arguments->value;
/*tmp = (float*)action->arguments->value;
in = (bool*)action->arguments->next->value;*/
if (state == TM_ACTIONSTATE_INIT) {
*count = 0;
/* *tmp = 0;
*in = true;*/
}
else if (state == TM_ACTIONSTATE_RUNNING) {
if (rand()%(10000/(int)tps(game, 60*85*game->level.speed_modifier))<=3) {
PrintConsole(game, "OBSTACLE %d", *count);
(*count)++;
struct Obstacle *obst = malloc(sizeof(struct Obstacle));
obst->prev = NULL;
obst->x = 100;
obst->y = (rand()%91)-1;
obst->speed = 1;
obst->points = -10;
obst->hit = false;
obst->rows = 1;
obst->cols = 1;
obst->pos = 0;
obst->blanks = 0;
obst->anim_speed = 0;
obst->tmp_pos = 0;
obst->angle = 0;
if (rand()%100<=50) {
obst->callback= NULL;
obst->data = NULL;
obst->points = -5;
obst->bitmap = &(game->level.obst_bmps.badmuffin);
} else if (rand()%100<=12) {
obst->callback= &Obst_RotateSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->points = 8;
obst->bitmap = &(game->level.obst_bmps.muffin);
} else if (rand()%100<=12) {
obst->callback= &Obst_RotateSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->points = 4;
obst->bitmap = &(game->level.obst_bmps.cherry);
} else if (rand()%100<=65) {
obst->callback= &Obst_MoveUp;
if (rand()%100<=80) obst->bitmap = &(game->level.obst_bmps.pie1);
else {
obst->bitmap = &(game->level.obst_bmps.pie2);
obst->points = -12;
}
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0.25+(rand()%50/100.0);
obst->y*=1.8;
obst->angle = ((rand()%50)/100.0)-0.25;
} else if (rand()%100<=80) {
obst->callback = &Obst_MoveSin;
obst->data = malloc(sizeof(float));
*((float*)obst->data) = 0;
obst->bitmap = &(game->level.obst_bmps.pig);
obst->rows = 3;
obst->cols = 3;
obst->speed = 1.2;
obst->anim_speed = 2;
obst->points = -20;
} else {
obst->callback = &Obst_MoveUpDown;
obst->bitmap = &(game->level.obst_bmps.screwball);
obst->data = (void*)(rand()%2);
obst->rows = 4;
obst->cols = 4;
obst->speed = 1.1;
obst->anim_speed = 2;
obst->points = -25;
}
if (game->level.obstacles) {
game->level.obstacles->prev = obst;
obst->next = game->level.obstacles;
} else {
obst->next = NULL;
}
game->level.obstacles = obst;
if (*count > 128) return true;
}
} else {
free(action->arguments->value);
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
}
return false;
}
bool Stop(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.speed=0;
SelectDerpySpritesheet(game, "stand");
return true;
if (state != TM_ACTIONSTATE_RUNNING) return false;
game->level.speed=0;
SelectDerpySpritesheet(game, "stand");
return true;
}
bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state == TM_ACTIONSTATE_DESTROY) {
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
al_set_audio_stream_playing(*stream, false);
al_destroy_audio_stream(*stream);
free(action->arguments->next->value);
free(action->arguments->value);
TM_DestroyArgs(action->arguments);
}
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
float* f = (float*)action->arguments->value;
*f = 0;
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(ALLEGRO_AUDIO_STREAM*)));
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
*stream = al_load_audio_stream(GetDataFilePath("levels/letter.flac"), 4, 1024);
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
al_set_audio_stream_playing(*stream, true);
al_set_audio_stream_gain(*stream, 2.00);
action->arguments->next->next = NULL;
}
float* f = (float*)action->arguments->value;
*f+=tps(game,350);
if (*f>255) *f=255;
al_draw_tinted_bitmap(game->level.letter, al_map_rgba(*f,*f,*f,*f), (game->viewportWidth-al_get_bitmap_width(game->level.letter))/2.0, al_get_bitmap_height(game->level.letter)*-0.05, 0);
struct ALLEGRO_KEYBOARD_STATE keyboard;
al_get_keyboard_state(&keyboard);
if (al_key_down(&keyboard, ALLEGRO_KEY_ENTER)) {
return true;
}
return false;
if (state == TM_ACTIONSTATE_INIT) action->arguments = NULL;
if (state == TM_ACTIONSTATE_DESTROY) {
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
al_set_audio_stream_playing(*stream, false);
al_destroy_audio_stream(*stream);
free(action->arguments->next->value);
free(action->arguments->value);
TM_DestroyArgs(action->arguments);
}
if (state != TM_ACTIONSTATE_RUNNING) return false;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
float* f = (float*)action->arguments->value;
*f = 0;
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(ALLEGRO_AUDIO_STREAM*)));
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
*stream = al_load_audio_stream(GetDataFilePath("levels/letter.flac"), 4, 1024);
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
al_set_audio_stream_playing(*stream, true);
al_set_audio_stream_gain(*stream, 2.00);
action->arguments->next->next = NULL;
}
float* f = (float*)action->arguments->value;
*f+=tps(game,350);
if (*f>255) *f=255;
al_draw_tinted_bitmap(game->level.letter, al_map_rgba(*f,*f,*f,*f), (game->viewportWidth-al_get_bitmap_width(game->level.letter))/2.0, al_get_bitmap_height(game->level.letter)*-0.05, 0);
struct ALLEGRO_KEYBOARD_STATE keyboard;
al_get_keyboard_state(&keyboard);
if (al_key_down(&keyboard, ALLEGRO_KEY_ENTER)) {
return true;
}
return false;
}
bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(game->viewportWidth, game->viewportHeight));
}
float* fadeloop;
ALLEGRO_BITMAP* fade_bitmap;
fadeloop = (float*)action->arguments->value;
fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
if (state == TM_ACTIONSTATE_INIT) {
*fadeloop = 255;
al_set_target_bitmap(fade_bitmap);
al_clear_to_color(al_map_rgb(0,0,0));
al_set_target_bitmap(al_get_backbuffer(game->display));
} else if (state == TM_ACTIONSTATE_RUNNING) {
al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
*fadeloop-=tps(game, 600);
if (*fadeloop<=0) return true;
} else {
al_destroy_bitmap(fade_bitmap);
free(fadeloop);
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
al_play_sample_instance(game->level.music);
}
return false;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(game->viewportWidth, game->viewportHeight));
}
float* fadeloop;
ALLEGRO_BITMAP* fade_bitmap;
fadeloop = (float*)action->arguments->value;
fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
if (state == TM_ACTIONSTATE_INIT) {
*fadeloop = 255;
al_set_target_bitmap(fade_bitmap);
al_clear_to_color(al_map_rgb(0,0,0));
al_set_target_bitmap(al_get_backbuffer(game->display));
} else if (state == TM_ACTIONSTATE_RUNNING) {
al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
*fadeloop-=tps(game, 600);
if (*fadeloop<=0) return true;
} else {
al_destroy_bitmap(fade_bitmap);
free(fadeloop);
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
al_play_sample_instance(game->level.music);
}
return false;
}
bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(game->viewportWidth, game->viewportHeight));
}
float* fadeloop;
ALLEGRO_BITMAP* fade_bitmap;
fadeloop = (float*)action->arguments->value;
fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
if (state == TM_ACTIONSTATE_INIT) {
*fadeloop = 0;
al_set_target_bitmap(fade_bitmap);
al_clear_to_color(al_map_rgb(0,0,0));
al_set_target_bitmap(al_get_backbuffer(game->display));
} else if (state == TM_ACTIONSTATE_RUNNING) {
al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
*fadeloop+=tps(game, 600);
if (*fadeloop>=256) return true;
} else {
PrintConsole(game, "Leaving level with %d HP", (int)(game->level.hp*100));
al_destroy_bitmap(fade_bitmap);
free(fadeloop);
Level_Unload(game);
game->gamestate = GAMESTATE_LOADING;
game->loadstate = GAMESTATE_MAP;
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
}
return false;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
action->arguments = TM_AddToArgs(action->arguments, (void*)al_create_bitmap(game->viewportWidth, game->viewportHeight));
}
float* fadeloop;
ALLEGRO_BITMAP* fade_bitmap;
fadeloop = (float*)action->arguments->value;
fade_bitmap = (ALLEGRO_BITMAP*)action->arguments->next->value;
if (state == TM_ACTIONSTATE_INIT) {
*fadeloop = 0;
al_set_target_bitmap(fade_bitmap);
al_clear_to_color(al_map_rgb(0,0,0));
al_set_target_bitmap(al_get_backbuffer(game->display));
} else if (state == TM_ACTIONSTATE_RUNNING) {
al_draw_tinted_bitmap(fade_bitmap,al_map_rgba_f(1,1,1,*fadeloop/255.0),0,0,0);
*fadeloop+=tps(game, 600);
if (*fadeloop>=256) return true;
} else {
PrintConsole(game, "Leaving level with %d HP", (int)(game->level.hp*100));
al_destroy_bitmap(fade_bitmap);
free(fadeloop);
Level_Unload(game);
game->gamestate = GAMESTATE_LOADING;
game->loadstate = GAMESTATE_MAP;
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
}
return false;
}
bool Welcome(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
float* tmp; bool* in;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(bool)));
}
tmp = (float*)action->arguments->value;
in = (bool*)action->arguments->next->value;
if (state == TM_ACTIONSTATE_INIT) {
*tmp = 0;
*in = true;
/*PrintConsole(game, "WELCOME INIT");*/
}
else if (state == TM_ACTIONSTATE_RUNNING) {
/*PrintConsole(game, "WELCOME RUNNING FADE=%f, IN=%d", *in); */
float fade = *tmp;
if (fade>255) fade=255;
if (*tmp > 2048) { *tmp=255; *in=false; }
al_draw_tinted_bitmap(game->level.welcome, al_map_rgba_f(fade/255.0,fade/255.0,fade/255.0,fade/255.0), 0, 0, 0);
if (*in) {
*tmp+=tps(game, 600);
} else {
*tmp-=tps(game, 600);
if (*tmp<=0) { return true; }
}
} else {
free(action->arguments->value);
free(action->arguments->next->value);
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
}
return false;
float* tmp; bool* in;
if (!action->arguments) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(bool)));
}
tmp = (float*)action->arguments->value;
in = (bool*)action->arguments->next->value;
if (state == TM_ACTIONSTATE_INIT) {
*tmp = 0;
*in = true;
/*PrintConsole(game, "WELCOME INIT");*/
}
else if (state == TM_ACTIONSTATE_RUNNING) {
/*PrintConsole(game, "WELCOME RUNNING FADE=%f, IN=%d", *in); */
float fade = *tmp;
if (fade>255) fade=255;
if (*tmp > 2048) { *tmp=255; *in=false; }
al_draw_tinted_bitmap(game->level.welcome, al_map_rgba_f(fade/255.0,fade/255.0,fade/255.0,fade/255.0), 0, 0, 0);
if (*in) {
*tmp+=tps(game, 600);
} else {
*tmp-=tps(game, 600);
if (*tmp<=0) { return true; }
}
} else {
free(action->arguments->value);
free(action->arguments->next->value);
TM_DestroyArgs(action->arguments);
action->arguments = NULL;
}
return false;
}
bool PassLevel(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_DESTROY) {
Level_Passed(game);
TM_AddBackgroundAction(&FadeOut, NULL, 0, "fadeout");
}
return true;
if (state == TM_ACTIONSTATE_DESTROY) {
Level_Passed(game);
TM_AddBackgroundAction(&FadeOut, NULL, 0, "fadeout");
}
return true;
}

View file

@ -23,35 +23,35 @@
#include "callbacks.h"
void Obst_MoveUpDown(struct Game *game, struct Obstacle *obstacle) {
if (obstacle->data) {
obstacle->y -= 0.5;
if (obstacle->y<=0) {
obstacle->data=NULL;
}
} else {
obstacle->y += 0.5;
if (obstacle->y>=((game->viewportHeight-al_get_bitmap_height(*(obstacle->bitmap))/obstacle->rows)/(float)game->viewportHeight)*100) {
obstacle->data++;
}
}
if (obstacle->data) {
obstacle->y -= 0.5;
if (obstacle->y<=0) {
obstacle->data=NULL;
}
} else {
obstacle->y += 0.5;
if (obstacle->y>=((game->viewportHeight-al_get_bitmap_height(*(obstacle->bitmap))/obstacle->rows)/(float)game->viewportHeight)*100) {
obstacle->data++;
}
}
}
void Obst_MoveUp(struct Game *game, struct Obstacle *obstacle) {
float* a = (float*)obstacle->data;
obstacle->y -= *a;
float* a = (float*)obstacle->data;
obstacle->y -= *a;
}
void Obst_RotateSin(struct Game *game, struct Obstacle *obstacle) {
float* a = (float*)obstacle->data;
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/
obstacle->angle = sin(*a)/2.0;
*a+=tps(game, 4.5);
float* a = (float*)obstacle->data;
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/
obstacle->angle = sin(*a)/2.0;
*a+=tps(game, 4.5);
}
void Obst_MoveSin(struct Game *game, struct Obstacle *obstacle) {
float* a = (float*)obstacle->data;
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/
obstacle->y -= sin(*a)*4;
*a+=tps(game, 4.5);
obstacle->y += sin(*a)*4;
float* a = (float*)obstacle->data;
/*PrintConsole(game, "%p - %f", obstacle, obstacle->y);*/
obstacle->y -= sin(*a)*4;
*a+=tps(game, 4.5);
obstacle->y += sin(*a)*4;
}

View file

@ -63,42 +63,42 @@ int frames_done = 0;
char* GetDataFilePath(char* filename) {
char *result = 0;
char *result = 0;
if (al_filename_exists(filename)) {
return strdup(filename);
}
if (al_filename_exists(filename)) {
return strdup(filename);
}
char origfn[255] = "data/";
strcat(origfn, filename);
char origfn[255] = "data/";
strcat(origfn, filename);
if (al_filename_exists(origfn)) {
return strdup(origfn);
}
if (al_filename_exists(origfn)) {
return strdup(origfn);
}
void TestPath(char* subpath) {
ALLEGRO_PATH *tail = al_create_path(filename);
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
ALLEGRO_PATH *data = al_create_path(subpath);
al_join_paths(path, data);
al_join_paths(path, tail);
//printf("Testing for %s\n", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
if (al_filename_exists(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP))) {
result = strdup(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
}
al_destroy_path(tail);
al_destroy_path(data);
al_destroy_path(path);
}
TestPath("../share/superderpy/data/");
TestPath("../data/");
TestPath("data/");
void TestPath(char* subpath) {
ALLEGRO_PATH *tail = al_create_path(filename);
ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
ALLEGRO_PATH *data = al_create_path(subpath);
al_join_paths(path, data);
al_join_paths(path, tail);
//printf("Testing for %s\n", al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
if (al_filename_exists(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP))) {
result = strdup(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));
}
al_destroy_path(tail);
al_destroy_path(data);
al_destroy_path(path);
}
TestPath("../share/superderpy/data/");
TestPath("../data/");
TestPath("data/");
if (!result) {
printf("FATAL: Could not find data file: %s!\n", filename);
exit(1);
}
return result;
if (!result) {
printf("FATAL: Could not find data file: %s!\n", filename);
exit(1);
}
return result;
}
void PrintConsole(struct Game *game, char* format, ...) {
@ -147,15 +147,15 @@ void PreloadGameState(struct Game *game, void (*progress)(struct Game*, float))
}
switch (game->loadstate) {
PRELOAD_STATE(GAMESTATE_MENU, Menu)
PRELOAD_STATE(GAMESTATE_LOADING, Loading)
PRELOAD_STATE(GAMESTATE_ABOUT, About)
PRELOAD_STATE(GAMESTATE_INTRO, Intro)
PRELOAD_STATE(GAMESTATE_MAP, Map)
PRELOAD_STATE(GAMESTATE_LEVEL, Level)
PRELOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PRELOAD_STATE(GAMESTATE_LOADING, Loading)
PRELOAD_STATE(GAMESTATE_ABOUT, About)
PRELOAD_STATE(GAMESTATE_INTRO, Intro)
PRELOAD_STATE(GAMESTATE_MAP, Map)
PRELOAD_STATE(GAMESTATE_LEVEL, Level)
PRELOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to preload unknown gamestate %d!", game->loadstate);
break;
break;
}
PrintConsole(game, "finished");
}
@ -169,15 +169,15 @@ void UnloadGameState(struct Game *game) {
PrintConsole(game, "Just stopping GAMESTATE_MENU..."); Menu_Stop(game);
}
break;
UNLOAD_STATE(GAMESTATE_PAUSE, Pause)
UNLOAD_STATE(GAMESTATE_LOADING, Loading)
UNLOAD_STATE(GAMESTATE_ABOUT, About)
UNLOAD_STATE(GAMESTATE_INTRO, Intro)
UNLOAD_STATE(GAMESTATE_MAP, Map)
UNLOAD_STATE(GAMESTATE_LEVEL, Level)
UNLOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate %d!", game->gamestate);
UNLOAD_STATE(GAMESTATE_PAUSE, Pause)
UNLOAD_STATE(GAMESTATE_LOADING, Loading)
UNLOAD_STATE(GAMESTATE_ABOUT, About)
UNLOAD_STATE(GAMESTATE_INTRO, Intro)
UNLOAD_STATE(GAMESTATE_MAP, Map)
UNLOAD_STATE(GAMESTATE_LEVEL, Level)
UNLOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate %d!", game->gamestate);
break;
}
PrintConsole(game, "finished");
@ -186,13 +186,13 @@ void UnloadGameState(struct Game *game) {
void LoadGameState(struct Game *game) {
switch (game->loadstate) {
LOAD_STATE(GAMESTATE_MENU, Menu)
LOAD_STATE(GAMESTATE_LOADING, Loading)
LOAD_STATE(GAMESTATE_ABOUT, About)
LOAD_STATE(GAMESTATE_INTRO, Intro)
LOAD_STATE(GAMESTATE_MAP, Map)
LOAD_STATE(GAMESTATE_LEVEL, Level)
LOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
LOAD_STATE(GAMESTATE_LOADING, Loading)
LOAD_STATE(GAMESTATE_ABOUT, About)
LOAD_STATE(GAMESTATE_INTRO, Intro)
LOAD_STATE(GAMESTATE_MAP, Map)
LOAD_STATE(GAMESTATE_LEVEL, Level)
LOAD_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
PrintConsole(game, "ERROR: Attempted to load unknown gamestate %d!", game->loadstate);
}
PrintConsole(game, "finished");
@ -203,24 +203,24 @@ void LoadGameState(struct Game *game) {
void DrawGameState(struct Game *game) {
switch (game->gamestate) {
DRAW_STATE(GAMESTATE_MENU, Menu)
DRAW_STATE(GAMESTATE_PAUSE, Pause)
DRAW_STATE(GAMESTATE_LOADING, Loading)
DRAW_STATE(GAMESTATE_ABOUT, About)
DRAW_STATE(GAMESTATE_INTRO, Intro)
DRAW_STATE(GAMESTATE_MAP, Map)
DRAW_STATE(GAMESTATE_LEVEL, Level)
DRAW_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
DRAW_STATE(GAMESTATE_PAUSE, Pause)
DRAW_STATE(GAMESTATE_LOADING, Loading)
DRAW_STATE(GAMESTATE_ABOUT, About)
DRAW_STATE(GAMESTATE_INTRO, Intro)
DRAW_STATE(GAMESTATE_MAP, Map)
DRAW_STATE(GAMESTATE_LEVEL, Level)
DRAW_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
default:
game->showconsole = true;
al_clear_to_color(al_map_rgb(0,0,0));
PrintConsole(game, "ERROR: Unknown gamestate %d reached! (5 sec sleep)", game->gamestate);
DrawConsole(game);
al_flip_display();
al_rest(5.0);
PrintConsole(game, "Returning to menu...");
game->gamestate = GAMESTATE_LOADING;
game->loadstate = GAMESTATE_MENU;
break;
al_clear_to_color(al_map_rgb(0,0,0));
PrintConsole(game, "ERROR: Unknown gamestate %d reached! (5 sec sleep)", game->gamestate);
DrawConsole(game);
al_flip_display();
al_rest(5.0);
PrintConsole(game, "Returning to menu...");
game->gamestate = GAMESTATE_LOADING;
game->loadstate = GAMESTATE_MENU;
break;
}
}
@ -238,9 +238,9 @@ void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height) {
ALLEGRO_COLOR interpolate(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) {
return al_map_rgba_f(c1.r + frac * (c2.r - c1.r),
c1.g + frac * (c2.g - c1.g),
c1.b + frac * (c2.b - c1.b),
c1.a + frac * (c2.a - c1.a));
c1.g + frac * (c2.g - c1.g),
c1.b + frac * (c2.b - c1.b),
c1.a + frac * (c2.a - c1.a));
}
for (y = 0; y < height; y++) {
@ -270,7 +270,7 @@ ALLEGRO_BITMAP* LoadScaledBitmap(char* filename, int width, int height) {
ALLEGRO_BITMAP *source, *target = al_create_bitmap(width, height);
al_set_target_bitmap(target);
al_clear_to_color(al_map_rgba(0,0,0,0));
char* origfn = GetDataFilePath(filename);
char* origfn = GetDataFilePath(filename);
void GenerateBitmap() {
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
@ -287,9 +287,9 @@ ALLEGRO_BITMAP* LoadScaledBitmap(char* filename, int width, int height) {
if (source) {
if ((al_get_bitmap_width(source)!=width) || (al_get_bitmap_height(source)!=height)) {
al_destroy_bitmap(source);*/
GenerateBitmap();
free(origfn);
return target;
GenerateBitmap();
free(origfn);
return target;
/* }
return source;
} else GenerateBitmap();
@ -327,12 +327,12 @@ void SetupViewport(struct Game *game) {
}
int Shared_Load(struct Game *game) {
game->font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.09,0 );
game->font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.09,0 );
if(!game->font) {
fprintf(stderr, "failed to load game font!\n");
return -1;
}
game->font_console = al_load_ttf_font(GetDataFilePath("DejaVuSansMono.ttf"),game->viewportHeight*0.018,0 );
game->font_console = al_load_ttf_font(GetDataFilePath("DejaVuSansMono.ttf"),game->viewportHeight*0.018,0 );
if(!game->font_console) {
fprintf(stderr, "failed to load console font!\n");
return -1;
@ -351,9 +351,9 @@ void Shared_Unload(struct Game *game) {
}
void derp(int sig) {
write(STDERR_FILENO, "Segmentation fault\n", 19);
write(STDERR_FILENO, "I just don't know what went wrong!\n", 35);
abort();
write(STDERR_FILENO, "Segmentation fault\n", 19);
write(STDERR_FILENO, "I just don't know what went wrong!\n", 35);
abort();
}
int main(int argc, char **argv){
@ -364,12 +364,12 @@ int main(int argc, char **argv){
al_set_org_name("Super Derpy");
al_set_app_name("Muffin Attack");
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
if(!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
InitConfig();
InitConfig();
bool redraw = true;
@ -389,7 +389,7 @@ int main(int argc, char **argv){
if(!al_init_image_addon()) {
fprintf(stderr, "failed to initialize image addon!\n");
/*al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!",
NULL, ALLEGRO_MESSAGEBOX_ERROR);*/
NULL, ALLEGRO_MESSAGEBOX_ERROR);*/
return 0;
}
@ -413,7 +413,7 @@ int main(int argc, char **argv){
return -1;
}
/* if (!al_reserve_samples(10)){
/* if (!al_reserve_samples(10)){
fprintf(stderr, "failed to reserve samples!\n");
return -1;
}
@ -540,11 +540,11 @@ int main(int argc, char **argv){
}
else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
/*PrintConsole(&game, "KEYCODE: %s", al_keycode_to_name(ev.keyboard.keycode));*/
#ifdef ALLEGRO_MACOSX
#ifdef ALLEGRO_MACOSX
if ((ev.type == ALLEGRO_EVENT_KEY_DOWN) && (ev.keyboard.keycode == 104)) {
#else
#else
if ((ev.type == ALLEGRO_EVENT_KEY_DOWN) && (ev.keyboard.keycode == ALLEGRO_KEY_TILDE)) {
#endif
#endif
game.showconsole = !game.showconsole;
}
else if ((game.debug) && (ev.type == ALLEGRO_EVENT_KEY_DOWN) && (ev.keyboard.keycode == ALLEGRO_KEY_F1)) {
@ -564,14 +564,14 @@ int main(int argc, char **argv){
al_destroy_path(path);
}
KEYDOWN_STATE(GAMESTATE_PAUSE, Pause)
KEYDOWN_STATE(GAMESTATE_MENU, Menu)
KEYDOWN_STATE(GAMESTATE_LOADING, Loading)
KEYDOWN_STATE(GAMESTATE_ABOUT, About)
KEYDOWN_STATE(GAMESTATE_INTRO, Intro)
KEYDOWN_STATE(GAMESTATE_MAP, Map)
KEYDOWN_STATE(GAMESTATE_LEVEL, Level)
KEYDOWN_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
else {
KEYDOWN_STATE(GAMESTATE_MENU, Menu)
KEYDOWN_STATE(GAMESTATE_LOADING, Loading)
KEYDOWN_STATE(GAMESTATE_ABOUT, About)
KEYDOWN_STATE(GAMESTATE_INTRO, Intro)
KEYDOWN_STATE(GAMESTATE_MAP, Map)
KEYDOWN_STATE(GAMESTATE_LEVEL, Level)
KEYDOWN_STATE(GAMESTATE_DISCLAIMER, Disclaimer)
else {
game.showconsole = true;
PrintConsole(&game, "ERROR: Keystroke in unknown (%d) gamestate! (5 sec sleep)", game.gamestate);
DrawConsole(&game);
@ -618,11 +618,11 @@ int main(int argc, char **argv){
if (game.restart) {
al_shutdown_ttf_addon();
al_shutdown_font_addon();
#ifdef ALLEGRO_MACOSX
return _al_mangled_main(argc, argv);
#else
return main(argc, argv);
#endif
#ifdef ALLEGRO_MACOSX
return _al_mangled_main(argc, argv);
#else
return main(argc, argv);
#endif
}
return 0;
}

View file

@ -54,102 +54,102 @@ enum gamestate_enum {
/*! \brief Resources used by moonwalk level placeholder. */
struct Moonwalk {
ALLEGRO_BITMAP *fade_bitmap; /*!< Bitmap used on fade-in and fade-out animations. */
ALLEGRO_BITMAP *image; /*!< Background texture. */
int derpy_frame; /*!< Current frame of Derpy animation. */
int derpy_frame_tmp; /*!< Counter used to slow down Derpy animation. */
double derpy_pos; /*!< Position of Derpy on screen. */
ALLEGRO_BITMAP *fade_bitmap; /*!< Bitmap used on fade-in and fade-out animations. */
ALLEGRO_BITMAP *image; /*!< Background texture. */
int derpy_frame; /*!< Current frame of Derpy animation. */
int derpy_frame_tmp; /*!< Counter used to slow down Derpy animation. */
double derpy_pos; /*!< Position of Derpy on screen. */
};
/*! \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. */
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. */
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 (*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. */
};
/*! \brief Structure representing one spritesheet animation of Derpy. */
struct Spritesheet {
char* name; /*!< Readable name of the spritesheet. */
ALLEGRO_BITMAP* bitmap; /*!< Spritesheet bitmap. */
int rows; /*!< Number of rows in the spritesheet. */
int cols; /*!< Number of columns in the spritesheet. */
int blanks; /*!< Number of blank frames at the end of the spritesheet. */
float speed; /*!< Speed modifier of spritesheet animation. */
float aspect; /*!< Aspect ratio of the frame. */
float scale; /*!< Scale modifier of the frame. */
struct Spritesheet* next; /*!< Next spritesheet in the queue. */
char* name; /*!< Readable name of the spritesheet. */
ALLEGRO_BITMAP* bitmap; /*!< Spritesheet bitmap. */
int rows; /*!< Number of rows in the spritesheet. */
int cols; /*!< Number of columns in the spritesheet. */
int blanks; /*!< Number of blank frames at the end of the spritesheet. */
float speed; /*!< Speed modifier of spritesheet animation. */
float aspect; /*!< Aspect ratio of the frame. */
float scale; /*!< Scale modifier of the frame. */
struct Spritesheet* next; /*!< Next spritesheet in the queue. */
};
/*! \brief Resources used by Level state. */
struct Level {
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. */
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. */
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 *owl; /*!< Owlicious bitmap. */
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 sprite sheets of Derpy character. */
struct Spritesheet* pony_sheets; /*!< List of sprite sheets of character rescued by Derpy. */
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. */
struct Moonwalk moonwalk; /*!< Moonwalk placeholder 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. */
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. */
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 *owl; /*!< Owlicious bitmap. */
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 sprite sheets of Derpy character. */
struct Spritesheet* pony_sheets; /*!< List of sprite sheets of character rescued by Derpy. */
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. */
struct Moonwalk moonwalk; /*!< Moonwalk placeholder data. */
};
/*! \brief Enum of menu states in Menu and Pause game states. */
@ -164,139 +164,139 @@ enum menustate_enum {
/*! \brief Resources used by Menu state. */
struct Menu {
ALLEGRO_BITMAP *menu_fade_bitmap; /*!< Screenshot bitmap used for fades. */
ALLEGRO_BITMAP *image; /*!< Bitmap with lower portion of menu landscape. */
ALLEGRO_BITMAP *cloud; /*!< Bitmap with bigger cloud. */
ALLEGRO_BITMAP *cloud2; /*!< Bitmap with small cloud. */
ALLEGRO_BITMAP *pie; /*!< Unscaled bitmap with pie. */
ALLEGRO_BITMAP *pie_bitmap; /*!< Scaled and "rendered" bitmap with pies. */
ALLEGRO_BITMAP *pinkcloud_bitmap; /*!< Scaled bitmap with pinkcloud and home. */
ALLEGRO_BITMAP *pinkcloud; /*!< Unscaled bitmap with pinkcloud and home. */
ALLEGRO_BITMAP *rain; /*!< Unscaled bitmap with rain drop. */
ALLEGRO_BITMAP *rain_bitmap; /*!< Scaled and "rendered" bitmap with rain drops. */
ALLEGRO_BITMAP *mountain; /*!< Flashing mountain in background bitmap. */
ALLEGRO_BITMAP *logo; /*!< Logo displayed in the background. */
ALLEGRO_BITMAP *logoblur; /*!< Prerendered blurred logo. */
ALLEGRO_BITMAP *glass; /*!< Texture used for glass effect in the logo. */
ALLEGRO_BITMAP *blurbg; /*!< Temporary bitmap used for blur effect in glass logo. */
ALLEGRO_BITMAP *blurbg2; /*!< Temporary bitmap used for blur effect in glass logo. */
float cloud_position; /*!< Position of bigger cloud. */
float cloud2_position; /*!< Position of small cloud. */
int mountain_position; /*!< Position of flashing mountain. */
ALLEGRO_SAMPLE *sample; /*!< Background music sample. */
ALLEGRO_SAMPLE *rain_sample; /*!< Rain sound sample. */
ALLEGRO_SAMPLE *click_sample; /*!< Click sound sample. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_SAMPLE_INSTANCE *rain_sound; /*!< Sample instance with rain sound. */
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
ALLEGRO_FONT *font_title; /*!< Font of "Super Derpy" text. */
ALLEGRO_FONT *font_subtitle; /*!< Font of "Muffin Attack" text. */
ALLEGRO_FONT *font; /*!< Font of standard menu item. */
ALLEGRO_FONT *font_selected; /*!< Font of selected menu item. */
int selected; /*!< Number of selected menu item. */
enum menustate_enum menustate; /*!< Current menu page. */
bool loaded; /*!< True if Menu state has been already loaded. */
struct {
bool fullscreen;
int fps;
int width;
int height;
} options; /*!< Options which can be changed in menu. */
ALLEGRO_BITMAP *menu_fade_bitmap; /*!< Screenshot bitmap used for fades. */
ALLEGRO_BITMAP *image; /*!< Bitmap with lower portion of menu landscape. */
ALLEGRO_BITMAP *cloud; /*!< Bitmap with bigger cloud. */
ALLEGRO_BITMAP *cloud2; /*!< Bitmap with small cloud. */
ALLEGRO_BITMAP *pie; /*!< Unscaled bitmap with pie. */
ALLEGRO_BITMAP *pie_bitmap; /*!< Scaled and "rendered" bitmap with pies. */
ALLEGRO_BITMAP *pinkcloud_bitmap; /*!< Scaled bitmap with pinkcloud and home. */
ALLEGRO_BITMAP *pinkcloud; /*!< Unscaled bitmap with pinkcloud and home. */
ALLEGRO_BITMAP *rain; /*!< Unscaled bitmap with rain drop. */
ALLEGRO_BITMAP *rain_bitmap; /*!< Scaled and "rendered" bitmap with rain drops. */
ALLEGRO_BITMAP *mountain; /*!< Flashing mountain in background bitmap. */
ALLEGRO_BITMAP *logo; /*!< Logo displayed in the background. */
ALLEGRO_BITMAP *logoblur; /*!< Prerendered blurred logo. */
ALLEGRO_BITMAP *glass; /*!< Texture used for glass effect in the logo. */
ALLEGRO_BITMAP *blurbg; /*!< Temporary bitmap used for blur effect in glass logo. */
ALLEGRO_BITMAP *blurbg2; /*!< Temporary bitmap used for blur effect in glass logo. */
float cloud_position; /*!< Position of bigger cloud. */
float cloud2_position; /*!< Position of small cloud. */
int mountain_position; /*!< Position of flashing mountain. */
ALLEGRO_SAMPLE *sample; /*!< Background music sample. */
ALLEGRO_SAMPLE *rain_sample; /*!< Rain sound sample. */
ALLEGRO_SAMPLE *click_sample; /*!< Click sound sample. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_SAMPLE_INSTANCE *rain_sound; /*!< Sample instance with rain sound. */
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
ALLEGRO_FONT *font_title; /*!< Font of "Super Derpy" text. */
ALLEGRO_FONT *font_subtitle; /*!< Font of "Muffin Attack" text. */
ALLEGRO_FONT *font; /*!< Font of standard menu item. */
ALLEGRO_FONT *font_selected; /*!< Font of selected menu item. */
int selected; /*!< Number of selected menu item. */
enum menustate_enum menustate; /*!< Current menu page. */
bool loaded; /*!< True if Menu state has been already loaded. */
struct {
bool fullscreen;
int fps;
int width;
int height;
} options; /*!< Options which can be changed in menu. */
};
/*! \brief Resources used by Loading state. */
struct Loading {
ALLEGRO_BITMAP *loading_bitmap; /*!< Rendered loading bitmap. */
ALLEGRO_BITMAP *image; /*!< Loading background. */
ALLEGRO_BITMAP *loading_bitmap; /*!< Rendered loading bitmap. */
ALLEGRO_BITMAP *image; /*!< Loading background. */
};
/*! \brief Resources used by Pause state. */
struct Pause {
ALLEGRO_BITMAP *bitmap; /*!< Bitmap with screenshot. */
ALLEGRO_BITMAP *derpy; /*!< Derpy on foreground. */
ALLEGRO_BITMAP *bitmap; /*!< Bitmap with screenshot. */
ALLEGRO_BITMAP *derpy; /*!< Derpy on foreground. */
};
/*! \brief Resources used by About state. */
struct About {
ALLEGRO_BITMAP *fade_bitmap; /*!< Bitmap with screenshot, used in fades. */
ALLEGRO_BITMAP *image; /*!< Background bitmap. */
ALLEGRO_BITMAP *text_bitmap; /*!< Bitmap with scrolled text. */
ALLEGRO_BITMAP *letter; /*!< Paper bitmap. */
ALLEGRO_SAMPLE *sample; /*!< Sample with background music. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_FONT *font; /*!< Font used in the text on letter. */
float x; /*!< Horizontal position of the text. */
int fadeloop; /*!< Loop counter used in fades. */
ALLEGRO_BITMAP *fade_bitmap; /*!< Bitmap with screenshot, used in fades. */
ALLEGRO_BITMAP *image; /*!< Background bitmap. */
ALLEGRO_BITMAP *text_bitmap; /*!< Bitmap with scrolled text. */
ALLEGRO_BITMAP *letter; /*!< Paper bitmap. */
ALLEGRO_SAMPLE *sample; /*!< Sample with background music. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_FONT *font; /*!< Font used in the text on letter. */
float x; /*!< Horizontal position of the text. */
int fadeloop; /*!< Loop counter used in fades. */
};
/*! \brief Resources used by Map state. */
struct Map {
ALLEGRO_BITMAP *map; /*!< Background table bitmap. */
ALLEGRO_BITMAP *map_bg; /*!< Map bitmap. */
ALLEGRO_BITMAP *highlight; /*!< Level highlights bitmap. */
ALLEGRO_BITMAP *arrow; /*!< Arrow bitmap. */
int selected; /*!< Number of currently selected level. */
int available; /*!< Number of highest available level. */
float arrowpos; /*!< Vertical position of the arrow. */
ALLEGRO_SAMPLE *sample; /*!< Sample with backgrond music. */
ALLEGRO_SAMPLE *click_sample; /*!< Sample with click sound. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
ALLEGRO_BITMAP *map; /*!< Background table bitmap. */
ALLEGRO_BITMAP *map_bg; /*!< Map bitmap. */
ALLEGRO_BITMAP *highlight; /*!< Level highlights bitmap. */
ALLEGRO_BITMAP *arrow; /*!< Arrow bitmap. */
int selected; /*!< Number of currently selected level. */
int available; /*!< Number of highest available level. */
float arrowpos; /*!< Vertical position of the arrow. */
ALLEGRO_SAMPLE *sample; /*!< Sample with backgrond music. */
ALLEGRO_SAMPLE *click_sample; /*!< Sample with click sound. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_SAMPLE_INSTANCE *click; /*!< Sample instance with click sound. */
};
/*! \brief Resources used by Intro state. */
struct Intro {
int position; /*!< Position of the page. */
int page; /*!< Current page number. */
bool in_animation; /*!< Animation as in page transition animation. */
float anim; /*!< Counter used for spritesheet animations. */
ALLEGRO_BITMAP *table; /*!< Background paper bitmap, two pages long. */
ALLEGRO_BITMAP *table_bitmap; /*!< Unscaled background paper bitmap. */
ALLEGRO_BITMAP *frame; /*!< Bitmap with frame around the screen. */
ALLEGRO_BITMAP *animsprites[5]; /*!< Array with spritesheet bitmaps. */
ALLEGRO_FONT *font; /*!< Font used for text. */
ALLEGRO_SAMPLE *sample; /*!< Background music sample. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_AUDIO_STREAM *audiostream; /*!< Audiostream used for Celestia voice. */
int position; /*!< Position of the page. */
int page; /*!< Current page number. */
bool in_animation; /*!< Animation as in page transition animation. */
float anim; /*!< Counter used for spritesheet animations. */
ALLEGRO_BITMAP *table; /*!< Background paper bitmap, two pages long. */
ALLEGRO_BITMAP *table_bitmap; /*!< Unscaled background paper bitmap. */
ALLEGRO_BITMAP *frame; /*!< Bitmap with frame around the screen. */
ALLEGRO_BITMAP *animsprites[5]; /*!< Array with spritesheet bitmaps. */
ALLEGRO_FONT *font; /*!< Font used for text. */
ALLEGRO_SAMPLE *sample; /*!< Background music sample. */
ALLEGRO_SAMPLE_INSTANCE *music; /*!< Sample instance with background music. */
ALLEGRO_AUDIO_STREAM *audiostream; /*!< Audiostream used for Celestia voice. */
};
/*! \brief Resources used by Game state. */
struct Game {
ALLEGRO_DISPLAY *display; /*!< Main Allegro display. */
ALLEGRO_FONT *font; /*!< Main font used in game. */
ALLEGRO_FONT *font_console; /*!< Font used in game console. */
enum gamestate_enum gamestate; /*!< Current game state. */
enum gamestate_enum loadstate; /*!< Game state to be loaded. */
ALLEGRO_EVENT_QUEUE *event_queue; /*!< Main event queue. */
ALLEGRO_TIMER *timer; /*!< Main FPS timer. */
ALLEGRO_BITMAP *console; /*!< Bitmap with game console. */
int viewportWidth; /*!< Actual available width of viewport. */
int viewportHeight; /*!< Actual available height of viewport. */
bool showconsole; /*!< If true, game console is rendered on screen. */
int fx; /*!< Effects volume. */
int music; /*!< Music volume. */
int voice; /*!< Voice volume. */
bool fullscreen; /*!< Fullscreen toggle. */
bool debug; /*!< Toggles debug mode. */
int fps; /*!< FPS limit */
int width; /*!< Width of window as being set in configuration. */
int height; /*!< Height of window as being set in configuration. */
bool shuttingdown; /*!< If true then shut down of the game is pending. */
bool restart; /*!< If true then restart of the game is pending. */
struct Menu menu; /*!< Resources used by Menu state. */
struct Loading loading; /*!< Resources used by Menu state. */
struct Intro intro; /*!< Resources used by Intro state. */
struct About about; /*!< Resources used by About state. */
struct Map map; /*!< Resources used by Map state. */
struct Level level; /*!< Resources used by Level state. */
struct Pause pause; /*!< Resources used by Pause state. */
struct {
ALLEGRO_VOICE *v; /*!< Main voice used by the game. */
ALLEGRO_MIXER *mixer; /*!< Main mixer of the game. */
ALLEGRO_MIXER *music; /*!< Music mixer. */
ALLEGRO_MIXER *voice; /*!< Voice mixer. */
ALLEGRO_MIXER *fx; /*!< Effects mixer. */
} audio; /*!< Audio resources. */
ALLEGRO_DISPLAY *display; /*!< Main Allegro display. */
ALLEGRO_FONT *font; /*!< Main font used in game. */
ALLEGRO_FONT *font_console; /*!< Font used in game console. */
enum gamestate_enum gamestate; /*!< Current game state. */
enum gamestate_enum loadstate; /*!< Game state to be loaded. */
ALLEGRO_EVENT_QUEUE *event_queue; /*!< Main event queue. */
ALLEGRO_TIMER *timer; /*!< Main FPS timer. */
ALLEGRO_BITMAP *console; /*!< Bitmap with game console. */
int viewportWidth; /*!< Actual available width of viewport. */
int viewportHeight; /*!< Actual available height of viewport. */
bool showconsole; /*!< If true, game console is rendered on screen. */
int fx; /*!< Effects volume. */
int music; /*!< Music volume. */
int voice; /*!< Voice volume. */
bool fullscreen; /*!< Fullscreen toggle. */
bool debug; /*!< Toggles debug mode. */
int fps; /*!< FPS limit */
int width; /*!< Width of window as being set in configuration. */
int height; /*!< Height of window as being set in configuration. */
bool shuttingdown; /*!< If true then shut down of the game is pending. */
bool restart; /*!< If true then restart of the game is pending. */
struct Menu menu; /*!< Resources used by Menu state. */
struct Loading loading; /*!< Resources used by Menu state. */
struct Intro intro; /*!< Resources used by Intro state. */
struct About about; /*!< Resources used by About state. */
struct Map map; /*!< Resources used by Map state. */
struct Level level; /*!< Resources used by Level state. */
struct Pause pause; /*!< Resources used by Pause state. */
struct {
ALLEGRO_VOICE *v; /*!< Main voice used by the game. */
ALLEGRO_MIXER *mixer; /*!< Main mixer of the game. */
ALLEGRO_MIXER *music; /*!< Music mixer. */
ALLEGRO_MIXER *voice; /*!< Voice mixer. */
ALLEGRO_MIXER *fx; /*!< Effects mixer. */
} audio; /*!< Audio resources. */
};
/*! \brief Preloads gamestate set in game->loadstate. */
@ -312,7 +312,7 @@ void LoadGameState(struct Game *game);
char* GetDataFilePath(char* filename);
/*! \brief Print some message on game console.
*
*
* Draws message on console bitmap, so it'll be displayed when calling DrawConsole.
* If game->debug is true, then it also prints given message on stdout.
* It needs to be called in printf style.

View file

@ -113,12 +113,12 @@ void Map_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
game->map.highlight = LoadScaledBitmap(filename, game->viewportWidth, game->viewportHeight);
PROGRESS;
game->map.arrow = al_load_bitmap( GetDataFilePath("map/arrow.png") );
game->map.arrow = al_load_bitmap( GetDataFilePath("map/arrow.png") );
PROGRESS;
game->map.click_sample = al_load_sample( GetDataFilePath("menu/click.flac") );
game->map.click_sample = al_load_sample( GetDataFilePath("menu/click.flac") );
PROGRESS;
game->map.sample = al_load_sample( GetDataFilePath("map/map.flac") );
game->map.sample = al_load_sample( GetDataFilePath("map/map.flac") );
PROGRESS;
game->map.music = al_create_sample_instance(game->map.sample);

View file

@ -36,7 +36,7 @@ void DrawMenuState(struct Game *game) {
font = game->menu.font; if (game->menu.selected==2) font = game->menu.font_selected;
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.7, ALLEGRO_ALIGN_CENTRE, "About");
font = game->menu.font; if (game->menu.selected==3) font = game->menu.font_selected;
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
al_draw_text_with_shadow(font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.8, ALLEGRO_ALIGN_CENTRE, "Exit");
break;
case MENUSTATE_OPTIONS:
font = game->menu.font; if (game->menu.selected==0) font = game->menu.font_selected;
@ -216,17 +216,17 @@ void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
game->menu.pinkcloud = LoadScaledBitmap( "menu/pinkcloud.png", game->viewportWidth*0.33125, game->viewportHeight*0.8122);
PROGRESS;
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
game->menu.rain = al_load_bitmap( GetDataFilePath("menu/rain.png") );
game->menu.rain = al_load_bitmap( GetDataFilePath("menu/rain.png") );
PROGRESS;
game->menu.pie = al_load_bitmap( GetDataFilePath("levels/pie1.png") );
game->menu.pie = al_load_bitmap( GetDataFilePath("levels/pie1.png") );
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
PROGRESS;
game->menu.sample = al_load_sample( GetDataFilePath("menu/menu.flac") );
game->menu.sample = al_load_sample( GetDataFilePath("menu/menu.flac") );
PROGRESS;
game->menu.rain_sample = al_load_sample( GetDataFilePath("menu/rain.flac") );
game->menu.rain_sample = al_load_sample( GetDataFilePath("menu/rain.flac") );
PROGRESS;
game->menu.click_sample = al_load_sample( GetDataFilePath("menu/click.flac") );
game->menu.click_sample = al_load_sample( GetDataFilePath("menu/click.flac") );
PROGRESS;
game->menu.mountain_position = game->viewportWidth*0.7;
@ -242,10 +242,10 @@ void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) {
al_attach_sample_instance_to_mixer(game->menu.click, game->audio.fx);
al_set_sample_instance_playmode(game->menu.click, ALLEGRO_PLAYMODE_ONCE);
game->menu.font_title = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.16,0 );
game->menu.font_subtitle = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.08,0 );
game->menu.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.05,0 );
game->menu.font_selected = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.065,0 );
game->menu.font_title = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.16,0 );
game->menu.font_subtitle = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.08,0 );
game->menu.font = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.05,0 );
game->menu.font_selected = al_load_ttf_font(GetDataFilePath("ShadowsIntoLight.ttf"),game->viewportHeight*0.065,0 );
PROGRESS;
if (!game->menu.sample){

View file

@ -42,13 +42,13 @@ void Moonwalk_Draw(struct Game *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;
}
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,game->viewportWidth, game->viewportHeight,0);
al_draw_bitmap(game->level.derpy, game->level.moonwalk.derpy_pos*game->viewportWidth, game->viewportHeight*0.95-al_get_bitmap_height(game->level.derpy), ALLEGRO_FLIP_HORIZONTAL);
@ -94,7 +94,7 @@ void Moonwalk_PreloadBitmaps(struct Game *game) {
void Moonwalk_Preload(struct Game *game) {
PrintConsole(game, "Initializing level %d...", game->level.current_level);
game->level.sample = al_load_sample( GetDataFilePath("levels/moonwalk.flac") );
game->level.sample = al_load_sample( GetDataFilePath("levels/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);

View file

@ -40,9 +40,9 @@ void TM_Process() {
if (!game) return;
if (paused) return;
/*
process first element from queue
if returns true, then delete it
*/
process first element from queue
if returns true, then delete it
*/
if (queue) {
if (*queue->function) {
queue->active = true;
@ -117,7 +117,7 @@ void TM_HandleEvent(ALLEGRO_EVENT *ev) {
queue->active=true;
al_destroy_timer(queue->timer);
queue->timer = NULL;
if (queue->function) {
if (queue->function) {
PrintConsole(game, "Timeline Manager: queue: init action (%d - %s)", queue->id, queue->name);
(*queue->function)(game, queue, TM_ACTIONSTATE_INIT);
} else {
@ -160,7 +160,7 @@ struct TM_Action* TM_AddAction(bool (*func)(struct Game*, struct TM_Action*, enu
action->active = false;
action->delay = 0;
action->id = ++lastid;
if (action->function) {
if (action->function) {
PrintConsole(game, "Timeline Manager: queue: init action (%d - %s)", action->id, action->name);
(*action->function)(game, action, TM_ACTIONSTATE_INIT);
}
@ -236,18 +236,18 @@ void TM_AddDelay(float delay) {
void TM_Pause(bool pause) {
paused = pause;
PrintConsole(game, "Timeline Manager: pause %d", pause);
if (queue) {
if (queue->timer) {
if (pause) {
if (queue) {
if (queue->timer) {
if (pause) {
al_stop_timer(queue->timer);
} else if (!queue->active) al_start_timer(queue->timer);
}
}
struct TM_Action* tmp = background;
while (tmp) {
if (tmp->timer) {
if (pause) {
al_stop_timer(tmp->timer);
if (tmp->timer) {
if (pause) {
al_stop_timer(tmp->timer);
} else if (!tmp->active) al_start_timer(tmp->timer);
}
tmp = tmp->next;

View file

@ -32,20 +32,20 @@ enum TM_ActionState {
/*! \brief Arguments for TM_Action. */
struct TM_Arguments {
void *value; /*!< Value of argument. */
struct TM_Arguments *next; /*!< Pointer to next argument. */
void *value; /*!< Value of argument. */
struct TM_Arguments *next; /*!< Pointer to next argument. */
};
/*! \brief Timeline action. */
struct TM_Action {
bool (*function)(struct Game*, struct TM_Action*, enum TM_ActionState); /*!< Function callback of the action. */
struct TM_Arguments *arguments; /*!< Arguments of the action. */
ALLEGRO_TIMER *timer; /*!< Delay timer. */
bool active; /*!< If false, then this action is waiting for it's delay to finish. */
int delay; /*!< Number of miliseconds to delay before action is started. */
struct TM_Action *next; /*!< Pointer to next action in queue. */
unsigned int id; /*!< ID of the action. */
char* name; /*!< "User friendly" name of the action. */
bool (*function)(struct Game*, struct TM_Action*, enum TM_ActionState); /*!< Function callback of the action. */
struct TM_Arguments *arguments; /*!< Arguments of the action. */
ALLEGRO_TIMER *timer; /*!< Delay timer. */
bool active; /*!< If false, then this action is waiting for it's delay to finish. */
int delay; /*!< Number of miliseconds to delay before action is started. */
struct TM_Action *next; /*!< Pointer to next action in queue. */
unsigned int id; /*!< ID of the action. */
char* name; /*!< "User friendly" name of the action. */
};
/*! \brief Init timeline. */