mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 11:06:44 +01:00
use ANSI C gcc mode
This commit is contained in:
parent
35a6a328bf
commit
555cc0b9e0
13 changed files with 60 additions and 78 deletions
2
Makefile
2
Makefile
|
@ -1,6 +1,6 @@
|
||||||
IDIR =.
|
IDIR =.
|
||||||
CC=gcc
|
CC=gcc
|
||||||
CFLAGS=-I$(IDIR) -Wall -g
|
CFLAGS=-I$(IDIR) -Wall -ansi -g
|
||||||
|
|
||||||
SRCDIR=src
|
SRCDIR=src
|
||||||
ODIR=obj
|
ODIR=obj
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "about.h"
|
#include "about.h"
|
||||||
|
|
||||||
void About_Draw(struct Game *game) {
|
void About_Draw(struct Game *game) {
|
||||||
//PrintConsole(game, "%d", al_get_sample_instance_position(game->about.music));
|
/*PrintConsole(game, "%d", al_get_sample_instance_position(game->about.music));*/
|
||||||
if (al_get_sample_instance_position(game->about.music)<700000) { al_clear_to_color(al_map_rgba(0,0,0,0)); return; }
|
if (al_get_sample_instance_position(game->about.music)<700000) { al_clear_to_color(al_map_rgba(0,0,0,0)); return; }
|
||||||
if (game->about.fadeloop>=0) {
|
if (game->about.fadeloop>=0) {
|
||||||
al_draw_tinted_bitmap(game->about.fade_bitmap,al_map_rgba_f(game->about.fadeloop/255.0,game->about.fadeloop/255.0,game->about.fadeloop/255.0,1),0,0,0);
|
al_draw_tinted_bitmap(game->about.fade_bitmap,al_map_rgba_f(game->about.fadeloop/255.0,game->about.fadeloop/255.0,game->about.fadeloop/255.0,1),0,0,0);
|
||||||
|
|
27
src/intro.c
27
src/intro.c
|
@ -38,7 +38,6 @@ void FillPage(struct Game *game, int page) {
|
||||||
char filename[30] = { };
|
char filename[30] = { };
|
||||||
sprintf(filename, "data/intro/%d.flac", page);
|
sprintf(filename, "data/intro/%d.flac", page);
|
||||||
|
|
||||||
//if (game->intro.audiostream) al_destroy_audio_stream(game->intro.audiostream);
|
|
||||||
game->intro.audiostream = al_load_audio_stream(filename, 4, 1024);
|
game->intro.audiostream = al_load_audio_stream(filename, 4, 1024);
|
||||||
al_attach_audio_stream_to_mixer(game->intro.audiostream, game->audio.voice);
|
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_playing(game->intro.audiostream, false);
|
||||||
|
@ -118,24 +117,24 @@ void Intro_Draw(struct Game *game) {
|
||||||
al_clear_to_color(al_map_rgb(0,0,0));
|
al_clear_to_color(al_map_rgb(0,0,0));
|
||||||
if (game->intro.in_animation) {
|
if (game->intro.in_animation) {
|
||||||
AnimPage(game, game->intro.page);
|
AnimPage(game, game->intro.page);
|
||||||
al_draw_bitmap(game->intro.table, -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(ALLEGRO_PI))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0);//al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_bitmap(game->intro.table, -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(ALLEGRO_PI))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0);
|
||||||
al_draw_bitmap(game->intro.animation, -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(ALLEGRO_PI))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0);//al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_bitmap(game->intro.animation, -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(ALLEGRO_PI))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AnimPage(game, game->intro.page+1);
|
AnimPage(game, game->intro.page+1);
|
||||||
al_draw_bitmap(game->intro.table, 0, 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_bitmap(game->intro.table, 0, 0, 0);
|
||||||
al_draw_bitmap(game->intro.animation, 0, 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_bitmap(game->intro.animation, 0, 0, 0);
|
||||||
}
|
}
|
||||||
al_draw_text_with_shadow(game->intro.font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.90, ALLEGRO_ALIGN_CENTRE, "Press any key to continue or escape to skip...");
|
al_draw_text_with_shadow(game->intro.font, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, al_get_display_height(game->display)*0.90, ALLEGRO_ALIGN_CENTRE, "Press any key to continue or escape to skip...");
|
||||||
//PrintConsole(game, "drawing");
|
/*PrintConsole(game, "drawing");*/
|
||||||
if (game->intro.in_animation) {
|
if (game->intro.in_animation) {
|
||||||
//PrintConsole(game, "animating");
|
/*PrintConsole(game, "animating");*/
|
||||||
int old = game->intro.position%al_get_display_width(game->display);
|
int old = game->intro.position%al_get_display_width(game->display);
|
||||||
game->intro.position -= tps(game, 600);
|
game->intro.position -= tps(game, 600);
|
||||||
//PrintConsole(game, "%d", game->intro.position%al_get_display_width(game->display));
|
/*PrintConsole(game, "%d", game->intro.position%al_get_display_width(game->display));*/
|
||||||
if (game->intro.position%al_get_display_width(game->display)>old) {
|
if (game->intro.position%al_get_display_width(game->display)>old) {
|
||||||
//DrawConsole(game);
|
/*DrawConsole(game);
|
||||||
//al_flip_display();
|
al_flip_display();*/
|
||||||
game->intro.in_animation = false;
|
game->intro.in_animation = false;
|
||||||
FillPage(game, game->intro.page+1);
|
FillPage(game, game->intro.page+1);
|
||||||
PrintConsole(game, "Animation finished.");
|
PrintConsole(game, "Animation finished.");
|
||||||
|
@ -233,12 +232,12 @@ void Intro_Unload(struct Game *game) {
|
||||||
for(fadeloop=255; fadeloop>=0; fadeloop-=tps(game, 600)){
|
for(fadeloop=255; fadeloop>=0; fadeloop-=tps(game, 600)){
|
||||||
al_wait_for_event(game->event_queue, &ev);
|
al_wait_for_event(game->event_queue, &ev);
|
||||||
if (game->intro.in_animation) {
|
if (game->intro.in_animation) {
|
||||||
al_draw_tinted_bitmap(game->intro.table, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(3.1415))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_tinted_bitmap(game->intro.table, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(3.1415))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0);
|
||||||
al_draw_tinted_bitmap(game->intro.animation, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(3.1415))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_tinted_bitmap(game->intro.animation, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), -1*al_get_display_width(game->display) + (cos(((-1*((game->intro.position)%al_get_display_width(game->display)))/(float)al_get_display_width(game->display))*(3.1415))/2.0)*al_get_display_width(game->display) + al_get_display_width(game->display)/2.0, 0, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
al_draw_tinted_bitmap(game->intro.table, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_tinted_bitmap(game->intro.table, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0);
|
||||||
al_draw_tinted_bitmap(game->intro.animation, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0); //al_get_display_height(game->display)*((game->intro.position/3.0)/(float)al_get_display_width(game->display)), 0);
|
al_draw_tinted_bitmap(game->intro.animation, al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1), 0, 0, 0);
|
||||||
}
|
}
|
||||||
DrawConsole(game);
|
DrawConsole(game);
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
|
|
42
src/level.c
42
src/level.c
|
@ -25,7 +25,7 @@
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
#include "timeline.h"
|
#include "timeline.h"
|
||||||
|
|
||||||
// TODO: fix spritesheet speed to not depend on FPS
|
/* TODO: check if spritesheet speed still depends on FPS */
|
||||||
|
|
||||||
void Level_Passed(struct Game *game) {
|
void Level_Passed(struct Game *game) {
|
||||||
if (game->level.current_level<6) {
|
if (game->level.current_level<6) {
|
||||||
|
@ -77,7 +77,6 @@ bool Stop(struct Game *game, struct TM_Action *action, enum TM_ActionState state
|
||||||
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
if (state != TM_ACTIONSTATE_RUNNING) return false;
|
||||||
game->level.speed=0;
|
game->level.speed=0;
|
||||||
game->level.sheet_speed = 0;
|
game->level.sheet_speed = 0;
|
||||||
//game->level.sheet_pos = 0;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,11 +104,11 @@ void Level_Draw(struct Game *game) {
|
||||||
if (game->level.handle_input) {
|
if (game->level.handle_input) {
|
||||||
if (al_key_down(&keyboard, ALLEGRO_KEY_UP)) {
|
if (al_key_down(&keyboard, ALLEGRO_KEY_UP)) {
|
||||||
game->level.derpy_y -= 0.005;
|
game->level.derpy_y -= 0.005;
|
||||||
//PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);
|
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
||||||
}
|
}
|
||||||
if (al_key_down(&keyboard, ALLEGRO_KEY_DOWN)) {
|
if (al_key_down(&keyboard, ALLEGRO_KEY_DOWN)) {
|
||||||
game->level.derpy_y += 0.005;
|
game->level.derpy_y += 0.005;
|
||||||
//PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);
|
/*PrintConsole(game, "Derpy Y position: %f", game->level.derpy_y);*/
|
||||||
}
|
}
|
||||||
if (game->level.derpy_y > 0.5) game->level.sheet_speed = 0.0020/game->level.speed;
|
if (game->level.derpy_y > 0.5) game->level.sheet_speed = 0.0020/game->level.speed;
|
||||||
else game->level.sheet_speed=0;
|
else game->level.sheet_speed=0;
|
||||||
|
@ -129,17 +128,12 @@ void Level_Draw(struct Game *game) {
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
al_draw_bitmap_region(game->level.derpy_walkcycle,al_get_bitmap_width(game->level.derpy)*(game->level.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(game->level.derpy_walkcycle,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);
|
||||||
if (game->level.sheet_speed) {
|
if (game->level.sheet_speed) {
|
||||||
//int i;
|
game->level.sheet_tmp+=tps(game, 60);
|
||||||
//for (i = 0; i < tps(game, 60); i++ ) {
|
if (game->level.sheet_tmp >= game->level.sheet_speed) {
|
||||||
game->level.sheet_tmp+=tps(game, 60);
|
game->level.sheet_pos++;
|
||||||
//if (game->level.sheet_speed==1) game->level.sheet_pos++;
|
game->level.sheet_tmp = 0;
|
||||||
if (game->level.sheet_tmp >= game->level.sheet_speed) {
|
}
|
||||||
game->level.sheet_pos++;
|
if (game->level.sheet_pos>=game->level.sheet_cols*game->level.sheet_rows) game->level.sheet_pos=0;
|
||||||
game->level.sheet_tmp = 0;
|
|
||||||
//game->level.sheet_tmp -= game->level.sheet_speed;
|
|
||||||
}
|
|
||||||
if (game->level.sheet_pos>=game->level.sheet_cols*game->level.sheet_rows) game->level.sheet_pos=0;
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
|
||||||
|
@ -231,18 +225,16 @@ bool Welcome(struct Game *game, struct TM_Action *action, enum TM_ActionState st
|
||||||
if (state == TM_ACTIONSTATE_INIT) {
|
if (state == TM_ACTIONSTATE_INIT) {
|
||||||
*tmp = 0;
|
*tmp = 0;
|
||||||
*in = true;
|
*in = true;
|
||||||
//PrintConsole(game, "WELCOME INIT");
|
/*PrintConsole(game, "WELCOME INIT");*/
|
||||||
}
|
}
|
||||||
else if (state == TM_ACTIONSTATE_RUNNING) {
|
else if (state == TM_ACTIONSTATE_RUNNING) {
|
||||||
//al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), *tmp, 20, 0, "Level 1");
|
/*PrintConsole(game, "WELCOME RUNNING FADE=%f, IN=%d", *in); */
|
||||||
//PrintConsole(game, "WELCOME RUNNING FADE=%f, IN=%d", *in);
|
|
||||||
int fade = *tmp;
|
int fade = *tmp;
|
||||||
if (fade>255) fade=255;
|
if (fade>255) fade=255;
|
||||||
if (*tmp > 2048) { *tmp=255; *in=false; }
|
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);
|
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) {
|
if (*in) {
|
||||||
*tmp+=tps(game, 600);
|
*tmp+=tps(game, 600);
|
||||||
//if (*tmp>=256) { return false; }
|
|
||||||
} else {
|
} else {
|
||||||
*tmp-=tps(game, 600);
|
*tmp-=tps(game, 600);
|
||||||
if (*tmp<=0) { return true; }
|
if (*tmp<=0) { return true; }
|
||||||
|
@ -294,15 +286,18 @@ void Level_Load(struct Game *game) {
|
||||||
TM_AddDelay(500);
|
TM_AddDelay(500);
|
||||||
TM_AddQueuedBackgroundAction(&Accelerate, NULL, 0, "accelerate");
|
TM_AddQueuedBackgroundAction(&Accelerate, NULL, 0, "accelerate");
|
||||||
TM_AddAction(&Fly, NULL, "fly");
|
TM_AddAction(&Fly, NULL, "fly");
|
||||||
// Derpy walks in... (background - owl)
|
/*
|
||||||
|
// Derpy walks in... (background - owl)
|
||||||
// Derpy reads a letter
|
// Derpy reads a letter
|
||||||
// Letter on screen
|
// Letter on screen
|
||||||
// Derpy: fly! (background - accelerate)
|
// Derpy: fly! (background - accelerate)
|
||||||
|
*/
|
||||||
|
|
||||||
// first part gameplay goes here
|
/* first part gameplay goes here */
|
||||||
TM_AddDelay(60*1000);
|
TM_AddDelay(60*1000);
|
||||||
|
|
||||||
// wings disappear, deccelerate, fall down
|
/*
|
||||||
|
// wings disappear, deccelerate, fall down
|
||||||
// run
|
// run
|
||||||
// show Fluttershy's house
|
// show Fluttershy's house
|
||||||
|
|
||||||
|
@ -311,6 +306,7 @@ void Level_Load(struct Game *game) {
|
||||||
|
|
||||||
// cutscene goes here
|
// cutscene goes here
|
||||||
//
|
//
|
||||||
|
*/
|
||||||
|
|
||||||
TM_AddAction(&PassLevel, NULL, "passlevel");
|
TM_AddAction(&PassLevel, NULL, "passlevel");
|
||||||
}
|
}
|
||||||
|
@ -381,7 +377,7 @@ void Level_PreloadBitmaps(struct Game *game) {
|
||||||
game->level.derpy = al_create_bitmap(al_get_display_width(game->display)*0.1953125, al_get_display_height(game->display)*0.25);
|
game->level.derpy = al_create_bitmap(al_get_display_width(game->display)*0.1953125, al_get_display_height(game->display)*0.25);
|
||||||
if (game->level.current_level!=1) Moonwalk_PreloadBitmaps(game);
|
if (game->level.current_level!=1) Moonwalk_PreloadBitmaps(game);
|
||||||
else {
|
else {
|
||||||
// TODO: handle strange display aspects
|
/* TODO: handle strange display aspects */
|
||||||
game->level.clouds = LoadScaledBitmap("levels/1/clouds.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display));
|
game->level.clouds = LoadScaledBitmap("levels/1/clouds.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display));
|
||||||
game->level.foreground = LoadScaledBitmap("levels/1/foreground.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display));
|
game->level.foreground = LoadScaledBitmap("levels/1/foreground.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display));
|
||||||
game->level.background = LoadScaledBitmap("levels/1/background.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display));
|
game->level.background = LoadScaledBitmap("levels/1/background.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display));
|
||||||
|
|
|
@ -47,15 +47,11 @@ void Loading_Draw(struct Game *game) {
|
||||||
al_clear_to_color(al_map_rgb(0,0,0));
|
al_clear_to_color(al_map_rgb(0,0,0));
|
||||||
DrawConsole(game);
|
DrawConsole(game);
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
//al_rest(0.2);
|
|
||||||
LoadGameState(game);
|
LoadGameState(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Loading_Load(struct Game *game) {
|
void Loading_Load(struct Game *game) {
|
||||||
al_clear_to_color(al_map_rgb(0,0,0));
|
al_clear_to_color(al_map_rgb(0,0,0));
|
||||||
//al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.0234, al_get_display_height(game->display)*0.85, ALLEGRO_ALIGN_LEFT, "Loading...");
|
|
||||||
//DrawConsole(game);
|
|
||||||
//al_flip_display();
|
|
||||||
|
|
||||||
game->loading.loading_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
game->loading.loading_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||||
|
|
||||||
|
|
34
src/main.c
34
src/main.c
|
@ -75,7 +75,6 @@ void PrintConsole(struct Game *game, char* format, ...) {
|
||||||
al_draw_text(game->font_console, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.005, al_get_bitmap_height(game->console)*0.81, ALLEGRO_ALIGN_LEFT, text);
|
al_draw_text(game->font_console, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.005, al_get_bitmap_height(game->console)*0.81, ALLEGRO_ALIGN_LEFT, text);
|
||||||
al_set_target_bitmap(game->console);
|
al_set_target_bitmap(game->console);
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
//al_draw_bitmap_region(game->console, 0, al_get_bitmap_height(game->console)*0.2, al_get_bitmap_width(game->console), al_get_bitmap_height(game->console)*0.8, 0, 0, 0);
|
|
||||||
al_draw_bitmap(con, 0, 0, 0);
|
al_draw_bitmap(con, 0, 0, 0);
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
al_destroy_bitmap(con);
|
al_destroy_bitmap(con);
|
||||||
|
@ -173,7 +172,7 @@ void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height) {
|
||||||
al_lock_bitmap(al_get_target_bitmap(), ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
|
al_lock_bitmap(al_get_target_bitmap(), ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
|
||||||
al_lock_bitmap(source, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
|
al_lock_bitmap(source, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
|
||||||
|
|
||||||
//linear filtering code written by SiegeLord
|
/* linear filtering code written by SiegeLord */
|
||||||
|
|
||||||
ALLEGRO_COLOR interpolate(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) {
|
ALLEGRO_COLOR interpolate(ALLEGRO_COLOR c1, ALLEGRO_COLOR c2, float frac) {
|
||||||
return al_map_rgba_f(c1.r + frac * (c2.r - c1.r),
|
return al_map_rgba_f(c1.r + frac * (c2.r - c1.r),
|
||||||
|
@ -210,9 +209,9 @@ ALLEGRO_BITMAP* LoadScaledBitmap(char* filename, int width, int height) {
|
||||||
al_set_target_bitmap(target);
|
al_set_target_bitmap(target);
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
char origfn[255] = "data/";
|
char origfn[255] = "data/";
|
||||||
//char cachefn[255] = "data/cache/";
|
/*char cachefn[255] = "data/cache/";*/
|
||||||
strcat(origfn, filename);
|
strcat(origfn, filename);
|
||||||
//strcat(cachefn, filename);
|
/*strcat(cachefn, filename);*/
|
||||||
void GenerateBitmap() {
|
void GenerateBitmap() {
|
||||||
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
|
al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);
|
||||||
|
|
||||||
|
@ -220,21 +219,21 @@ ALLEGRO_BITMAP* LoadScaledBitmap(char* filename, int width, int height) {
|
||||||
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
|
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
|
||||||
|
|
||||||
ScaleBitmap(source, width, height);
|
ScaleBitmap(source, width, height);
|
||||||
//al_save_bitmap(cachefn, target);
|
/*al_save_bitmap(cachefn, target);
|
||||||
//PrintConsole(game, "Cache bitmap %s generated.", filename);
|
PrintConsole(game, "Cache bitmap %s generated.", filename);*/
|
||||||
al_destroy_bitmap(source);
|
al_destroy_bitmap(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
//source = al_load_bitmap( cachefn );
|
/*source = al_load_bitmap( cachefn );
|
||||||
//if (source) {
|
if (source) {
|
||||||
// if ((al_get_bitmap_width(source)!=width) || (al_get_bitmap_height(source)!=height)) {
|
if ((al_get_bitmap_width(source)!=width) || (al_get_bitmap_height(source)!=height)) {
|
||||||
// al_destroy_bitmap(source);
|
al_destroy_bitmap(source);*/
|
||||||
GenerateBitmap();
|
GenerateBitmap();
|
||||||
return target;
|
return target;
|
||||||
// }
|
/* }
|
||||||
// return source;
|
return source;
|
||||||
//} else GenerateBitmap();
|
} else GenerateBitmap();
|
||||||
//return target;
|
return target;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
float tps(struct Game *game, float t) {
|
float tps(struct Game *game, float t) {
|
||||||
|
@ -299,8 +298,8 @@ int main(int argc, char **argv){
|
||||||
|
|
||||||
if(!al_init_image_addon()) {
|
if(!al_init_image_addon()) {
|
||||||
fprintf(stderr, "failed to initialize image addon!\n");
|
fprintf(stderr, "failed to initialize image addon!\n");
|
||||||
//al_show_native_message_box(display, "Error", "Error", "Failed to initialize al_init_image_addon!",
|
/*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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +333,7 @@ int main(int argc, char **argv){
|
||||||
if (game.fullscreen) al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW);
|
if (game.fullscreen) al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW);
|
||||||
else al_set_new_display_flags(ALLEGRO_WINDOWED);
|
else al_set_new_display_flags(ALLEGRO_WINDOWED);
|
||||||
al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST);
|
al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST);
|
||||||
//al_set_new_display_option(ALLEGRO_OPENGL, 1, ALLEGRO_SUGGEST);
|
/*al_set_new_display_option(ALLEGRO_OPENGL, 1, ALLEGRO_SUGGEST);*/
|
||||||
game.display = al_create_display(game.width, game.height);
|
game.display = al_create_display(game.width, game.height);
|
||||||
if(!game.display) {
|
if(!game.display) {
|
||||||
fprintf(stderr, "failed to create display!\n");
|
fprintf(stderr, "failed to create display!\n");
|
||||||
|
@ -345,7 +344,6 @@ int main(int argc, char **argv){
|
||||||
al_inhibit_screensaver(true);
|
al_inhibit_screensaver(true);
|
||||||
|
|
||||||
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
|
al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR);
|
||||||
//al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA);
|
|
||||||
|
|
||||||
int ret = Shared_Load(&game);
|
int ret = Shared_Load(&game);
|
||||||
if (ret!=0) return ret;
|
if (ret!=0) return ret;
|
||||||
|
|
|
@ -238,7 +238,6 @@ void PrintConsole(struct Game *game, char* format, ...);
|
||||||
/*! \brief Draws console bitmap on screen. */
|
/*! \brief Draws console bitmap on screen. */
|
||||||
void DrawConsole(struct Game *game);
|
void DrawConsole(struct Game *game);
|
||||||
|
|
||||||
//void ScaleBitmap(ALLEGRO_BITMAP* source, int width, int height);
|
|
||||||
ALLEGRO_BITMAP* LoadScaledBitmap(char* filename, int width, int height);
|
ALLEGRO_BITMAP* LoadScaledBitmap(char* filename, int width, int height);
|
||||||
float tps(struct Game *game, float t);
|
float tps(struct Game *game, float t);
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,6 @@ void Map_Unload(struct Game *game) {
|
||||||
al_flip_display();
|
al_flip_display();
|
||||||
}
|
}
|
||||||
al_destroy_bitmap(game->map.map);
|
al_destroy_bitmap(game->map.map);
|
||||||
//al_destroy_bitmap(game->map.background);
|
|
||||||
al_destroy_bitmap(game->map.map_bg);
|
al_destroy_bitmap(game->map.map_bg);
|
||||||
al_destroy_bitmap(game->map.highlight);
|
al_destroy_bitmap(game->map.highlight);
|
||||||
al_destroy_bitmap(game->map.arrow);
|
al_destroy_bitmap(game->map.arrow);
|
||||||
|
|
|
@ -110,13 +110,12 @@ void Menu_Draw(struct Game *game) {
|
||||||
|
|
||||||
al_set_target_bitmap(game->menu.pinkcloud_bitmap);
|
al_set_target_bitmap(game->menu.pinkcloud_bitmap);
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
float x = 1.5;//*(rand() / (float)RAND_MAX);
|
float x = 1.5;
|
||||||
int minus;
|
int minus;
|
||||||
if (game->menu.cloud_position>0) minus=1; else minus=-1;
|
if (game->menu.cloud_position>0) minus=1; else minus=-1;
|
||||||
al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*5+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.7, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.88+(fmod(-1.8*(game->menu.cloud_position+80), 6))/20.0), 0);
|
al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*5+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.7, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.88+(fmod(-1.8*(game->menu.cloud_position+80), 6))/20.0), 0);
|
||||||
al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*3+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/3.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.78+(fmod(-2.8*(game->menu.cloud_position+80), 4))/18.0), 0);
|
al_draw_bitmap(game->menu.rain_bitmap, fmod(minus*game->menu.cloud_position,3)*x*3+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/3.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.78+(fmod(-2.8*(game->menu.cloud_position+80), 4))/18.0), 0);
|
||||||
al_draw_scaled_bitmap(game->menu.rain_bitmap, 0, 0, al_get_bitmap_width(game->menu.rain_bitmap), al_get_bitmap_height(game->menu.rain_bitmap), fmod(minus*game->menu.cloud_position,3)*x*6+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.87+(fmod(-4.9*(game->menu.cloud_position+80), 8))/26.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.08, 0);
|
al_draw_scaled_bitmap(game->menu.rain_bitmap, 0, 0, al_get_bitmap_width(game->menu.rain_bitmap), al_get_bitmap_height(game->menu.rain_bitmap), fmod(minus*game->menu.cloud_position,3)*x*6+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.1, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.87+(fmod(-4.9*(game->menu.cloud_position+80), 8))/26.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.08, 0);
|
||||||
//al_draw_scaled_bitmap(game->menu.rain, 0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), fmod(minus*game->menu.cloud_position,3)*x*6+al_get_bitmap_width(game->menu.pinkcloud_bitmap)/2.4, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*(0.9+(fmod(-5*(game->menu.cloud_position+86), 8))/20.0), al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.35, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.07, 0);
|
|
||||||
al_draw_bitmap(game->menu.pinkcloud, 0, 0, 0);
|
al_draw_bitmap(game->menu.pinkcloud, 0, 0, 0);
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
|
|
||||||
|
@ -196,9 +195,9 @@ void Menu_Preload(struct Game *game) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
game->menu.pinkcloud_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.33125, al_get_display_height(game->display)); // *0.8122);
|
game->menu.pinkcloud_bitmap = al_create_bitmap(al_get_display_width(game->display)*0.33125, al_get_display_height(game->display));
|
||||||
|
|
||||||
game->menu.pie_bitmap = al_create_bitmap(al_get_display_width(game->display)/2, al_get_display_height(game->display)); //*0.8122);
|
game->menu.pie_bitmap = al_create_bitmap(al_get_display_width(game->display)/2, al_get_display_height(game->display));
|
||||||
al_set_target_bitmap(game->menu.pie_bitmap);
|
al_set_target_bitmap(game->menu.pie_bitmap);
|
||||||
al_clear_to_color(al_map_rgba(0,0,0,0));
|
al_clear_to_color(al_map_rgba(0,0,0,0));
|
||||||
al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.5, 0, al_get_display_width(game->display)*0.11875, al_get_display_height(game->display)*0.0825, 0);
|
al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.5, 0, al_get_display_width(game->display)*0.11875, al_get_display_height(game->display)*0.0825, 0);
|
||||||
|
@ -223,7 +222,6 @@ void Menu_Stop(struct Game* game) {
|
||||||
ALLEGRO_EVENT ev;
|
ALLEGRO_EVENT ev;
|
||||||
float fadeloop;
|
float fadeloop;
|
||||||
for(fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)){
|
for(fadeloop=0; fadeloop<256; fadeloop+=tps(game, 600)){
|
||||||
//if ((game->menu.draw_while_fading) || (fadeloop==255)) {
|
|
||||||
al_wait_for_event(game->event_queue, &ev);
|
al_wait_for_event(game->event_queue, &ev);
|
||||||
Menu_Draw(game);
|
Menu_Draw(game);
|
||||||
al_draw_tinted_bitmap(game->menu.menu_fade_bitmap,al_map_rgba_f(1,1,1,fadeloop/255.0),0,0,0);
|
al_draw_tinted_bitmap(game->menu.menu_fade_bitmap,al_map_rgba_f(1,1,1,fadeloop/255.0),0,0,0);
|
||||||
|
|
|
@ -35,11 +35,9 @@ void Moonwalk_Draw(struct Game *game) {
|
||||||
if (game->level.current_level<6) {
|
if (game->level.current_level<6) {
|
||||||
game->gamestate = GAMESTATE_LOADING;
|
game->gamestate = GAMESTATE_LOADING;
|
||||||
game->loadstate = GAMESTATE_MAP;
|
game->loadstate = GAMESTATE_MAP;
|
||||||
//LoadGameState(game);
|
|
||||||
} else {
|
} else {
|
||||||
game->gamestate = GAMESTATE_LOADING;
|
game->gamestate = GAMESTATE_LOADING;
|
||||||
game->loadstate = GAMESTATE_ABOUT;
|
game->loadstate = GAMESTATE_ABOUT;
|
||||||
//LoadGameState(game);
|
|
||||||
}
|
}
|
||||||
return; }
|
return; }
|
||||||
int i;
|
int i;
|
||||||
|
|
|
@ -79,7 +79,6 @@ void Pause_Load(struct Game* game) {
|
||||||
al_clear_to_color(al_map_rgb(0,0,0));
|
al_clear_to_color(al_map_rgb(0,0,0));
|
||||||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||||
al_draw_tinted_bitmap(fade,al_map_rgba_f(1,1,1,0.75),0,0,0);
|
al_draw_tinted_bitmap(fade,al_map_rgba_f(1,1,1,0.75),0,0,0);
|
||||||
//al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.5, ALLEGRO_ALIGN_CENTRE,"Game paused!");
|
|
||||||
game->pause.bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
game->pause.bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display));
|
||||||
al_set_target_bitmap(game->pause.bitmap);
|
al_set_target_bitmap(game->pause.bitmap);
|
||||||
al_draw_bitmap(al_get_backbuffer(game->display), 0, 0, 0);
|
al_draw_bitmap(al_get_backbuffer(game->display), 0, 0, 0);
|
||||||
|
|
|
@ -39,8 +39,10 @@ void TM_Init(struct Game* g) {
|
||||||
void TM_Process() {
|
void TM_Process() {
|
||||||
if (!game) return;
|
if (!game) return;
|
||||||
if (paused) 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) {
|
||||||
if (*queue->function) {
|
if (*queue->function) {
|
||||||
queue->active = true;
|
queue->active = true;
|
||||||
|
@ -55,7 +57,7 @@ void TM_Process() {
|
||||||
if (queue) PrintConsole(game, "Timeline Manager: queue: run action (%d - %s)", queue->id, queue->name);
|
if (queue) PrintConsole(game, "Timeline Manager: queue: run action (%d - %s)", queue->id, queue->name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// delay
|
/* delay handling */
|
||||||
if (queue->active) {
|
if (queue->active) {
|
||||||
struct TM_Action *tmp = queue;
|
struct TM_Action *tmp = queue;
|
||||||
queue = queue->next;
|
queue = queue->next;
|
||||||
|
@ -67,7 +69,7 @@ void TM_Process() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// process all elements from background marked as active
|
/* process all elements from background marked as active */
|
||||||
struct TM_Action *tmp, *tmp2, *pom = background;
|
struct TM_Action *tmp, *tmp2, *pom = background;
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
while (pom!=NULL) {
|
while (pom!=NULL) {
|
||||||
|
@ -84,7 +86,7 @@ void TM_Process() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// delay
|
/* delay handling */
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
tmp->next = pom->next;
|
tmp->next = pom->next;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,7 +30,6 @@ enum TM_ActionState {
|
||||||
struct TM_Arguments {
|
struct TM_Arguments {
|
||||||
void *value;
|
void *value;
|
||||||
struct TM_Arguments *next;
|
struct TM_Arguments *next;
|
||||||
//*prev;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TM_Action {
|
struct TM_Action {
|
||||||
|
@ -42,7 +41,6 @@ struct TM_Action {
|
||||||
struct TM_Action *next;
|
struct TM_Action *next;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
char* name;
|
char* name;
|
||||||
//*prev;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void TM_Init(struct Game* game);
|
void TM_Init(struct Game* game);
|
||||||
|
|
Loading…
Reference in a new issue