Add message and adjust timers
This commit is contained in:
parent
51adb19ba1
commit
3236732ea8
|
@ -28,6 +28,7 @@ set(ASSETS_fx
|
|||
assets-fx/mutations.png
|
||||
assets-fx/cursor.png
|
||||
assets-fx/title.png
|
||||
assets-fx/dna.png
|
||||
assets-fx/mutations_table/abilities_1.txt
|
||||
assets-fx/mutations_table/abilities_2.txt
|
||||
assets-fx/mutations_table/abilities_3.txt
|
||||
|
|
BIN
Plague.g1a
BIN
Plague.g1a
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 5.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
30
src/core.c
30
src/core.c
|
@ -43,9 +43,9 @@ void next_frame(struct game *current_game)
|
|||
}
|
||||
}
|
||||
current_game->time += ENGINE_TICK;
|
||||
if (current_game->time > 10000)
|
||||
if (current_game->time > LIMIT_TICK)
|
||||
{
|
||||
current_game->dna += 1;
|
||||
if (current_game->dna <= 100) current_game->dna += 1;
|
||||
current_game->time = 0;
|
||||
|
||||
// Epidemic propagation simulation to add here
|
||||
|
@ -120,3 +120,29 @@ int callback_tick(volatile int *tick)
|
|||
return TIMER_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void message(const char *msg[5])
|
||||
{
|
||||
display_message(msg);
|
||||
|
||||
int key = 0, frame = 1;
|
||||
|
||||
static volatile int tick = 1;
|
||||
int t = timer_configure(TIMER_ANY, DNA_ANIMATION_TICK*1000, GINT_CALL(callback_tick, &tick));
|
||||
if (t >= 0) timer_start(t);
|
||||
|
||||
while (!key)
|
||||
{
|
||||
while(!tick) sleep();
|
||||
tick = 0;
|
||||
|
||||
key = rtc_key();
|
||||
display_dna_animation(frame);
|
||||
|
||||
frame = (frame + 1) % 24;
|
||||
if (!frame) frame = 24;
|
||||
}
|
||||
|
||||
if (t >= 0) timer_stop(t);
|
||||
}
|
||||
|
||||
|
|
17
src/core.h
17
src/core.h
|
@ -1,16 +1,17 @@
|
|||
#ifndef _PLAGUE_CORE_H
|
||||
#define _PLAGUE_CORE_H
|
||||
|
||||
// Duration for internal clock
|
||||
// Duration for internal clock (ms)
|
||||
#define ENGINE_TICK 50
|
||||
#define CURSOR_TICK 100
|
||||
#define CURSOR_TICK 150
|
||||
#define DNA_ANIMATION_TICK 150
|
||||
|
||||
// The duration for DNA points and infectious model (ms)
|
||||
#define LIMIT_TICK 10000
|
||||
|
||||
// Number of planes on screen
|
||||
#define NB_PLANES 5
|
||||
|
||||
// Number of humans
|
||||
#define TOTAL_POP 10000000000
|
||||
|
||||
// game : all statistics of the current game
|
||||
struct game
|
||||
{
|
||||
|
@ -28,9 +29,6 @@ struct game
|
|||
// Research data
|
||||
int research, limit;
|
||||
|
||||
// Infectious pattern parameters
|
||||
long long int healthy, infected, dead, cured;
|
||||
|
||||
// Time
|
||||
int time;
|
||||
|
||||
|
@ -77,4 +75,7 @@ int rtc_key(void);
|
|||
// callback_timer : basic timer
|
||||
int callback_tick(volatile int *tick);
|
||||
|
||||
// message : display a message
|
||||
void message(const char *msg[5]);
|
||||
|
||||
#endif /* _PLAGUE_CORE_H */
|
|
@ -58,23 +58,7 @@ void display_foreground(const int background, const struct game *current_game)
|
|||
if (current_game->mutations_selected[2]) dsubimage(65, 15, &img_mutations, 32, 16 * (current_game->mutations_selected[2] - 1), 15, 15, 0);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
length = 63 * current_game->healthy/ TOTAL_POP;
|
||||
dline(61, 31, 61 + length, 31, C_BLACK);
|
||||
dline(61, 32, 61 + length, 32, C_BLACK);
|
||||
|
||||
length = 63 * current_game->infected / TOTAL_POP;
|
||||
dline(61, 39, 61 + length, 39, C_BLACK);
|
||||
dline(61, 40, 61 + length, 40, C_BLACK);
|
||||
|
||||
length = 63 * current_game->dead / TOTAL_POP;
|
||||
dline(61, 47, 61 + length, 47, C_BLACK);
|
||||
dline(61, 48, 61 + length, 48, C_BLACK);
|
||||
|
||||
length = 63 * current_game->cured / TOTAL_POP;
|
||||
dline(61, 55, 61 + length, 55, C_BLACK);
|
||||
dline(61, 56, 61 + length, 56, C_BLACK);
|
||||
break;
|
||||
// case 6: statistics about humans
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -124,10 +108,19 @@ void display_mutation_buy(const struct cursor c, const int mutation_menu, const
|
|||
}
|
||||
|
||||
|
||||
void output_error(const char *msg)
|
||||
void display_message(const char *msg[5])
|
||||
{
|
||||
dclear(C_WHITE);
|
||||
dprint(0, 0, C_BLACK, msg);
|
||||
display_background(7);
|
||||
for (int i = 0; i < 5; i ++) dprint(54, 6 * i + 4, C_BLACK, msg[i]);
|
||||
dupdate();
|
||||
}
|
||||
|
||||
void display_dna_animation(const int frame)
|
||||
{
|
||||
extern bopti_image_t img_dna;
|
||||
|
||||
dsubimage(114, 29, &img_dna, 11 * (frame - 1), 0, 11, 32, DIMAGE_NONE);
|
||||
dupdate();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,10 @@ void display_mutation(const int table[4][8], const struct cursor c, const int mu
|
|||
// 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);
|
||||
|
||||
// output_error : display text
|
||||
void output_error(const char *msg);
|
||||
// output_error : display text and message background
|
||||
void display_message(const char *msg[5]);
|
||||
|
||||
// display_dna_animation : display the DNA according to the frame number
|
||||
void display_dna_animation(const int frame);
|
||||
|
||||
#endif /* _PLAGUE_DISPLAY_ENGINE_H */
|
|
@ -53,10 +53,6 @@ int main(void)
|
|||
.research = 0,
|
||||
.limit = 100,
|
||||
|
||||
.healthy = TOTAL_POP - 1,
|
||||
.infected = 1,
|
||||
.dead = 0,
|
||||
|
||||
.time = 0,
|
||||
|
||||
.planes = {&plane_1, &plane_2, &plane_3, &plane_4, &plane_5, NULL}
|
||||
|
@ -101,7 +97,7 @@ void main_loop(struct game *current_game)
|
|||
display_foreground(background, current_game);
|
||||
dupdate();
|
||||
|
||||
// Compute the motion of planes
|
||||
// Compute the motion of planes, DNA points and infectious model
|
||||
next_frame(current_game);
|
||||
|
||||
// Get inputs from the keyboard and manage it
|
||||
|
|
|
@ -120,8 +120,10 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
|
|||
|
||||
// Update
|
||||
update_disease(current_game);
|
||||
const char *msg[5] = {"mutation", "achetee", "", "", ""};
|
||||
message(msg);
|
||||
}
|
||||
else {output_error("Achat impossible"); getkey();}
|
||||
else {const char *msg[5] = {"achat", "impossible", "", "", ""}; message(msg);}
|
||||
}
|
||||
|
||||
// if the player has already bought this mutation
|
||||
|
@ -129,6 +131,8 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
|
|||
{
|
||||
current_game->mutations_selected[mutation_menu - 1] = id;
|
||||
update_disease(current_game);
|
||||
const char *msg[5] = {"mutation", "selectionnee"};
|
||||
message(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue