Bases of the epidemic engine

This commit is contained in:
Shadow15510 2021-05-30 21:33:32 +02:00
parent 3236732ea8
commit 21f5ad03dd
13 changed files with 53 additions and 10 deletions

View File

@ -15,6 +15,7 @@ set(SOURCES
src/display_engine.c
src/mutation_engine.c
src/mutation_data.c
src/epidemic_engine.c
# ...
)
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -48,6 +48,9 @@ void next_frame(struct game *current_game)
if (current_game->dna <= 100) current_game->dna += 1;
current_game->time = 0;
current_game->research += current_game->priority;
// if (current_game->research > current_game->limit) ; game over
// Epidemic propagation simulation to add here
}
}

View File

@ -6,7 +6,7 @@
#define CURSOR_TICK 150
#define DNA_ANIMATION_TICK 150
// The duration for DNA points and infectious model (ms)
// Duration for DNA points and infectious model (ms)
#define LIMIT_TICK 10000
// Number of planes on screen
@ -27,7 +27,7 @@ struct game
int mutations_bought[3][14];
// Research data
int research, limit;
int research, limit, priority;
// Time
int time;

View File

@ -83,12 +83,13 @@ void display_mutation(const int table[4][8], const struct cursor c, const int mu
}
void display_mutation_buy(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected)
void display_mutation_buy(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected, const struct game *current_game)
{
extern const bopti_image_t img_mutations;
const int id = table[c.y][c.x];
struct mutation *mutation_data = get_mutation_data(mutation_menu, id);
struct mutation *mutation_sel = get_mutation_data(mutation_menu, current_game->mutations_selected[mutation_menu]);
dclear(C_WHITE);
@ -97,9 +98,9 @@ void display_mutation_buy(const struct cursor c, const int mutation_menu, const
dprint(47, 25, C_BLACK, mutation_data->name);
dprint(81, 33, C_BLACK, "%d", mutation_data->dna);
dprint(81, 41, C_BLACK, "%d", mutation_data->contagion);
dprint(81, 49, C_BLACK, "%d", mutation_data->lethality);
dprint(81, 57, C_BLACK, "%d", mutation_data->severity);
dprint(81, 41, C_BLACK, "%d (%d)", mutation_data->contagion, mutation_data->contagion - mutation_sel->contagion);
dprint(81, 49, C_BLACK, "%d (%d)", mutation_data->severity, mutation_data->severity - mutation_sel->severity);
dprint(81, 57, C_BLACK, "%d (%d)", mutation_data->lethality, mutation_data->lethality - mutation_sel->lethality);
if (button_selected) drect(81, 2, 123, 8, C_INVERT);
else drect(81, 12, 123, 18, C_INVERT);

View File

@ -13,7 +13,7 @@ void display_foreground(const int background, const struct game *current_game);
void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu);
// mutation_selected : display the mutation's informations screen
void display_mutation_buy(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected);
void display_mutation_buy(const struct cursor c, const int mutation_menu, const int table[4][8], const int button_selected, const struct game *current_game);
// output_error : display text and message background
void display_message(const char *msg[5]);

19
src/epidemic_engine.c Normal file
View File

@ -0,0 +1,19 @@
#include "epidemic_engine.h"
int * count(const int epidemic_grid[10][20], int counter[4])
{
for (int i = 0; i < 10; i ++)
{
for (int j = 0; j < 20; j ++)
{
counter[epidemic_grid[i][j]] ++;
}
}
return counter;
}
int can_become_infected(const int epidemic_grid[10][20], const int i, const int j)
{
return 0;
}

10
src/epidemic_engine.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef _EPIDEMIC_ENGINE_H
#define _EPIDEMIC_ENGINE_H
// count : return an int *counter[4] of the form {healthy, infected, healed, dead}
int * count(const int epidemic_grid[10][20], int counter[4]);
// can_become_infected : return 0 if the case (i, j) isn't infectable, 1 else
int can_become_infected(const int epidemic_grid[10][20], const int i, const int j);
#endif /* _EPIDEMIC_ENGINE_H */

View File

@ -15,6 +15,7 @@
#include "core.h"
#include "display_engine.h"
#include "mutation_engine.h"
#include "epidemic_engine.h"
// title_screen : display the title screen
@ -51,7 +52,8 @@ int main(void)
.mutations_bought = {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
.research = 0,
.limit = 100,
.limit = RESEARCH_LIMIT,
.priority = 0,
.time = 0,

View File

@ -96,7 +96,7 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
while (1)
{
display_mutation_buy(c, mutation_menu, table, button_selected);
display_mutation_buy(c, mutation_menu, table, button_selected, current_game);
key = getkey().key;
if (key == KEY_DOWN || key == KEY_UP) button_selected = (button_selected + 1) % 2;
@ -149,9 +149,14 @@ void update_disease(struct game *current_game)
struct mutation *ability = get_mutation_data(2, current_game->mutations_selected[1]);
struct mutation *transmission = get_mutation_data(3, current_game->mutations_selected[2]);
// disease parameters
current_game->contagion = symptom->contagion + ability->contagion + transmission->contagion;
current_game->severity = symptom->severity + ability->severity + transmission->severity;
current_game->lethality = symptom->lethality + ability->lethality + transmission->lethality;
// research parameters
current_game->limit = RESEARCH_LIMIT + symptom->changement + ability->changement + transmission->changement;
current_game->priority = floor((symptom->severity + ability->severity + transmission->severity) / 10);
}

View File

@ -4,6 +4,9 @@
#include "core.h"
#include "display_engine.h"
// Basic limit research
#define RESEARCH_LIMIT 100
// mutation_table : contain the map of the mutation available
struct mutation_table
{
@ -39,5 +42,4 @@ struct mutation * get_mutation_data(const int mutation_menu, const int id);
// init_mat : copy src into dest (for int)
void init_mat(int x, int y, int dest[][x], int src[][x]);
#endif /* _MUTATION_ENGINE_H */