diff --git a/CMakeLists.txt b/CMakeLists.txt index 294350e..a37a897 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Plague.g1a b/Plague.g1a index aaaa1f4..5e3df4a 100644 Binary files a/Plague.g1a and b/Plague.g1a differ diff --git a/assets-fx/bground.png b/assets-fx/bground.png index 3df997a..174080c 100644 Binary files a/assets-fx/bground.png and b/assets-fx/bground.png differ diff --git a/assets-fx/plague.png b/assets-fx/plague.png index 6c25191..2c3b91d 100644 Binary files a/assets-fx/plague.png and b/assets-fx/plague.png differ diff --git a/src/core.c b/src/core.c index d7f884c..c526a40 100644 --- a/src/core.c +++ b/src/core.c @@ -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 } } diff --git a/src/core.h b/src/core.h index d3eca8b..cd3f2dc 100644 --- a/src/core.h +++ b/src/core.h @@ -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; diff --git a/src/display_engine.c b/src/display_engine.c index 93379da..e9ee567 100644 --- a/src/display_engine.c +++ b/src/display_engine.c @@ -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); diff --git a/src/display_engine.h b/src/display_engine.h index 6942f3c..916e4f8 100644 --- a/src/display_engine.h +++ b/src/display_engine.h @@ -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]); diff --git a/src/epidemic_engine.c b/src/epidemic_engine.c new file mode 100644 index 0000000..4caaf25 --- /dev/null +++ b/src/epidemic_engine.c @@ -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; +} \ No newline at end of file diff --git a/src/epidemic_engine.h b/src/epidemic_engine.h new file mode 100644 index 0000000..132d939 --- /dev/null +++ b/src/epidemic_engine.h @@ -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 */ \ No newline at end of file diff --git a/src/main.c b/src/main.c index 2f9dbae..6e58790 100644 --- a/src/main.c +++ b/src/main.c @@ -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, diff --git a/src/mutation_engine.c b/src/mutation_engine.c index ed14116..8b0931a 100644 --- a/src/mutation_engine.c +++ b/src/mutation_engine.c @@ -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); } diff --git a/src/mutation_engine.h b/src/mutation_engine.h index 206ba50..b8d22d1 100644 --- a/src/mutation_engine.h +++ b/src/mutation_engine.h @@ -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 */ \ No newline at end of file