Change the game control
This commit is contained in:
parent
4e65fbf3fa
commit
4657718bc9
BIN
Plague.g1a
BIN
Plague.g1a
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 19 KiB |
40
src/core.c
40
src/core.c
|
@ -54,7 +54,7 @@ void next_frame(struct game *current_game)
|
|||
current_game->time = 0;
|
||||
|
||||
// Update the game
|
||||
if (current_game->dna <= 100) current_game->dna += 1 + floor(current_game->severity / 25);
|
||||
if (current_game->dna < 30) current_game->dna += 1 + floor(current_game->severity / 25);
|
||||
if (current_game->research < current_game->limit) current_game->research += current_game->priority;
|
||||
epidemic_simulation(current_game);
|
||||
|
||||
|
@ -87,42 +87,40 @@ int get_inputs(const int background, int *mutation_menu)
|
|||
int key = rtc_key();
|
||||
|
||||
if (key == KEY_OPTN && (background == 1 || background == 2)) return (background % 2) + 1;
|
||||
if (key == KEY_VARS) return 3;
|
||||
if (key == KEY_VARS)
|
||||
{
|
||||
*mutation_menu = 1;
|
||||
return 3;
|
||||
}
|
||||
if (key == KEY_SQUARE) return 6;
|
||||
|
||||
if (key == KEY_EXIT)
|
||||
if (key == KEY_ALPHA)
|
||||
{
|
||||
if (background == 5) return 3;
|
||||
if (background != 1 && background != 2) return 1;
|
||||
if (background == 1 || background == 2) return -1;
|
||||
}
|
||||
if (key == KEY_EXIT && (background == 1 || background == 2)) return -1;
|
||||
|
||||
if (background == 3)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
// Symptoms
|
||||
case KEY_F1:
|
||||
*mutation_menu = 1;
|
||||
return 5;
|
||||
case KEY_LEFT:
|
||||
*mutation_menu = *mutation_menu - 1;
|
||||
if (*mutation_menu <= 0) *mutation_menu = 4;
|
||||
break;
|
||||
|
||||
// Abilities
|
||||
case KEY_F3:
|
||||
*mutation_menu = 2;
|
||||
return 5;
|
||||
case KEY_RIGHT:
|
||||
*mutation_menu = *mutation_menu + 1;
|
||||
if (*mutation_menu >= 5) *mutation_menu = 1;
|
||||
break;
|
||||
|
||||
// Transmission
|
||||
case KEY_F5:
|
||||
*mutation_menu = 3;
|
||||
return 5;
|
||||
break;
|
||||
|
||||
// Return to the main menu
|
||||
case KEY_F6:
|
||||
*mutation_menu = 0;
|
||||
return 1;
|
||||
// Validation
|
||||
case KEY_SHIFT:
|
||||
if (*mutation_menu == 4) return 1;
|
||||
else return 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +131,7 @@ int get_inputs(const int background, int *mutation_menu)
|
|||
|
||||
int rtc_key(void)
|
||||
{
|
||||
int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS;
|
||||
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
|
||||
int timeout = 1;
|
||||
|
||||
key_event_t ev = getkey_opt(opt, &timeout);
|
||||
|
|
62
src/data.c
62
src/data.c
|
@ -4,20 +4,20 @@
|
|||
// (contation, severity, lethality, DNA cost, change to cure requirement)
|
||||
const struct mutation symptoms_data[14] =
|
||||
{
|
||||
{10, 10, 0, 2, 0, "NAUSEE"},
|
||||
{25, 10, 0, 10, 0, "VOMISSEMENT"},
|
||||
{20, 10, 0, 3, 0, "TOUX"},
|
||||
{15, 20, 0, 10, 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"},
|
||||
{25, 10, 20, 20, 0, "INFLAMMATION"},
|
||||
{10, 15, 20, 15, 0, "IMMUNITE"},
|
||||
{ 0, 20, 0, 15, 120, "PARANOIA"},
|
||||
{ 0, 15, 0, 20, 100, "FOLIE"},
|
||||
{ 0, 30, 30, 30, 250, "ARRET TOTAL"},
|
||||
{10, 10, 0, 2, 0, "NAUSEE"},
|
||||
{15, 10, 0, 10, 0, "VOMISSEMENT"},
|
||||
{10, 10, 0, 3, 0, "TOUX"},
|
||||
{15, 20, 0, 10, 0, "PNEUMONIE"},
|
||||
{10, 30, 20, 15, 10, "TUMEUR"},
|
||||
{15, 10, 0, 4, 0, "PLAIES"},
|
||||
{10, 10, 0, 10, 0, "LESIONS"},
|
||||
{30, 20, 20, 20, 5, "HEMORRAGIE"},
|
||||
{25, 15, 10, 17, 0, "INFECTION"},
|
||||
{15, 10, 20, 20, 0, "INFLAMMATION"},
|
||||
{10, 15, 20, 15, 0, "IMMUNITE"},
|
||||
{ 0, 20, 0, 15, 10, "PARANOIA"},
|
||||
{ 0, 15, 0, 20, 10, "FOLIE"},
|
||||
{ 0, 30, 30, 30, 20, "ARRET TOTAL"},
|
||||
};
|
||||
|
||||
|
||||
|
@ -25,28 +25,28 @@ const struct mutation abilities_data[6] =
|
|||
{
|
||||
{15, 0, 0, 10, 0, "FROID"},
|
||||
{15, 0, 0, 15, 0, "CHAUD"},
|
||||
{ 0, 10, 4, 25, 20, "GENETIQUE"},
|
||||
{10, 40, 20, 30, 50, "MUTATION+"},
|
||||
{30, 0, 0, 30, 0, "ENVIRON"},
|
||||
{ 0, 15, 30, 15, 30, "MEDICAMENT"},
|
||||
{ 0, 10, 4, 25, 10, "GENETIQUE"},
|
||||
{10, 40, 20, 30, 20, "MUTATION+"},
|
||||
{30, 10, 0, 30, 0, "ENVIRON"},
|
||||
{ 0, 15, 30, 15, 20, "MEDICAMENT"},
|
||||
};
|
||||
|
||||
|
||||
const struct mutation transmissions_data[13] =
|
||||
{
|
||||
{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"},
|
||||
{ 5, 0, 0, 9, 0, "AIR 1"},
|
||||
{10, 10, 0, 15, 0, "AIR 2"},
|
||||
{20, 10, 0, 20, 0, "AIR 3"},
|
||||
{40, 15, 0, 30, 0, "AEROSOL"},
|
||||
{10, 0, 0, 9, 0, "EAU 1"},
|
||||
{20, 10, 0, 12, 0, "EAU 2"},
|
||||
{20, 0, 0, 10, 0, "ANIMAL 1"},
|
||||
{40, 10, 0, 16, 0, "ANIMAL 2"},
|
||||
{20, 0, 0, 12, 0, "OISEAU 1"},
|
||||
{40, 10, 0, 16, 0, "OISEAU 2"},
|
||||
{10, 0, 0, 8, 0, "SANG 1"},
|
||||
{20, 10, 0, 14, 0, "SANG 2"},
|
||||
{40, 15, 0, 20, 0, "SANG 3"},
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ void display_background(const int background)
|
|||
}
|
||||
|
||||
|
||||
void display_foreground(const int background, const struct game *current_game)
|
||||
void display_foreground(const int background, const struct game *current_game, const int mutation_menu)
|
||||
{
|
||||
extern const bopti_image_t img_mutations;
|
||||
extern const bopti_image_t img_planes;
|
||||
|
@ -29,7 +29,7 @@ void display_foreground(const int background, const struct game *current_game)
|
|||
{
|
||||
for (int j = 0; j < current_game->grid.height; j ++)
|
||||
{
|
||||
if (current_game->grid.data[i + j * current_game->grid.width] == 1 && world[j][i] != 0) dpixel(i, j, C_BLACK);
|
||||
if ((current_game->grid.data[i + j * current_game->grid.width] == 1 || current_game->grid.data[i + j * current_game->grid.width] == 3) && world[j][i] != 0) dpixel(i, j, C_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ void display_foreground(const int background, const struct game *current_game)
|
|||
{
|
||||
for (int j = 0; j < 48; j ++)
|
||||
{
|
||||
if (current_game->grid.data[i + j * current_game->grid.width] == 1 && world[j][i] != 0) dpixel(i, j, C_BLACK);
|
||||
if ((current_game->grid.data[i + j * current_game->grid.width] == 1 || current_game->grid.data[i + j * current_game->grid.width] == 3) && world[j][i] != 0) dpixel(i, j, C_BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,8 @@ void display_foreground(const int background, const struct game *current_game)
|
|||
break;
|
||||
|
||||
case 3:
|
||||
drect(mutation_menu + 31 * (mutation_menu - 1), 0, mutation_menu + 31 * (mutation_menu), 7, C_INVERT);
|
||||
|
||||
dprint(102, 37, C_BLACK, "%d", current_game->dna);
|
||||
|
||||
length = 67 * current_game->contagion / 100;
|
||||
|
@ -80,9 +82,9 @@ void display_foreground(const int background, const struct game *current_game)
|
|||
dline(57, 60, 57 + length, 60, C_BLACK);
|
||||
dline(57, 61, 57 + length, 61, C_BLACK);
|
||||
|
||||
if (current_game->mutations_selected[0]) dsubimage(5, 15, &img_mutations, 0, 16 * (current_game->mutations_selected[0] - 1), 15, 15, 0);
|
||||
if (current_game->mutations_selected[1]) dsubimage(35, 15, &img_mutations, 16, 16 * (current_game->mutations_selected[1] - 1), 15, 15, 0);
|
||||
if (current_game->mutations_selected[2]) dsubimage(65, 15, &img_mutations, 32, 16 * (current_game->mutations_selected[2] - 1), 15, 15, 0);
|
||||
if (current_game->mutations_selected[0]) dsubimage(7, 15, &img_mutations, 0, 16 * (current_game->mutations_selected[0] - 1), 15, 15, 0);
|
||||
if (current_game->mutations_selected[1]) dsubimage(37, 15, &img_mutations, 16, 16 * (current_game->mutations_selected[1] - 1), 15, 15, 0);
|
||||
if (current_game->mutations_selected[2]) dsubimage(67, 15, &img_mutations, 32, 16 * (current_game->mutations_selected[2] - 1), 15, 15, 0);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
|
|
@ -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);
|
||||
void display_foreground(const int background, const struct game *current_game, const int mutation_menu);
|
||||
|
||||
// display_mutation : display the mutation selection screen
|
||||
void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu);
|
||||
|
|
|
@ -15,7 +15,7 @@ bool can_become_infected(const struct grid epidemic_grid, const int mutations_se
|
|||
extern const uint8_t world[64][128];
|
||||
|
||||
// In case of water, low or high temperature
|
||||
if (world[j][i] == 0 && mutations_selected[2] != 3) return false;
|
||||
if (world[j][i] == 0 && mutations_selected[2] != 3 && mutations_selected[2] != 2 && mutations_selected[2] != 5) 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;
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ void main_loop(struct game *current_game)
|
|||
// Update the screen
|
||||
dclear(C_WHITE);
|
||||
display_background(background);
|
||||
display_foreground(background, current_game);
|
||||
display_foreground(background, current_game, mutation_menu);
|
||||
dupdate();
|
||||
|
||||
// Compute the motion of planes, DNA points and infectious model
|
||||
|
|
|
@ -74,8 +74,8 @@ void mutation_select(struct game *current_game, const int mutation_menu)
|
|||
key = rtc_key();
|
||||
|
||||
// Manage input
|
||||
if (key == KEY_EXIT) end = 1;
|
||||
if (key == KEY_EXE && table[c.y][c.x] != 15 && table[c.y][c.x] != 0)
|
||||
if (key == KEY_ALPHA) end = 1;
|
||||
if (key == KEY_SHIFT && table[c.y][c.x] != 15 && table[c.y][c.x] != 0)
|
||||
{
|
||||
end = mutation_buy(current_game, c, mutation_menu, table);
|
||||
}
|
||||
|
@ -99,11 +99,16 @@ 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, current_game);
|
||||
key = getkey().key;
|
||||
|
||||
int opt = GETKEY_DEFAULT & ~GETKEY_MOD_SHIFT & ~GETKEY_MOD_ALPHA & ~GETKEY_REP_ARROWS;
|
||||
int timeout = NULL;
|
||||
|
||||
key_event_t ev = getkey_opt(opt, &timeout);
|
||||
key = ev.key;
|
||||
|
||||
if (key == KEY_DOWN || key == KEY_UP) button_selected = (button_selected + 1) % 2;
|
||||
if (key == KEY_EXIT) return 1;
|
||||
if (key == KEY_EXE)
|
||||
if (key == KEY_ALPHA) return 1;
|
||||
if (key == KEY_SHIFT)
|
||||
{
|
||||
if (!button_selected) return 0;
|
||||
else
|
||||
|
@ -122,6 +127,8 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
|
|||
|
||||
// Update
|
||||
update_disease(current_game);
|
||||
current_game->priority += floor((mutation_data->severity / 50) + (mutation_data->lethality / 50));
|
||||
|
||||
const char *msg[5] = {"mutation", "achetee", "", "", ""};
|
||||
message(msg);
|
||||
}
|
||||
|
@ -138,7 +145,7 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
|
|||
}
|
||||
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -158,7 +165,6 @@ 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) / 40);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue