Fix humans count and improve the game mecanics

This commit is contained in:
Shadow15510 2021-06-04 16:32:37 +02:00
parent 6c4278ffda
commit 5b3b26ba7d
11 changed files with 57 additions and 36 deletions

Binary file not shown.

View File

@ -1,9 +1,22 @@
# Plague
## Généralités
### Présentation
Plague inc est un jeu de stratégie où le but est de réduire l'humanité à néant… Simple ? Non ! Il vous faudra manipuler avec dextérité et prudence un virus pour anéantir des humains qui ne sont pas super collaboratifs… Pire, ces petits rigolos veulent sauver leurs peaux et recherchent activement un remède à ce mystérieux virus inconnu !
Vous commencez la partie en Asie Centrale.
### Licence
La totalité du projet est soumise à la licence GNU General Public Licence v3.0.
### To do list
- Ajouter *in-game* des information sur chaque mutation
- Corriger le calcul avec les statistiques des humains
## Contrôles
Lancez le jeu, et pressez n'importe quelle touche pour passer l'écran principal. Une fois sur l'écran représentant la Terre, plusieurs choix s'offrent à vous :
@ -38,5 +51,4 @@ En mutant, votre maladie peut acquérir des capacités. Ces capacités lui perme
### Moyens de transmissions
Votre maladie aura tout le loisir de changer ses moyens de transmission ! Plus ou moins efficaces ceux-ci permettent à votre maladie d'accéder à des caractéristiques intéressantes qui lui permettront de coloniser le monde entier !
Votre maladie aura tout le loisir de changer ses moyens de transmission ! Plus ou moins efficaces ceux-ci permettent à votre maladie d'accéder à des caractéristiques intéressantes qui lui permettront de coloniser le monde entier !

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -14,12 +14,11 @@ def show():
img = Image.open("world.png")
data = np.array(img)
rslt = ""
count = 0
for index, line in enumerate(data):
for pxl in line:
rslt += f"{analyse(index, pxl)}"
rslt += "\n"
print(rslt)
if analyse(index, pxl) == 0: count += 1
print(count)
def get_tabular():
@ -35,5 +34,4 @@ def get_tabular():
rslt += "\n};"
print(rslt)
get_tabular()
show()

View File

@ -48,8 +48,6 @@ void next_frame(struct game *current_game)
// Infect the plane
if (current_game->grid.data[current_game->planes[i]->x + current_game->planes[i]->y * current_game->grid.width] == 1 && current_game->mutations_selected[2] == 4) current_game->planes[i]->is_infected = 1;
}
}
@ -64,16 +62,12 @@ void next_frame(struct game *current_game)
// Update the game
current_game->dna = current_game->dna + 1 + floor(current_game->severity / 25);
if (current_game->dna > 30) current_game->dna = 30;
if (current_game->research < current_game->limit) current_game->research += current_game->priority;
current_game->research += current_game->priority;
if (current_game->research > current_game->limit) current_game->research = current_game->limit;
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;
}
if (!current_game->humans[1])
{
if (current_game->humans[0] != 0)

View File

@ -3,8 +3,6 @@
#include <gint/defs/types.h>
// Duration for internal clock (ms)
#define ENGINE_TICK 50
#define CURSOR_TICK 150
@ -16,6 +14,9 @@
// Number of planes on screen
#define NB_PLANES 5
// Number of non-infectable cases
#define BLANK_CASES 5382
struct grid
{
// 64, 128

View File

@ -90,7 +90,7 @@ void display_foreground(const int background, const struct game *current_game, c
case 6:
for (int i = 0; i < 4; i ++)
{
length = 63 * current_game->humans[i] / (current_game->grid.width * current_game->grid.height);
length = 63 * current_game->humans[i] / ((current_game->grid.width * current_game->grid.height) - BLANK_CASES);
dline(61, i*8 + 31, 61 + length, i*8 + 31, C_BLACK);
dline(61, i*8 + 32, 61 + length, i*8 + 32, C_BLACK);
}

View File

@ -32,6 +32,8 @@ bool bernoulli(const int p)
void epidemic_simulation(struct game *current_game)
{
extern const uint8_t world[64][128];
srand(current_game->total_time);
// Create a copy of the epidemic grid
@ -54,8 +56,11 @@ void epidemic_simulation(struct game *current_game)
if (can_become_infected(current_game->grid, current_game->mutations_selected, i, j) && bernoulli(current_game->contagion))
{
current_grid[i + j * current_game->grid.width] = 1;
current_game->humans[0] --;
current_game->humans[1] ++;
if (world[j][i])
{
current_game->humans[0] --;
current_game->humans[1] ++;
}
}
break;
@ -66,16 +71,22 @@ void epidemic_simulation(struct game *current_game)
if (bernoulli(healed_rate))
{
current_grid[i + j * current_game->grid.width] = 2;
current_game->humans[1] --;
current_game->humans[2] ++;
if (world[j][i])
{
current_game->humans[1] --;
current_game->humans[2] ++;
}
}
// Become dead
else if (bernoulli(current_game->lethality))
{
current_grid[i + j * current_game->grid.width] = 3;
current_game->humans[1] --;
current_game->humans[3] ++;
if (world[j][i])
{
current_game->humans[1] --;
current_game->humans[3] ++;
}
}
break;
}

View File

@ -1,6 +1,6 @@
/*
Project name ......: Plague
Version ...........: 1.2
Version ...........: 1.2.1
Last modification .: 4 June 2021
code and assets provided with licence :
@ -70,7 +70,7 @@ int main(void)
current_game.grid.data = calloc(current_game.grid.width * current_game.grid.height, sizeof(uint8_t));
current_game.grid.data[95 + 20 * current_game.grid.width] = 1;
current_game.humans[0] = (current_game.grid.width * current_game.grid.height) - 1;
current_game.humans[0] = (current_game.grid.width * current_game.grid.height) - 1 - BLANK_CASES;
read_save(&current_game);
@ -130,7 +130,7 @@ static void title_screen(void)
void main_loop(struct game *current_game)
{
int background = 1, mutation_menu = 0;
int background = 1, mutation_menu = 4;
int end = 0;
static volatile int tick = 1;

View File

@ -80,10 +80,13 @@ void mutation_select(struct game *current_game, const int mutation_menu)
end = mutation_buy(current_game, c, mutation_menu, table);
}
if (key == KEY_LEFT && c.x > 0) c.x = (c.x - 1) % 8;
if (key == KEY_RIGHT && c.x < 7) c.x = (c.x + 1) % 8;
if (key == KEY_UP && c.y > 0) c.y = (c.y - 1) % 4;
if (key == KEY_DOWN && c.y < 3) c.y = (c.y + 1) % 4;
if (key == KEY_LEFT) c.x = c.x - 1;
if (key == KEY_RIGHT) c.x = (c.x + 1) % 8;
if (key == KEY_UP) c.y = c.y - 1;
if (key == KEY_DOWN) c.y = (c.y + 1) % 4;
if (c.x < 0) c.x = 7;
if (c.y < 0) c.y = 3;
}
if (t >= 0) timer_stop(t);
}
@ -125,7 +128,7 @@ int mutation_buy(struct game *current_game, const struct cursor c, const int mut
// Update
update_disease(current_game);
current_game->priority += ceil((mutation_data->severity + mutation_data->lethality)/10);
current_game->priority += ceil((mutation_data->severity + mutation_data->lethality)/8);
const char *msg[5] = {"mutation", "achetee", "", "", ""};
message(msg);
}
@ -160,8 +163,10 @@ void update_disease(struct game *current_game)
current_game->severity = symptom->severity + ability->severity + transmission->severity;
current_game->lethality = symptom->lethality + ability->lethality + transmission->lethality;
// research parameters
// research parameter
current_game->limit = RESEARCH_LIMIT + symptom->changement + ability->changement + transmission->changement;
if (current_game->research > current_game->limit) current_game->research = current_game->limit;
}

View File

@ -5,7 +5,7 @@
#include "display_engine.h"
// Basic limit research
#define RESEARCH_LIMIT 100
#define RESEARCH_LIMIT 200
// mutation_table : contain the map of the mutation available
struct mutation_table