Some changes

This commit is contained in:
Shadow15510 2021-06-06 18:07:22 +02:00
commit 7c59b327e8
6 changed files with 40 additions and 16 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,6 +65,10 @@ int next_frame(struct game *current_game, int *dna_animation)
// Reset internal clock
current_game->time = 0;
// 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);
if (current_game->dna > 30) current_game->dna = 30;
@ -160,7 +164,9 @@ int callback_tick(volatile int *tick)
void message(char *msg)
{
display_message(msg);
getkey();
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
key_event_t ev = {0};
display_message(msg);
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 150
#define CURSOR_TICK 110
#define DNA_ANIMATION_TICK 150
// Duration for DNA points and infectious model (ms)
@ -82,7 +82,7 @@ struct cursor
// Cursor's coordinates
int x, y;
// If the cursor should be displayed
// If the cursor should be displayed (0: display ; 1: hide)
int display;
};
@ -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

@ -39,6 +39,9 @@ void display_foreground(const int background, const struct game *current_game, c
{
dsubimage(current_game->planes[i]->x - 4, current_game->planes[i]->y - 4, &img_planes, 0, 8 * (current_game->planes[i]->direction - 1), 8, 8, DIMAGE_NONE);
}
// Display if boost is activated
if (current_game->boost) dprint(0, 0, C_BLACK, "+");
break;
case 2:
@ -67,6 +70,10 @@ void display_foreground(const int background, const struct game *current_game, c
dline(51, 60, 51 + length, 60, C_BLACK);
dline(51, 59, 51 + length, 59, C_BLACK);
// Display if boost is activated
if (current_game->boost) dprint(0, 0, C_BLACK, "+");
break;
case 3:

View File

@ -1,11 +1,7 @@
/*
Project name ......: Plague
<<<<<<< HEAD
Version ...........: 1.3.3
=======
Version ...........: 1.3.4
>>>>>>> dev
Last modification .: 5 June 2021
Version ...........: 1.3.5
Last modification .: 6 June 2021
code and assets provided with licence :
GNU General Public Licence v3.0
@ -24,7 +20,7 @@
#include "mutation_engine.h"
#include "save.h"
const char *VERSION = "1.3.4";
const char *VERSION = "1.3.5";
// title_screen : display the title screen
static void title_screen(void);
@ -84,7 +80,20 @@ int main(void)
int to_save = main_loop(&current_game);
if (to_save) gint_world_switch(GINT_CALL(write_save, (void *)&current_game));
else gint_world_switch(GINT_CALL(delete_save));
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);
gint_world_switch(GINT_CALL(delete_save));
}
// Free memory
free(current_game.grid.data);
@ -133,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));
@ -152,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

@ -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;