Better mecanics and end game gestion

This commit is contained in:
Shadow15510 2021-06-04 23:25:14 +02:00
parent 41dc6fa06a
commit 47a8f30a45
10 changed files with 43 additions and 25 deletions

Binary file not shown.

View File

@ -9,7 +9,7 @@
#include "display_engine.h"
void next_frame(struct game *current_game)
int next_frame(struct game *current_game)
{
for (int i = 0; current_game->planes[i]; i++)
{
@ -60,7 +60,7 @@ void next_frame(struct game *current_game)
current_game->time = 0;
// Update the game
current_game->dna = current_game->dna + 1 + floor(current_game->severity / 25);
current_game->dna = current_game->dna + 1 + floor(current_game->severity / 10);
if (current_game->dna > 30) current_game->dna = 30;
current_game->research += current_game->priority;
if (current_game->research > current_game->limit) current_game->research = current_game->limit;
@ -72,8 +72,10 @@ void next_frame(struct game *current_game)
{
if (current_game->humans[0]) message("VOUS AVEZ PERDU.");
else message("VOUS AVEZ GAGNE !");
return 0;
}
}
return 1;
}
@ -87,7 +89,11 @@ int get_inputs(const int background, int *mutation_menu)
*mutation_menu = 4;
return 3;
}
if (key == KEY_SQUARE) return 6;
if (key == KEY_SQUARE)
{
if (background == 1 || background == 2) return 6;
else if (background == 6) return 1;
}
if (key == KEY_ALPHA)
{

View File

@ -90,7 +90,7 @@ struct cursor
int get_inputs(const int background, int *mutation_menu);
// next_frame : compute the plane's positions
void next_frame(struct game *current_game);
int next_frame(struct game *current_game);
// rtc_key : get the key with RTC system
int rtc_key(void);

View File

@ -5,7 +5,7 @@
const struct mutation symptoms_data[14] =
{
{10, 10, 0, 2, 0, "NAUSEE", "DONNE DES NAUSEES"},
{15, 10, 0, 10, 0, "VOMISSEMENT", "PROVOQUE DES REJETS GESTRIQUES"},
{15, 10, 0, 10, 0, "VOMISSEMENT", "PROVOQUE DES REJETS GASTRIQUES"},
{10, 5, 0, 3, 0, "TOUX", "LA PROJECTION DE PARTICULE AUGMENTE LA CONTAGION"},
{15, 20, 5, 10, 0, "PNEUMONIE", "AFFECTION PULMONAIRE PEU MORTELLE"},
{ 0, 30, 20, 15, 10, "TUMEUR", "PEU CONTAGIEUX, MAIS MORTEL"},
@ -25,8 +25,8 @@ const struct mutation abilities_data[6] =
{
{15, 0, 0, 10, 0, "FROID", "RESISTANCE AU FROID"},
{15, 0, 0, 15, 0, "CHAUD", "RESISTANCE AU CHAUD"},
{ 0, 10, 4, 25, 10, "GENETIQUE", "LE GENOME MUTE, RALENTISSANT LE SEQUENCAGE ADN"},
{10, 40, 20, 30, 20, "MUTATION+", "LE VIRUS MUTE, BLOQUANT LES CHERCHEURS"},
{ 0, 10, 0, 25, 10, "GENETIQUE", "LE GENOME MUTE, RALENTISSANT LE SEQUENCAGE ADN"},
{10, 10, 20, 30, 30, "MUTATION+", "LE VIRUS MUTE, BLOQUANT LES CHERCHEURS"},
{30, 10, 0, 30, 0, "ENVIRON", "LE VIRUS RESISTE AUX ENVIRONNEMENTS LES PLUS HOSTILES"},
{ 0, 15, 30, 15, 20, "MEDICAMENT", "RESISTANCES AU MEDICAMENTS"},
};
@ -38,15 +38,15 @@ const struct mutation transmissions_data[13] =
{10, 10, 0, 15, 0, "AIR 2", "TRANSMISSION PAR L'AIR"},
{20, 10, 0, 20, 0, "AIR 3", "TRANSMISSION PAR L'AIR"},
{40, 15, 0, 30, 0, "AEROSOL", "TRANSMISSION PAR L'AIR ET PAR L'EAU"},
{10, 0, 0, 9, 0, "EAU 1", "TRANSMISSION PAR L'EAU"},
{20, 10, 0, 12, 0, "EAU 2", "TRANSMISSION PAR L'EAU"},
{20, 0, 0, 10, 0, "ANIMAL 1", "LE VIRUS PEUT PASSER DE L'ANIMAL À L'HOMME"},
{40, 10, 0, 16, 0, "ANIMAL 2", "CAPACITE DE TRANSMISSION HOMME-ANIMAL"},
{20, 0, 0, 12, 0, "OISEAU 1", "CAPACITE DE TRANSMISSION ENTRE LES OISEAU"},
{40, 10, 0, 16, 0, "OISEAU 2", "LES OISEAUX DEVIENNENT DES VECTEURS VIRALS"},
{10, 0, 0, 15, 0, "EAU 1", "TRANSMISSION PAR L'EAU"},
{20, 10, 0, 20, 0, "EAU 2", "TRANSMISSION PAR L'EAU"},
{20, 0, 5, 12, 0, "ANIMAL 1", "LE VIRUS PEUT PASSER DE L'ANIMAL À L'HOMME"},
{40, 10, 0, 25, 0, "ANIMAL 2", "CAPACITE DE TRANSMISSION HOMME-ANIMAL"},
{20, 0, 0, 15, 0, "OISEAU 1", "LES OISEAUX TRANSMETTENT LE VIRUS"},
{40, 10, 0, 25, 0, "OISEAU 2", "LES OISEAUX TRANSMETTENT LE VIRUS"},
{10, 0, 0, 8, 0, "SANG 1", "LE VIRUS SE TRANSMET PAR LE SANG"},
{20, 10, 0, 14, 0, "SANG 2", "LE VIRUS SE TRANSMET PAR LE SANG"},
{40, 15, 0, 20, 0, "SANG 3", "LE VIRUS SE TRANSMET PAR LE SANG"},
{20, 10, 0, 15, 0, "SANG 2", "LE VIRUS SE TRANSMET PAR LE SANG"},
{40, 15, 0, 25, 0, "SANG 3", "LE VIRUS SE TRANSMET PAR LE SANG"},
};

View File

@ -41,7 +41,8 @@ void epidemic_simulation(struct game *current_game)
uint8_t *current_grid = calloc(current_game->grid.width * current_game->grid.height, sizeof(uint8_t));
init_tab(current_game->grid.width * current_game->grid.height, current_grid, current_game->grid.data);
int healed_rate = ceil((100 * current_game->research / current_game->limit));
int healed_rate = floor((100 * current_game->research / current_game->limit));
if (!bernoulli(healed_rate)) healed_rate = 0;
// Make the epidemic grid evolove
for (int i = 0; i < current_game->grid.width; i ++)

View File

@ -1,6 +1,6 @@
/*
Project name ......: Plague
Version ...........: 1.3
Version ...........: 1.3.1
Last modification .: 4 June 2021
code and assets provided with licence :
@ -24,7 +24,7 @@ static void title_screen(void);
// main_loop : display background, foreground and manage inputs
void main_loop(struct game *current_game);
int main_loop(struct game *current_game);
int main(void)
@ -74,9 +74,10 @@ int main(void)
read_save(&current_game);
main_loop(&current_game);
int to_save = main_loop(&current_game);
write_save(&current_game);
if (to_save) write_save(&current_game);
else delete_save();
// Free memory
free(current_game.grid.data);
@ -128,10 +129,10 @@ static void title_screen(void)
}
void main_loop(struct game *current_game)
int main_loop(struct game *current_game)
{
int background = 1, mutation_menu = 4;
int end = 0;
int end = 0, to_save = 1;
static volatile int tick = 1;
int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick));
@ -150,7 +151,7 @@ void main_loop(struct game *current_game)
dupdate();
// Compute the motion of planes, DNA points and infectious model
next_frame(current_game);
to_save = next_frame(current_game);
// Get inputs from the keyboard and manage it
background = get_inputs(background, &mutation_menu);
@ -165,5 +166,6 @@ void main_loop(struct game *current_game)
}
if (t >= 0) timer_stop(t);
return to_save;
}

View File

@ -133,7 +133,7 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
// Update
update_disease(current_game);
current_game->priority += ceil((mutation_data->severity + mutation_data->lethality)/8);
current_game->priority += ceil((mutation_data->severity + mutation_data->lethality) / 10);
message("MUTATION ACHETEE");
}
else message("ACHAT IMPOSSIBLE");

View File

@ -5,7 +5,7 @@
#include "display_engine.h"
// Basic limit research
#define RESEARCH_LIMIT 200
#define RESEARCH_LIMIT 300
// mutation_table : contain the map of the mutation available
struct mutation_table

View File

@ -90,4 +90,10 @@ void write_save(const struct game *current_game)
// Close file
BFile_Close(fd);
}
void delete_save(void)
{
BFile_Remove(filename);
}

View File

@ -9,4 +9,7 @@ void read_save(struct game *current_game);
// write_save : write the savefile
void write_save(const struct game *current_game);
// delete_save : delete the savefile
void delete_save(void);
#endif /* _SAVE_H */