Merge branch 'dev'

Add a compatibility code for G35+E II and others minor changes on title screen and main screen
This commit is contained in:
Shadow15510 2021-06-05 20:20:27 +02:00
commit c8317eeb40
9 changed files with 40 additions and 30 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 808 B

View File

@ -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
@ -159,7 +162,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));
@ -173,8 +176,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);

View File

@ -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);

View File

@ -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();
}

View File

@ -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);

View File

@ -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;
}
}

View File

@ -1,6 +1,6 @@
/*
Project name ......: Plague
Version ...........: 1.3.2
Version ...........: 1.3.3
Last modification .: 4 June 2021
code and assets provided with licence :
@ -13,12 +13,15 @@
#include <gint/clock.h>
#include <gint/defs/types.h>
#include <gint/std/stdlib.h>
#include <gint/gint.h>
#include "core.h"
#include "display_engine.h"
#include "mutation_engine.h"
#include "save.h"
const char *VERSION = "1.3.3";
// title_screen : display the title screen
static void title_screen(void);
@ -72,12 +75,12 @@ int main(void)
current_game.grid.data[95 + 20 * current_game.grid.width] = 1;
current_game.humans[0] = (current_game.grid.width * current_game.grid.height) - 1 - BLANK_CASES;
read_save(&current_game);
gint_world_switch(GINT_CALL(read_save, (void *)&current_game));
int to_save = main_loop(&current_game);
if (to_save) write_save(&current_game);
else delete_save();
if (to_save) gint_world_switch(GINT_CALL(write_save, (void *)&current_game));
else gint_world_switch(GINT_CALL(delete_save));
// Free memory
free(current_game.grid.data);
@ -95,9 +98,11 @@ static void title_screen(void)
dupdate();
sleep_ms(250);
dsubimage(0, 0, &img_title, 0, 0, 128, 64, DIMAGE_NONE);
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(500);
sleep_ms(1000);
for (int frame = 0; frame < 5; frame ++)
{
@ -111,15 +116,7 @@ static void title_screen(void)
dclear(C_BLACK);
dsubimage(0, 0, &img_title, 0, 65, 128, 64, DIMAGE_NONE);
dupdate();
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();
sleep_ms(250);
}
sleep_ms(750);
dclear(C_BLACK);
dsubimage(0, 0, &img_title, 0, 130, 128, 64, DIMAGE_NONE);
@ -132,7 +129,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));
@ -147,12 +144,12 @@ 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);
if (!to_save) end = 1;
to_save = next_frame(current_game, &dna_animation);
if (!to_save) return 0;
// Get inputs from the keyboard and manage it
background = get_inputs(background, &mutation_menu, &current_game->boost);
@ -167,6 +164,6 @@ int main_loop(struct game *current_game)
}
if (t >= 0) timer_stop(t);
return to_save;
return 1;
}