mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2025-02-01 02:56:43 +01:00
make string formatting in PrintConsole possible and use it
This commit is contained in:
parent
b3a3898bb1
commit
edd4d79eb9
5 changed files with 21 additions and 16 deletions
2
bin/.gitignore
vendored
2
bin/.gitignore
vendored
|
@ -1 +1 @@
|
|||
*.o
|
||||
*
|
||||
|
|
|
@ -49,9 +49,8 @@ int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
return 0;
|
||||
}
|
||||
if (!game->intro.in_animation) {
|
||||
PrintConsole(game, "Animate page...");
|
||||
PrintConsole(game, "Animate page (was on %d)...", ++game->intro.page);
|
||||
game->intro.in_animation = true;
|
||||
game->intro.page++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -73,9 +72,9 @@ void Intro_Preload(struct Game *game) {
|
|||
//game->intro.table_bitmap = al_load_bitmap( "table.png" );
|
||||
al_draw_scaled_bitmap(game->intro.table_bitmap, 0, 0, al_get_bitmap_width(game->intro.table_bitmap), al_get_bitmap_height(game->intro.table_bitmap), al_get_display_width(game->display), 0, al_get_display_width(game->display), al_get_display_height(game->display), ALLEGRO_FLIP_HORIZONTAL);
|
||||
//game->intro.table_bitmap = al_load_bitmap( "menu.png" );
|
||||
al_draw_scaled_bitmap(game->intro.table_bitmap, 0, 0, al_get_bitmap_width(game->intro.table_bitmap), al_get_bitmap_height(game->intro.table_bitmap), al_get_display_width(game->display)*2, 0, al_get_display_width(game->display), al_get_display_height(game->display), 0);
|
||||
al_draw_scaled_bitmap(game->intro.table_bitmap, 0, 0, al_get_bitmap_width(game->intro.table_bitmap), al_get_bitmap_height(game->intro.table_bitmap), al_get_display_width(game->display)*2, 0, al_get_display_width(game->display), al_get_display_height(game->display), ALLEGRO_FLIP_VERTICAL);
|
||||
//game->intro.table_bitmap = al_load_bitmap( "table.png" );
|
||||
al_draw_scaled_bitmap(game->intro.table_bitmap, 0, 0, al_get_bitmap_width(game->intro.table_bitmap), al_get_bitmap_height(game->intro.table_bitmap), al_get_display_width(game->display)*3, 0, al_get_display_width(game->display), al_get_display_height(game->display), ALLEGRO_FLIP_HORIZONTAL);
|
||||
al_draw_scaled_bitmap(game->intro.table_bitmap, 0, 0, al_get_bitmap_width(game->intro.table_bitmap), al_get_bitmap_height(game->intro.table_bitmap), al_get_display_width(game->display)*3, 0, al_get_display_width(game->display), al_get_display_height(game->display), ALLEGRO_FLIP_HORIZONTAL^ALLEGRO_FLIP_VERTICAL);
|
||||
|
||||
al_draw_text(game->intro.font, al_map_rgb(255,255,255), al_get_bitmap_width(game->intro.table_bitmap)*0.5, al_get_bitmap_height(game->intro.table_bitmap)*0.3, ALLEGRO_ALIGN_LEFT, "Tekst.");
|
||||
al_draw_text(game->intro.font, al_map_rgb(255,255,255), al_get_bitmap_width(game->intro.table_bitmap)*0.5, al_get_bitmap_height(game->intro.table_bitmap)*0.37, ALLEGRO_ALIGN_LEFT, "Drugi tekst.");
|
||||
|
|
20
src/main.c
20
src/main.c
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "menu.h"
|
||||
#include "loading.h"
|
||||
#include "about.h"
|
||||
|
@ -11,7 +12,12 @@ int DISPLAY_HEIGHT = 500;
|
|||
bool FULLSCREEN = true;
|
||||
bool DEBUG_MODE = true;
|
||||
|
||||
void PrintConsole(struct Game *game, char* text) {
|
||||
void PrintConsole(struct Game *game, char* format, ...) {
|
||||
va_list vl;
|
||||
va_start(vl, format);
|
||||
char text[255] = {};
|
||||
vsprintf(text, format, vl);
|
||||
va_end(vl);
|
||||
if (DEBUG_MODE) printf("%s\n", text);
|
||||
ALLEGRO_BITMAP *con = al_create_bitmap(al_get_bitmap_width(game->console), al_get_bitmap_height(game->console)*1.0);
|
||||
al_set_target_bitmap(con);
|
||||
|
@ -61,7 +67,7 @@ void PreloadGameState(struct Game *game) {
|
|||
al_flip_display();
|
||||
Map_Preload(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to preload unknown gamestate!");
|
||||
PrintConsole(game, "ERROR: Attempted to preload unknown gamestate %d!", game->gamestate);
|
||||
}
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
|
@ -87,7 +93,7 @@ void UnloadGameState(struct Game *game) {
|
|||
PrintConsole(game, "Unload GAMESTATE_MAP...");
|
||||
Map_Unload(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate!");
|
||||
PrintConsole(game, "ERROR: Attempted to unload unknown gamestate %d!", game->gamestate);
|
||||
}
|
||||
PrintConsole(game, "finished");
|
||||
}
|
||||
|
@ -113,7 +119,7 @@ void LoadGameState(struct Game *game) {
|
|||
PrintConsole(game, "Load GAMESTATE_MAP...");
|
||||
Map_Load(game);
|
||||
} else {
|
||||
PrintConsole(game, "ERROR: Attempted to load unknown gamestate!");
|
||||
PrintConsole(game, "ERROR: Attempted to load unknown gamestate %d!", game->gamestate);
|
||||
}
|
||||
PrintConsole(game, "finished");
|
||||
game->gamestate = game->loadstate;
|
||||
|
@ -181,7 +187,7 @@ int main(int argc, char **argv){
|
|||
return -1;
|
||||
}
|
||||
al_set_window_title(game.display, "Super Derpy: Muffin Attack");
|
||||
al_hide_mouse_cursor(game.display);
|
||||
if (FULLSCREEN) al_hide_mouse_cursor(game.display);
|
||||
game.font = al_load_ttf_font("data/ShadowsIntoLight.ttf",al_get_display_height(game.display)*0.09,0 );
|
||||
game.font_console = al_load_ttf_font("data/DejaVuSansMono.ttf",al_get_display_height(game.display)*0.018,0 );
|
||||
|
||||
|
@ -243,7 +249,7 @@ int main(int argc, char **argv){
|
|||
}
|
||||
else {
|
||||
game.showconsole = true;
|
||||
PrintConsole(&game, "ERROR: Keystroke in unknown gamestate! (5 sec sleep)");
|
||||
PrintConsole(&game, "ERROR: Keystroke in unknown (%d) gamestate! (5 sec sleep)", game.gamestate);
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
al_rest(5.0);
|
||||
|
@ -272,7 +278,7 @@ int main(int argc, char **argv){
|
|||
}
|
||||
else {
|
||||
game.showconsole = true;
|
||||
PrintConsole(&game, "ERROR: Unknown gamestate reached! (5 sec sleep)");
|
||||
PrintConsole(&game, "ERROR: Unknown gamestate %d reached! (5 sec sleep)", game.gamestate);
|
||||
DrawConsole(&game);
|
||||
al_flip_display();
|
||||
al_rest(5.0);
|
||||
|
|
|
@ -72,7 +72,7 @@ struct Game {
|
|||
void PreloadGameState(struct Game *game);
|
||||
void UnloadGameState(struct Game *game);
|
||||
void LoadGameState(struct Game *game);
|
||||
void PrintConsole(struct Game *game, char* text);
|
||||
void PrintConsole(struct Game *game, char* format, ...);
|
||||
void DrawConsole(struct Game *game);
|
||||
|
||||
#endif
|
|
@ -21,8 +21,8 @@ void Menu_Draw(struct Game *game) {
|
|||
al_set_target_bitmap(al_get_backbuffer(game->display));
|
||||
|
||||
al_clear_to_color(al_map_rgb(183,234,193));
|
||||
float tint = (sin((game->menu.cloud_position-30)/15)+1)/2;
|
||||
if (tint < 0.0001) { PrintConsole(game, "random tint"); game->menu.mountain_position = (al_get_display_width(game->display)*(rand()/(float)RAND_MAX)/2)+al_get_display_width(game->display)/2; }
|
||||
float tint = (sin((game->menu.cloud_position-80)/15)+1)/2;
|
||||
if (tint < 0.000004) { PrintConsole(game, "random tint %f", tint); game->menu.mountain_position = (al_get_display_width(game->display)*(rand()/(float)RAND_MAX)/2)+al_get_display_width(game->display)/2; }
|
||||
al_draw_tinted_bitmap(game->menu.mountain_bitmap,al_map_rgba_f(tint,tint,tint,tint),game->menu.mountain_position, 0,0);
|
||||
al_draw_scaled_bitmap(game->menu.cloud_bitmap,0,0,al_get_bitmap_width(game->menu.cloud_bitmap), al_get_bitmap_height(game->menu.cloud_bitmap), al_get_display_width(game->display)*(sin((game->menu.cloud_position/40)-4.5)-0.3), al_get_display_height(game->display)*0.35, al_get_bitmap_width(game->menu.cloud_bitmap)/2, al_get_bitmap_height(game->menu.cloud_bitmap)/2,0);
|
||||
al_draw_bitmap(game->menu.cloud2_bitmap,al_get_display_width(game->display)*(game->menu.cloud2_position/100.0), al_get_display_height(game->display)/1.5,0);
|
||||
|
@ -211,7 +211,7 @@ int Menu_Keydown(struct Game *game, ALLEGRO_EVENT *ev) {
|
|||
al_play_sample(game->menu.click_sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
|
||||
game->menu.options=!game->menu.options;
|
||||
game->menu.selected=0;
|
||||
PrintConsole(game, "options state changed");
|
||||
PrintConsole(game, "options state changed %d", game->menu.options);
|
||||
}
|
||||
if (game->menu.selected==-1) game->menu.selected=3;
|
||||
if (game->menu.selected==4) game->menu.selected=0;
|
||||
|
|
Loading…
Reference in a new issue