Change cursor blinking and display messages on research

This commit is contained in:
Shadow15510 2021-06-06 18:05:30 +02:00
parent 64bc16a99d
commit cf70e26dd8
6 changed files with 17 additions and 12 deletions

Binary file not shown.

View File

@ -9,7 +9,7 @@
#include "display_engine.h"
int next_frame(struct game *current_game, int *dna_animation)
int next_frame(struct game *current_game, int *dna_animation, int *vaccine)
{
for (int i = 0; current_game->planes[i]; i++)
{
@ -65,8 +65,9 @@ int next_frame(struct game *current_game, int *dna_animation)
// Reset internal clock
current_game->time = 0;
// Display the first step of research
// Display message on research
if (!current_game->research && current_game->priority) message("LA RECHERHCE CONTRE VOTRE VIRUS COMMENCE !");
else if (!*vaccine && (current_game->research == current_game->limit)) {*vaccine = 1; message("LE VACCIN EST TERMINE."); }
// Update the game
current_game->dna = current_game->dna + 1 + floor(current_game->severity / 10);
@ -163,7 +164,8 @@ int callback_tick(volatile int *tick)
void message(char *msg)
{
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
key_event_t ev = {0};
display_message(msg);
getkey_opt(opt, NULL);
while (ev.key != KEY_ALPHA) ev = getkey_opt(opt, NULL);
}

View File

@ -5,7 +5,7 @@
// Duration for internal clock (ms)
#define ENGINE_TICK 50
#define CURSOR_TICK 75
#define CURSOR_TICK 110
#define DNA_ANIMATION_TICK 150
// Duration for DNA points and infectious model (ms)
@ -90,7 +90,7 @@ struct cursor
int get_inputs(const int background, int *mutation_menu, int *boost);
// next_frame : compute the plane's positions
int next_frame(struct game *current_game, int *dna_animation);
int next_frame(struct game *current_game, int *dna_animation, int *vaccine);
// rtc_key : get the key with RTC system
int rtc_key(void);

View File

@ -124,9 +124,7 @@ void display_mutation(const int table[4][8], const struct cursor c, const int mu
if (table[i][j]) dsubimage(j*16, i*16, &img_mutations, 16 * (mutation_menu - 1), 16 * (table[i][j] - 1), 15, 15, DIMAGE_NONE);
}
}
int to_display = 0;
if (c.display > 1) to_display = 1;
dsubimage((16 * c.x) - 1, (16 * c.y) - 1, &img_cursor, 0, 17 * (to_display), 17, 17, DIMAGE_NONE);
dsubimage((16 * c.x) - 1, (16 * c.y) - 1, &img_cursor, 0, 17 * (c.display), 17, 17, DIMAGE_NONE);
dupdate();
}

View File

@ -83,8 +83,11 @@ int main(void)
else
{
// Display stats at the end of the game
dclear(C_WHITE);
display_background(6);
display_foreground(6, &current_game, 0, 0);
dupdate();
sleep_ms(250);
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
getkey_opt(opt, NULL);
@ -139,7 +142,7 @@ static void title_screen(void)
int main_loop(struct game *current_game)
{
int background = 1, mutation_menu = 4;
int end = 0, to_save = 1, dna_animation = 0;
int end = 0, to_save = 1, dna_animation = 0, vaccine = 0;
static volatile int tick = 1;
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
@ -158,7 +161,7 @@ int main_loop(struct game *current_game)
dupdate();
// Compute the motion of planes, DNA points and infectious model
to_save = next_frame(current_game, &dna_animation);
to_save = next_frame(current_game, &dna_animation, &vaccine);
if (!to_save) return 0;
// Get inputs from the keyboard and manage it

View File

@ -63,7 +63,7 @@ void mutation_select(struct game *current_game, const int mutation_menu)
// Cursor blinking gestion
while (!tick) sleep();
tick = 0;
c.display = (c.display + 1) % 4;
c.display = (c.display + 1) % 2;
// Get and display the mutation menu
int table[4][8];
@ -72,6 +72,8 @@ void mutation_select(struct game *current_game, const int mutation_menu)
// Get the key
key = rtc_key();
if (key) {tick = 1; c.display = 1;}
// Manage input
if (key == KEY_ALPHA) end = 1;