diff --git a/CMakeLists.txt b/CMakeLists.txt index 62a715c..0c2b79c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set(SOURCES src/core.c src/display_engine.c src/mutation_engine.c + src/mutation_data.c # ... ) # Shared assets, fx-9860G-only assets and fx-CG-50-only assets @@ -36,9 +37,6 @@ set(ASSETS_fx assets-fx/mutations_table/transmissions_1.txt assets-fx/mutations_table/transmissions_2.txt assets-fx/mutations_table/transmissions_3.txt - assets-fx/mutations_data/abilities.txt - assets-fx/mutations_data/symptoms.txt - assets-fx/mutations_data/transmissions.txt # ... ) set(ASSETS_cg diff --git a/Plague.g1a b/Plague.g1a index b180f0a..ce87a5e 100644 Binary files a/Plague.g1a and b/Plague.g1a differ diff --git a/assets-fx/bground.png b/assets-fx/bground.png index a50e413..e4438b1 100644 Binary files a/assets-fx/bground.png and b/assets-fx/bground.png differ diff --git a/assets-fx/converters.py b/assets-fx/converters.py index 10a2b88..b31c588 100644 --- a/assets-fx/converters.py +++ b/assets-fx/converters.py @@ -5,7 +5,7 @@ def convert(input_name, output, params, target): if params["custom-type"] == "mutation-table": convert_mt(input_name, output, params, target) return 0 - elif params["custom-type"] == "mutation-data": + elif params["custom-type"] == "mutation": convert_md(input_name, output, params, target) return 0 else: @@ -26,15 +26,3 @@ def convert_mt(input_name, output, params, target): fxconv.elf(data, output, "_" + params["name"], **target) - -def convert_md(input_name, output, params, target): - with open(input_name, "r") as file: - # Extract informations - lines = file.read().splitlines() - - # Convert data into bytes-like object - data = bytes() - for i in lines: - data += bytes(i, encoding="utf-8") - - fxconv.elf(data, output, "_" + params["name"], **target) diff --git a/assets-fx/mutations.png b/assets-fx/mutations.png index 6970d18..d6f671b 100644 Binary files a/assets-fx/mutations.png and b/assets-fx/mutations.png differ diff --git a/assets-fx/mutations_data/abilities.txt b/assets-fx/mutations_data/abilities.txt deleted file mode 100644 index 2a93ce9..0000000 --- a/assets-fx/mutations_data/abilities.txt +++ /dev/null @@ -1,14 +0,0 @@ -FROID,4,0,0,10,0 -CHAUD,7,0,0,15,0 -GENETIQUE,0,5,4,25, -MUTATION+,0,8,8,30,2 -ENVIRON,10,0,0,30,0 -MEDICAMENT,0,2,2,15,1 -NONE -NONE -NONE -NONE -NONE -NONE -NONE -NONE \ No newline at end of file diff --git a/assets-fx/mutations_data/fxconv-metadata.txt b/assets-fx/mutations_data/fxconv-metadata.txt deleted file mode 100644 index 0ad2668..0000000 --- a/assets-fx/mutations_data/fxconv-metadata.txt +++ /dev/null @@ -1,3 +0,0 @@ -*.txt: - custom-type: mutation-data - name_regex: (.*)\.txt md_\1 \ No newline at end of file diff --git a/assets-fx/mutations_data/symptoms.txt b/assets-fx/mutations_data/symptoms.txt deleted file mode 100644 index 7ccbfa5..0000000 --- a/assets-fx/mutations_data/symptoms.txt +++ /dev/null @@ -1,14 +0,0 @@ -NAUSEE,1,1,0,2,0.5, -VOMISSEMENT,3,2,0,4,0.5 -TOUX,2,1,0,3,0.5 -PNEUMONIE,2,2,0,4,0.5 -TUMEUR,4,2,5,15,1 -PLAIES,2,1,0,3,0.5 -LESIONS,5,4,0,10,0.5 -HEMORRAGIE,5,15,15,20,0.5 -INFLAMMATION,2,2,2,5,0.5 -INFECTION,6,7,6,17,0.5 -IMMUNODEFICIENCE,2,6,4,12,1 -PARANOIA,0,4,0,5,1 -FOLIE,6,15,0,20,2 -ARRETTOTAL,0,20,25,30,2 \ No newline at end of file diff --git a/assets-fx/mutations_data/transmissions.txt b/assets-fx/mutations_data/transmissions.txt deleted file mode 100644 index c4f008c..0000000 --- a/assets-fx/mutations_data/transmissions.txt +++ /dev/null @@ -1,14 +0,0 @@ -AIR1,2,0,0,9,0 -AIR2,5,0,0,15,0 -AIR3,8,0,0,20,0 -AEROSOL,10,0,0,30,0 -EAU1,2,0,0,9,0 -EAU2,4,0,0,12,0 -OISEAU1,3,0,0,12,0 -OISEAU2,6,0,0,16,0 -ANIMAL1,2,0,0,10,0 -ANIMAL2,6,0,0,16,0 -SANG1,1,0,0,8,0 -SANG2,4,0,0,14,0 -SANG3,9,0,0,20,0 -NONE \ No newline at end of file diff --git a/assets-fx/mutations_table/abilities_1.txt b/assets-fx/mutations_table/abilities_1.txt index 52ca2ed..7757355 100644 --- a/assets-fx/mutations_table/abilities_1.txt +++ b/assets-fx/mutations_table/abilities_1.txt @@ -1,4 +1,4 @@ -1 | 0 | 0 | 0 | 6 | 0 | 0 | 0 -7 | 7 | 0 | 7 | 0 | 0 | 0 | 0 -0 | 0 | 0 | 0 | 7 | 0 | 0 | 0 -0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \ No newline at end of file + 1 | 0 | 0 | 0 | 6 | 0 | 0 | 0 +15 | 15 | 0 | 15 | 0 | 0 | 0 | 0 + 0 | 0 | 0 | 0 | 15 | 0 | 0 | 0 + 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \ No newline at end of file diff --git a/assets-fx/mutations_table/abilities_2.txt b/assets-fx/mutations_table/abilities_2.txt index d2f497b..b54ad81 100644 --- a/assets-fx/mutations_table/abilities_2.txt +++ b/assets-fx/mutations_table/abilities_2.txt @@ -1,4 +1,4 @@ -1 | 0 | 0 | 0 | 6 | 0 | 0 | 0 -2 | 7 | 0 | 3 | 0 | 0 | 0 | 0 -0 | 0 | 0 | 0 | 7 | 0 | 0 | 0 -0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \ No newline at end of file +1 | 0 | 0 | 0 | 6 | 0 | 0 | 0 +2 | 15 | 0 | 3 | 0 | 0 | 0 | 0 +0 | 0 | 0 | 0 | 15 | 0 | 0 | 0 +0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 \ No newline at end of file diff --git a/assets-fx/mutations_table/transmissions_1.txt b/assets-fx/mutations_table/transmissions_1.txt index 0fde8a8..2e0695b 100644 --- a/assets-fx/mutations_table/transmissions_1.txt +++ b/assets-fx/mutations_table/transmissions_1.txt @@ -1,4 +1,4 @@ -1 | 14 | 14 | 0 | 14 | 5 | 0 | 0 -0 | 0 | 0 | 14 | 0 | 0 | 0 | 11 -9 | 14 | 0 | 0 | 0 | 0 | 0 | 14 -0 | 0 | 0 | 7 | 14 | 0 | 0 | 14 \ No newline at end of file +1 | 15 | 15 | 0 | 15 | 5 | 0 | 0 +0 | 0 | 0 | 15 | 0 | 0 | 0 | 11 +9 | 15 | 0 | 0 | 0 | 0 | 0 | 15 +0 | 0 | 0 | 7 | 15 | 0 | 0 | 15 \ No newline at end of file diff --git a/assets-fx/mutations_table/transmissions_2.txt b/assets-fx/mutations_table/transmissions_2.txt index ed42e81..91b216a 100644 --- a/assets-fx/mutations_table/transmissions_2.txt +++ b/assets-fx/mutations_table/transmissions_2.txt @@ -1,4 +1,4 @@ -1 | 2 | 14 | 0 | 6 | 5 | 0 | 0 -0 | 0 | 0 | 14 | 0 | 0 | 0 | 11 +1 | 2 | 15 | 0 | 6 | 5 | 0 | 0 +0 | 0 | 0 | 15 | 0 | 0 | 0 | 11 9 | 10 | 0 | 0 | 0 | 0 | 0 | 12 -0 | 0 | 0 | 7 | 8 | 0 | 0 | 14 \ No newline at end of file +0 | 0 | 0 | 7 | 8 | 0 | 0 | 15 \ No newline at end of file diff --git a/src/core.c b/src/core.c index e57f55d..f27576c 100644 --- a/src/core.c +++ b/src/core.c @@ -58,7 +58,7 @@ int get_inputs(const int background, int *mutation_menu) { if (background == 5) return 3; if (background != 1 && background != 2) return 1; - if (background == 1) return -1; + if (background == 1 || background == 2) return -1; } if (background == 3) @@ -134,8 +134,6 @@ void manage_mutation(struct game *current_game, const int mutation_menu) // Get and display the mutation menu int table[4][8]; get_mutation(current_game, mutation_menu, table); - char data[14]; - get_mutation_data(mutation_menu, data); display_mutation(table, c, mutation_menu); // Get the key @@ -143,7 +141,11 @@ void manage_mutation(struct game *current_game, const int mutation_menu) // Manage input if (key == KEY_EXIT) end = 1; - // if (key == KEY_EXE) mutation_selected(c, mutation_menu, get_mutation_data(current_game, mutation_menu)); + if (key == KEY_EXE && table[c.y][c.x] != 15 && table[c.y][c.x] != 0) + { + mutation_selected(c, mutation_menu, table); + getkey(); + } if (key == KEY_LEFT && c.x > 0) c.x--; if (key == KEY_RIGHT && c.x < 7) c.x++; diff --git a/src/core.h b/src/core.h index cf93a01..b6e9545 100644 --- a/src/core.h +++ b/src/core.h @@ -3,7 +3,7 @@ // Duration for internal clock #define ENGINE_TICK 50 -#define CURSOR_TICK 200 +#define CURSOR_TICK 100 // Number of planes on screen #define NB_PLANES 5 @@ -79,5 +79,4 @@ int callback_tick(volatile int *tick); // manage_mutation : an independant sub-programm which allow to select, buy and see the mutations. void manage_mutation(struct game *current_game, const int mutation_menu); - #endif /* _PLAGUE_CORE_H */ \ No newline at end of file diff --git a/src/display_engine.c b/src/display_engine.c index 31caeeb..98e4cc9 100644 --- a/src/display_engine.c +++ b/src/display_engine.c @@ -98,3 +98,47 @@ void display_mutation(const int table[4][8], const struct cursor c, const int mu } + +void mutation_selected(const struct cursor c, const int mutation_menu, const int table[4][8]) +{ + extern const bopti_image_t img_mutations; + const int id = table[c.y][c.x]; + + extern struct mutation symptoms_data[14]; + extern struct mutation abilities_data[6]; + extern struct mutation transmissions_data[13]; + + struct mutation *mutation_data; + + switch (mutation_menu) + { + case 1: + mutation_data = &symptoms_data[id - 1]; + break; + + case 2: + mutation_data = &abilities_data[id - 1]; + break; + + case 3: + mutation_data = &transmissions_data[id - 1]; + break; + } + + dclear(C_WHITE); + + display_background(4); + dsubimage(3, 21, &img_mutations, 16 * (mutation_menu - 1), 16 * (id - 1), 15, 15, DIMAGE_NONE); + + dprint(47, 25, C_BLACK, mutation_data->name); + dprint(81, 33, C_BLACK, "%d", mutation_data->dna); + dprint(81, 41, C_BLACK, "%d", mutation_data->contagion); + dprint(81, 49, C_BLACK, "%d", mutation_data->lethality); + dprint(81, 57, C_BLACK, "%d", mutation_data->severity); + + dupdate(); + + +} + + diff --git a/src/display_engine.h b/src/display_engine.h index 57fbeaa..23898a9 100644 --- a/src/display_engine.h +++ b/src/display_engine.h @@ -12,4 +12,7 @@ void display_foreground(const int background, const struct game *current_game); // display_mutation : display the mutation selection screen void display_mutation(const int table[4][8], const struct cursor c, const int mutation_menu); +// mutation_selected : display the mutation shop +void mutation_selected(const struct cursor c, const int mutation_menu, const int table[4][8]); + #endif /* _PLAGUE_DISPLAY_ENGINE_H */ \ No newline at end of file diff --git a/src/main.c b/src/main.c index c8e4e6d..a161c31 100644 --- a/src/main.c +++ b/src/main.c @@ -30,13 +30,14 @@ int main(void) title_screen(); + // Game statistics struct plane plane_1 = {22, 20, 2, 84, 20, 22, 20}; struct plane plane_2 = {34, 20, 3, 34, 44, 34, 20}; struct plane plane_3 = {68, 44, 1, 68, 20, 68, 44}; struct plane plane_4 = {104, 20, 3, 104, 50, 104, 20}; struct plane plane_5 = {68, 44, 4, 34, 44, 68, 44}; - GUNUSED struct game current_game = + struct game current_game = { .contagion = 0, .severity = 0, diff --git a/src/mutation_data.c b/src/mutation_data.c new file mode 100644 index 0000000..f298398 --- /dev/null +++ b/src/mutation_data.c @@ -0,0 +1,46 @@ +#include "mutation_engine.h" + +const struct mutation abilities_data[6] = +{ + {4, 0, 0, 10, 0, "FROID"}, + {7, 0, 0, 15, 0, "CHAUD"}, + {0, 5, 4, 25, 0, "GENETIQUE"}, + {0, 8, 8, 30, 2, "MUTATION+"}, + {10, 0, 0, 30, 0, "ENVIRON"}, + {0, 2, 2, 15, 1, "MEDICAMENT"}, +}; + +const struct mutation symptoms_data[14] = +{ + {1, 1, 0, 2, 0.5, "NAUSEE"}, + {3, 2, 0, 4, 0.5, "VOMISSEMENT"}, + {2, 1, 0, 3, 0.5, "TOUX"}, + {2, 2, 0, 4, 0.5, "PNEUMONIE"}, + {4, 2, 5, 15, 1, "TUMEUR"}, + {2, 1, 0, 3, 0.5, "PLAIES"}, + {5, 4, 0, 10, 0.5, "LESIONS"}, + {5, 15, 15, 20, 0.5, "HEMORRAGIE"}, + {6, 7, 6, 17, 0.5, "INFECTION"}, + {2, 2, 2, 5, 0.5, "INFLAMMATION"}, + {2, 6, 4, 12, 1, "IMMUNODEFICIENCE"}, + {0, 4, 0, 5, 1, "PARANOIA"}, + {6, 15, 0, 20, 2, "FOLIE"}, + {0, 20, 25, 30, 2, "ARRET TOTAL"}, +}; + +const struct mutation transmissions_data[13] = +{ + { 2, 0, 0, 9, 0, "AIR 1"}, + { 5, 0, 0, 15, 0, "AIR 2"}, + { 8, 0, 0, 20, 0, "AIR 3"}, + {10, 0, 0, 30, 0, "AEROSOL"}, + { 2, 0, 0, 9, 0, "EAU 1"}, + { 4, 0, 0, 12, 0, "EAU 2"}, + { 2, 0, 0, 10, 0, "ANIMAL 1"}, + { 6, 0, 0, 16, 0, "ANIMAL 2"}, + { 3, 0, 0, 12, 0, "OISEAU 1"}, + { 6, 0, 0, 16, 0, "OISEAU 2"}, + { 1, 0, 0, 8, 0, "SANG 1"}, + { 4, 0, 0, 14, 0, "SANG 2"}, + { 9, 0, 0, 20, 0, "SANG 3"}, +}; \ No newline at end of file diff --git a/src/mutation_engine.c b/src/mutation_engine.c index a5b4c99..a4dc60b 100644 --- a/src/mutation_engine.c +++ b/src/mutation_engine.c @@ -40,29 +40,6 @@ void get_mutation(const struct game *current_game, const int mutation_menu, int } -void get_mutation_data(const int mutation_menu, char data[14]) -{ - extern struct mutation_data md_abilities; - extern struct mutation_data md_symptoms; - extern struct mutation_data md_transmissions; - - switch (mutation_menu) - { - case 1: - char_init_mat(14, data, md_symptoms.data); - break; - - case 2: - char_init_mat(14, data, md_abilities.data); - break; - - case 3: - char_init_mat(14, data, md_transmissions.data); - break; - } -} - - void init_mat(int x, int y, int dest[][x], int src[][x]) { for (int i = 0; i < x; i++) @@ -74,11 +51,4 @@ void init_mat(int x, int y, int dest[][x], int src[][x]) } } -void char_init_mat(int x, char dest[x], char src[x]) -{ - for (int i = 0; i < x; i++) - { - dest[i] = src[i]; - } -} diff --git a/src/mutation_engine.h b/src/mutation_engine.h index 1b99a7a..a132110 100644 --- a/src/mutation_engine.h +++ b/src/mutation_engine.h @@ -10,19 +10,19 @@ struct mutation_table int data[4][8]; }; -// mutation_data : contain the mutations data -struct mutation_data +// mutation : data about a mutation +struct mutation { - // Data of the mutations - char data[14]; + // Data of the mutation : contagion, lethality, severity, DNA cost + int contagion, severity, lethality, dna, changement; + + // Name of the mutation + char *name; }; // get_mutation : return the mutation table to display void get_mutation(const struct game *current_game, const int mutation_menu, int table[4][8]); -// get_mutation_data : return the mutation_data -void get_mutation_data(const int mutation_menu, char data[14]); - // init_mat : copy src into dest (for int) void init_mat(int x, int y, int dest[][x], int src[][x]);