diff --git a/Plague.g1a b/Plague.g1a index 60e4d8f..0a4f243 100644 Binary files a/Plague.g1a and b/Plague.g1a differ diff --git a/assets-fx/bground.png b/assets-fx/bground.png index 37e9f89..a5187b2 100644 Binary files a/assets-fx/bground.png and b/assets-fx/bground.png differ diff --git a/assets-fx/dna.png b/assets-fx/dna.png index 07127be..02cffb0 100644 Binary files a/assets-fx/dna.png and b/assets-fx/dna.png differ diff --git a/src/core.c b/src/core.c index ae92f7a..c70e6bc 100644 --- a/src/core.c +++ b/src/core.c @@ -9,7 +9,7 @@ #include "display_engine.h" -int next_frame(struct game *current_game) +int next_frame(struct game *current_game, int *dna_animation) { for (int i = 0; current_game->planes[i]; i++) { @@ -54,9 +54,12 @@ int next_frame(struct game *current_game) int limit_tick = LIMIT_TICK; if (current_game->boost) limit_tick = floor(LIMIT_TICK / 10); + current_game->time += ENGINE_TICK; current_game->total_time += ENGINE_TICK; + if (!(current_game->time % 150)) *dna_animation = (*dna_animation + 1) % 16; + if (current_game->time > limit_tick) { // Reset internal clock @@ -158,7 +161,7 @@ void message(char *msg) { display_message(msg); - int key = 0, frame = 1; + int key = 0, frame = 0; static volatile int tick = 1; int t = timer_configure(TIMER_ANY, DNA_ANIMATION_TICK*1000, GINT_CALL(callback_tick, &tick)); @@ -172,8 +175,7 @@ void message(char *msg) key = rtc_key(); display_dna_animation(frame); - frame = (frame + 1) % 24; - if (!frame) frame = 24; + frame = (frame + 1) % 16; } if (t >= 0) timer_stop(t); diff --git a/src/core.h b/src/core.h index a1de721..cd72f77 100644 --- a/src/core.h +++ b/src/core.h @@ -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 next_frame(struct game *current_game, int *dna_animation); // rtc_key : get the key with RTC system int rtc_key(void); diff --git a/src/display_engine.c b/src/display_engine.c index 12b7978..c267d96 100644 --- a/src/display_engine.c +++ b/src/display_engine.c @@ -12,10 +12,11 @@ void display_background(const int background) } -void display_foreground(const int background, const struct game *current_game, const int mutation_menu) +void display_foreground(const int background, const struct game *current_game, const int mutation_menu, const int dna_animation) { extern const bopti_image_t img_mutations; extern const bopti_image_t img_planes; + extern const bopti_image_t img_dna; extern const uint8_t world[64][128]; GUNUSED int length; @@ -57,6 +58,9 @@ void display_foreground(const int background, const struct game *current_game, c if (current_game->planes[i]->y + 8 < 57) 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); } + // Animated DNA + dsubimage(1, 51, &img_dna, dna_animation * 8, 0, 7, 12, DIMAGE_NONE); + // Status bottom bar int length = 73 * current_game->research / current_game->limit; dprint(9, 58, C_BLACK, "%d", current_game->dna); @@ -196,9 +200,10 @@ void display_message(char *msg) void display_dna_animation(const int frame) { - extern bopti_image_t img_dna; + extern const bopti_image_t img_dna; - dsubimage(114, 29, &img_dna, 11 * (frame - 1), 0, 11, 32, DIMAGE_NONE); + dsubimage(2, 3, &img_dna, 8 * frame, 0, 7, 12, DIMAGE_NONE); + dsubimage(42, 3, &img_dna, 8 * ((frame + 2) % 16), 0, 7, 12, DIMAGE_NONE); dupdate(); } diff --git a/src/display_engine.h b/src/display_engine.h index a9c314e..5ac0dee 100644 --- a/src/display_engine.h +++ b/src/display_engine.h @@ -7,7 +7,7 @@ void display_background(const int background); // display_foreground : display the foreground, planes, statistics -void display_foreground(const int background, const struct game *current_game, const int mutation_menu); +void display_foreground(const int background, const struct game *current_game, const int mutation_menu, const int dna_animation); // display_mutation : display the mutation selection screen void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu); diff --git a/src/epidemic_engine.c b/src/epidemic_engine.c index e3762ea..5615b17 100644 --- a/src/epidemic_engine.c +++ b/src/epidemic_engine.c @@ -42,7 +42,7 @@ void epidemic_simulation(struct game *current_game) init_tab(current_game->grid.width * current_game->grid.height, current_grid, current_game->grid.data); int healed_rate = 0; - if (current_game->research == current_game->limit) healed_rate = rand() % 26; + if (current_game->research == current_game->limit) healed_rate = rand() % 11; // Make the epidemic grid evolove for (int i = 0; i < current_game->grid.width; i ++) @@ -97,6 +97,12 @@ void epidemic_simulation(struct game *current_game) } init_tab(current_game->grid.width * current_game->grid.height, current_game->grid.data, current_grid); free(current_grid); + + for (int i = 0; i < 4; i ++) + { + if (current_game->humans[i] < 0) current_game->humans[i] = 0; + else if (current_game->humans[i] > (current_game->grid.width * current_game->grid.height) - BLANK_CASES) current_game->humans[i] = (current_game->grid.width * current_game->grid.height) - BLANK_CASES; + } } diff --git a/src/main.c b/src/main.c index 44ba069..a04c32f 100644 --- a/src/main.c +++ b/src/main.c @@ -97,14 +97,9 @@ static void title_screen(void) dupdate(); sleep_ms(250); - for (int i = 64; i > 32; i --) - { - dclear(C_BLACK); - dsubimage(0, 0, &img_title, 0, 0, 128, 64, DIMAGE_NONE); - dprint_opt(16, i, C_WHITE, C_BLACK, 0, 0, "VERSION %s", VERSION, -1); - dupdate(); - sleep_ms(75); - } + dsubimage(0, 0, &img_title, 0, 0, 128, 64, DIMAGE_NONE); + dprint_opt(32, 29, C_WHITE, C_BLACK, 0, 0, "VERSION %s", VERSION, -1); + dupdate(); sleep_ms(1000); @@ -141,7 +136,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; + int end = 0, to_save = 1, dna_animation = 0; static volatile int tick = 1; int t = timer_configure(TIMER_ANY, ENGINE_TICK*1000, GINT_CALL(callback_tick, &tick)); @@ -156,11 +151,11 @@ int main_loop(struct game *current_game) // Update the screen dclear(C_WHITE); display_background(background); - display_foreground(background, current_game, mutation_menu); + display_foreground(background, current_game, mutation_menu, dna_animation); dupdate(); // Compute the motion of planes, DNA points and infectious model - to_save = next_frame(current_game); + to_save = next_frame(current_game, &dna_animation); if (!to_save) end = 1; // Get inputs from the keyboard and manage it