diff --git a/Plague.g1a b/Plague.g1a index 4f80122..7758431 100644 Binary files a/Plague.g1a and b/Plague.g1a differ diff --git a/assets-fx/mutations_table/abilities_2.txt b/assets-fx/mutations_table/abilities_2.txt index b54ad81..4d9f223 100644 --- a/assets-fx/mutations_table/abilities_2.txt +++ b/assets-fx/mutations_table/abilities_2.txt @@ -1,4 +1,4 @@ -1 | 0 | 0 | 0 | 6 | 0 | 0 | 0 +1 | 0 | 0 | 0 | 15 | 0 | 0 | 0 2 | 15 | 0 | 3 | 0 | 0 | 0 | 0 0 | 0 | 0 | 0 | 15 | 0 | 0 | 0 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \ No newline at end of file diff --git a/src/core.c b/src/core.c index 8777724..e7635bc 100644 --- a/src/core.c +++ b/src/core.c @@ -43,20 +43,40 @@ void next_frame(struct game *current_game) current_game->planes[i]->direction = new_dir; } } + current_game->time += ENGINE_TICK; + current_game->total_time += ENGINE_TICK; + if (current_game->time > LIMIT_TICK) { + // Reset internal clock current_game->time = 0; - if (current_game->dna <= 100) current_game->dna += 1; + // Update the game + if (current_game->dna <= 100) current_game->dna += 1; current_game->research += current_game->priority; + epidemic_simulation(current_game); + + // Check the end of the game if (current_game->research > current_game->limit) { const char *msg[5] = {"Vous avez", "perdu.", "", "", ""}; message(msg); current_game->research = 0; } - epidemic_simulation(current_game); + if (!current_game->humans[0]) + { + if (!current_game->humans[1]) + { + const char *msg[5] = {"Vous avez", "perdu.", "", "", ""}; + message(msg); + } + else + { + const char *msg[5] = {"Vous avez", "gagne.", "", "", ""}; + message(msg); + } + } } } @@ -152,4 +172,4 @@ void message(const char *msg[5]) } if (t >= 0) timer_stop(t); -} \ No newline at end of file +} diff --git a/src/core.h b/src/core.h index 66956ed..734dc89 100644 --- a/src/core.h +++ b/src/core.h @@ -44,7 +44,7 @@ struct game int humans[4]; // Time - int time; + int time, total_time; // Planes struct plane *planes[NB_PLANES + 1]; diff --git a/src/data.c b/src/data.c index 24466b1..25e24aa 100644 --- a/src/data.c +++ b/src/data.c @@ -1,51 +1,52 @@ #include "mutation_engine.h" +// (contation, severity, lethality, DNA cost, change to cure requirement) const struct mutation symptoms_data[14] = { - {1, 1, 0, 2, 0, "NAUSEE"}, - {3, 2, 0, 4, 0, "VOMISSEMENT"}, - {2, 1, 0, 3, 0, "TOUX"}, - {2, 2, 0, 4, 0, "PNEUMONIE"}, - {4, 2, 5, 15, 25, "TUMEUR"}, - {2, 1, 0, 3, 0, "PLAIES"}, - {5, 4, 0, 10, 0, "LESIONS"}, - {5, 15, 15, 20, 30, "HEMORRAGIE"}, - {6, 7, 6, 17, 0, "INFECTION"}, - {2, 2, 2, 5, 0, "INFLAMMATION"}, - {2, 6, 4, 12, 0, "IMMUNITE"}, - {0, 4, 0, 5, 120, "PARANOIA"}, - {6, 15, 0, 20, 100, "FOLIE"}, - {0, 20, 25, 30, 250, "ARRET TOTAL"}, + {15, 10, 0, 2, 0, "NAUSEE"}, + {25, 10, 0, 4, 0, "VOMISSEMENT"}, + {20, 10, 0, 3, 0, "TOUX"}, + {15, 20, 0, 4, 0, "PNEUMONIE"}, + {10, 30, 20, 15, 25, "TUMEUR"}, + {25, 10, 0, 4, 0, "PLAIES"}, + {10, 10, 0, 10, 0, "LESIONS"}, + {30, 20, 20, 20, 30, "HEMORRAGIE"}, + {25, 15, 10, 17, 0, "INFECTION"}, + {15, 10, 2, 5, 0, "INFLAMMATION"}, + {10, 15, 10, 12, 0, "IMMUNITE"}, + { 0, 20, 0, 15, 120, "PARANOIA"}, + { 0, 15, 0, 20, 100, "FOLIE"}, + { 0, 30, 30, 30, 250, "ARRET TOTAL"}, }; const struct mutation abilities_data[6] = { - {4, 0, 0, 10, 0, "FROID"}, - {7, 0, 0, 15, 0, "CHAUD"}, - {0, 5, 4, 25, 20, "GENETIQUE"}, - {0, 8, 8, 30, 50, "MUTATION+"}, - {10, 0, 0, 30, 0, "ENVIRON"}, - {0, 2, 2, 15, 50, "MEDICAMENT"}, + {15, 0, 0, 10, 0, "FROID"}, + {15, 0, 0, 15, 0, "CHAUD"}, + { 0, 20, 4, 25, 20, "GENETIQUE"}, + {10, 40, 8, 30, 50, "MUTATION+"}, + {30, 0, 0, 30, 0, "ENVIRON"}, + { 0, 15, 30, 15, 30, "MEDICAMENT"}, }; const struct mutation transmissions_data[13] = { - { 2, 0, 0, 9, 0, "AIR 1"}, - { 5, 0, 0, 15, 0, "AIR 2"}, - { 8, 0, 0, 20, 0, "AIR 3"}, - {10, 0, 0, 30, 0, "AEROSOL"}, - { 2, 0, 0, 9, 0, "EAU 1"}, - { 4, 0, 0, 12, 0, "EAU 2"}, - { 2, 0, 0, 10, 0, "ANIMAL 1"}, - { 6, 0, 0, 16, 0, "ANIMAL 2"}, - { 3, 0, 0, 12, 0, "OISEAU 1"}, - { 6, 0, 0, 16, 0, "OISEAU 2"}, - { 1, 0, 0, 8, 0, "SANG 1"}, - { 4, 0, 0, 14, 0, "SANG 2"}, - { 9, 1, 1, 20, 0, "SANG 3"}, + {5, 0, 0, 9, 0, "AIR 1"}, + {10, 0, 0, 15, 0, "AIR 2"}, + {20, 0, 0, 20, 0, "AIR 3"}, + {40, 0, 0, 30, 0, "AEROSOL"}, + {10, 0, 0, 9, 0, "EAU 1"}, + {20, 0, 0, 12, 0, "EAU 2"}, + {20, 0, 0, 10, 0, "ANIMAL 1"}, + {40, 0, 0, 16, 0, "ANIMAL 2"}, + {20, 0, 0, 12, 0, "OISEAU 1"}, + {40, 0, 0, 16, 0, "OISEAU 2"}, + {10, 0, 0, 8, 0, "SANG 1"}, + {20, 0, 0, 14, 0, "SANG 2"}, + {40, 0, 0, 20, 0, "SANG 3"}, }; diff --git a/src/epidemic_engine.c b/src/epidemic_engine.c index 51ca43a..3a2ffce 100644 --- a/src/epidemic_engine.c +++ b/src/epidemic_engine.c @@ -16,8 +16,8 @@ bool can_become_infected(const struct grid epidemic_grid, const int mutations_se // In case of water, low or high temperature if (world[j][i] == 0 && mutations_selected[2] != 3) return false; - if (world[j][i] == 1 && mutations_selected[1] != 0 && mutations_selected[1] != 4) return false; - if (world[j][i] == 3 && mutations_selected[1] != 1 && mutations_selected[1] != 4) return false; + if (world[j][i] == 1 && mutations_selected[1] != 1 && mutations_selected[1] != 5) return false; + if (world[j][i] == 3 && mutations_selected[1] != 2 && mutations_selected[1] != 5) return false; // Test cases around return grid_get(epidemic_grid, i - 1, j) == 1 || grid_get(epidemic_grid, i + 1, j) == 1 || grid_get(epidemic_grid, i, j - 1) == 1 || grid_get(epidemic_grid, i, j + 1) == 1; @@ -32,7 +32,7 @@ bool bernoulli(const int p) void epidemic_simulation(struct game *current_game) { - srand(15510); + srand(current_game->total_time); // Create a copy of the epidemic grid uint8_t *current_grid = calloc(current_game->grid.width * current_game->grid.height, sizeof(uint8_t)); diff --git a/src/main.c b/src/main.c index bbc5f77..c17a5ff 100644 --- a/src/main.c +++ b/src/main.c @@ -57,7 +57,7 @@ int main(void) .priority = 0, .humans = {0, 1, 0, 0}, - .time = 0, + .time = 0, .total_time = 0, .planes = {&plane_1, &plane_2, &plane_3, &plane_4, &plane_5, NULL}, @@ -90,23 +90,13 @@ static void title_screen(void) extern bopti_image_t img_title; extern bopti_image_t img_explosion; - static volatile int tick_5 = 1; - static volatile int tick_1 = 1; - int t_1 = timer_configure(TIMER_ANY, 500000, GINT_CALL(callback_tick, &tick_5)); - int t_2 = timer_configure(TIMER_ANY, 100000, GINT_CALL(callback_tick, &tick_1)); - - if (t_1 >= 0) timer_start(t_1); - if (t_2 >= 0) timer_start(t_2); - dclear(C_BLACK); dupdate(); - while (!tick_5) sleep(); - tick_5 = 0; + sleep_ms(250); dsubimage(0, 0, &img_title, 0, 0, 128, 64, DIMAGE_NONE); dupdate(); - while (!tick_5) sleep(); - tick_5 = 0; + sleep_ms(500); for (int frame = 0; frame < 5; frame ++) { @@ -114,27 +104,20 @@ static void title_screen(void) dsubimage(0, 0, &img_title, 0, 0, 128, 64, DIMAGE_NONE); dsubimage(76, 9, &img_explosion, 41 * frame, 0, 40, 40, DIMAGE_NONE); dupdate(); - while (!tick_1) sleep(); - tick_1 = 0; + sleep_ms(100); } dclear(C_BLACK); dsubimage(0, 0, &img_title, 0, 65, 128, 64, DIMAGE_NONE); dupdate(); - - for (int i = 0; i < 2; i ++) - { - while (!tick_5) sleep(); - tick_5 = 0; - } + sleep_ms(500); for (int i = 0; i < 5; i ++) { dclear(C_BLACK); dsubimage(0, 0, &img_title, 0, ((i % 2) + 1) * 65, 128, 64, DIMAGE_NONE); dupdate(); - while (!tick_5) sleep(); - tick_5 = 0; + sleep_ms(250); } dclear(C_BLACK); @@ -142,9 +125,6 @@ static void title_screen(void) dupdate(); getkey(); - - if (t_1 >= 0) timer_stop(t_1); - if (t_2 >= 0) timer_stop(t_2); } diff --git a/src/mutation_engine.c b/src/mutation_engine.c index a3a2b60..25a774b 100644 --- a/src/mutation_engine.c +++ b/src/mutation_engine.c @@ -156,7 +156,7 @@ void update_disease(struct game *current_game) // research parameters current_game->limit = RESEARCH_LIMIT + symptom->changement + ability->changement + transmission->changement; - current_game->priority = floor((current_game->severity + current_game->lethality) / 2); + current_game->priority = floor((current_game->severity + current_game->lethality) / 200); } @@ -198,4 +198,4 @@ void init_mat(int x, int y, int dest[][x], int src[][x]) dest[j][i] = src[j][i]; } } -} \ No newline at end of file +}