Compare commits

...

6 Commits

Author SHA1 Message Date
Shadow15510 b4d7f1fcdf Fix airport's box 2022-07-05 16:46:29 +02:00
Shadow15510 0a648cea10 Fix bug on game's structure declaration 2022-07-05 16:02:37 +02:00
Shadow15510 e495ee83e7 Update README.md 2022-06-24 13:13:38 +02:00
Shadow15510 aa2e4b5a4c Update README.md 2022-06-24 13:10:50 +02:00
Shadow15510 7a0e19c00c Minor changements 2022-06-24 13:06:30 +02:00
Shadow15510 70bce561ba Fix bugs around the evolution of statistics 2022-06-24 09:46:23 +02:00
7 changed files with 158 additions and 66 deletions

View File

@ -2,8 +2,51 @@
## Presentation
This game is a redesign of [CalcCity](https://www.planet-casio.com/Fr/programmes/programme1062-1-calccity-v3-menno-jeux-add-ins.html), a management game like Sim's City.
Ce jeu est une refonte de [CalcCity](https://www.planet-casio.com/Fr/programmes/programme1062-1-calccity-v3-menno-jeux-add-ins.html), un jeu de gestion inspiré de Sims' City.
## License
All rights reserved.
Tout droits réservés.
## Contrôles
- [REPLAY] : se déplacer
- [F1] et [F2] : menus de construction des bâtiments
- [F4] : taxes et subventions
- [F5] : statistiques
- [F6] : options diverses
- [+] et [-] : zoomer / dézoomer sur la carte
- [SHIFT] : valider
- [ALPHA] : revenir en arrière
- [OPTN] : affiche le nom du bâtiment sous le curseur
### Construction
Vous serez amener à constuire une ville, pour cela selectionnez un des deux menus de construction puis le bâtiment qui vous intéresse via [REPLAY] puis [SHIFT]. Le cadre autour du curseur vous indique où le bâtiment va se positionner. Certains bâtiments agencés en carrés permettent de construire un bâtiment plus grand et plus efficace.
Vous pouvez détruire un bâtiment en "construisant" de la terre dessus.
### Taxes et subventions
Votre ville à besoin de son état ! Les pompiers, les services de santés et les policiers ont besoin de subventions pour fonctionner correctement. Baisser les subventions vous expose à un risque plus ou moins grand de catastrophe.
À l'inverse les taxes vous permettent de faire monter vos revenus annuels, attention, booster les taxes peut aussi décourager les investissements dans votre ville et ainsi conduire à une perte importante d'argent.
### Statistiques
Vous permet de consulter les statistiques de votre ville. Les stats sont classées par catégories.
### Options
Le jeu est muni de quelques options.
- les animations : eau, warnings divers peuvent être (dé)activés
- les catastrophes : marre de voir votre ville détruite par un tremblement de terre ou autre évènements? Vous pouvez les enlever!
- la vitesse du jeu : régule l'allure à laquelle le temps passe (mois / années dans le jeu)
- quitter le jeu : sauvegarde et quitte
- reprendre la partie : continue la partie
## Conseils divers
Vous ne pouvez pas perdre, d'abord parce qu'il n'y pas de but à proprement parler, ensuite parce que si vous arrivez à 0$ de trésorerie à la fin de l'année, votre caisse sera renflouée de 1000$. C'est peu mais suffisant pour détruire les bâtiments qui coûte le plus cher et ainsi repartir d'un bon pied.
Ne négligez rien. Et le plus important : enjoy~!

View File

@ -68,6 +68,7 @@ struct camera
int cursor_x, cursor_y;
int cursor_size[2];
int display_name;
};

View File

@ -4,7 +4,9 @@
#include <gint/timer.h>
#include <gint/clock.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include "core.h"
@ -19,7 +21,7 @@ int callback_tick(volatile int *tick)
void default_values(struct calccity *calccity, struct camera *camera, struct map *map)
{
srand(20211104);
srand(clock());
// Initialisation of struct calccity
memset(calccity, 0, sizeof *calccity);
@ -112,47 +114,47 @@ void next_step(struct calccity *calccity, struct map *map)
end_year(calccity);
calccity->month = 1;
calccity->year ++;
}
if (calccity->disaster)
{
int random_event = rand() % 10000;
// Firehazard
if (calccity->stat[7] > 500 && random_event == 0)
if (calccity->disaster)
{
display_message("UN INCENDIE A RAVAGE VOTRE VILLE.");
disaster(calccity, map, calccity->stat[7]);
update_stat(calccity, map);
}
// Nuclear disaster
if (calccity->stat[8] >= 1 && random_event == 1)
{
display_message("UN ACCIDENT NUCLEAIRE A RAVAGE VOTRE VILLE.");
disaster(calccity, map, calccity->stat[8] * 100);
update_stat(calccity, map);
}
// Earthquake
if (random_event == 2)
{
display_message("UN TREMBLEMENT DE TERRE A RAVAGE VOTRE VILLE.");
disaster(calccity, map, rand() % 10);
update_stat(calccity, map);
}
// Treasure
if (calccity->misc[0] > 1000 && random_event == 3)
{
if (rand() % 2)
int random_event = rand() % 10000;
// Firehazard
if (calccity->stat[7] > 1000 && random_event == 0)
{
display_message("DES INVESTISSEMENT AUDACIEUX VOUS ONT RAPPORTES 1000$ !");
calccity->misc[0] += 1000;
display_message("UN INCENDIE A RAVAGE VOTRE VILLE.");
disaster(calccity, map, calccity->stat[7]);
update_stat(calccity, map);
}
else
// Nuclear disaster
if (calccity->stat[8] >= 1 && random_event == 1)
{
display_message("DES INVESTISSEMENT FOIREUX VOUS ONT FAIT PERDRE 1000$.");
calccity->misc[0] -= 1000;
display_message("UN ACCIDENT NUCLEAIRE A RAVAGE VOTRE VILLE.");
disaster(calccity, map, calccity->stat[8] * 100);
update_stat(calccity, map);
}
// Earthquake
if (random_event == 2)
{
display_message("UN TREMBLEMENT DE TERRE A RAVAGE VOTRE VILLE.");
disaster(calccity, map, rand() % 10);
update_stat(calccity, map);
}
// Treasure
if (calccity->misc[0] > 1000 && random_event == 3)
{
if (rand() % 2)
{
display_message("DES INVESTISSEMENT AUDACIEUX VOUS ONT RAPPORTES 1000$ !");
calccity->misc[0] += 1000;
}
else
{
display_message("DES INVESTISSEMENT FOIREUX VOUS ONT FAIT PERDRE 1000$.");
calccity->misc[0] -= 1000;
}
}
}
}
@ -189,11 +191,12 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
display_main(calccity, camera, map, 1);
if (build_mode >= 0)
{
char building_data[50];
sprintf(building_data, "%s:%d$", building.name, building.cost);
int width;
dsize(building.name, NULL, &width, NULL);
drect(4, 6, 5 + width, 17, C_WHITE);
dprint_opt(5, 7, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "$%d", building.cost);
dprint_opt(5, 13, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%s", building.name);
dsize(building_data, NULL, &width, NULL);
drect(4, 6, 5 + width, 11, C_WHITE);
dprint_opt(5, 7, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, building_data);
}
dupdate();
@ -233,6 +236,9 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
if (build_mode >= 0)
{
if (camera->display_name)
camera->display_name = 0;
// Build annulation
if (key == KEY_ALPHA)
exit_build_mode(camera, &build_mode);
@ -283,6 +289,10 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
}
}
// Exit build mode
if (build_mode != -1)
exit_build_mode(camera, &build_mode);
// Free timer
if (t >= 0) timer_stop(t);
}
@ -330,8 +340,14 @@ void keyboard_managment(struct camera *camera, const int key, const int build_mo
if (camera->x > 35) camera->x = 35;
if (camera->y > 43) camera->y = 43;
camera->zoom = 1;
camera->display_name = 0;
}
break;
case KEY_OPTN:
if (!camera->zoom)
camera->display_name = (camera->display_name + 1) % 2;
break;
}
}
@ -488,22 +504,22 @@ void update_stat(struct calccity *calccity, struct map *map)
// FUNDS : health
case 1:
calccity->stat[i] += floor(building.stat[i] * (calccity->funds[3] / 100));
calccity->stat[i] += floor((building.stat[i] * calccity->funds[3]) / 100);
break;
// FUNDS : crime
case 6:
calccity->stat[i] += floor(building.stat[i] * (calccity->funds[0] / 100));
calccity->stat[i] += floor((building.stat[i] * calccity->funds[0]) / 100);
break;
// FUNDS : firehazard
case 7:
calccity->stat[i] += floor(building.stat[i] * (calccity->funds[1] / 100));
calccity->stat[i] += floor((building.stat[i] * calccity->funds[1]) / 100);
break;
// FUNDS : education
case 2:
calccity->stat[i] += floor(building.stat[i] * (calccity->funds[2] / 100));
calccity->stat[i] += floor((building.stat[i] * calccity->funds[2]) / 100);
break;
// special calculation of the annual cost
@ -779,7 +795,7 @@ void disaster(struct calccity *calccity, struct map *map, const int destruction_
{
for (int x = 0; x < 50; x ++)
{
if (map->id[y][x] > 1 && rand() % destruction_rate <= destruction_rate / 4)
if (map->id[y][x] > 1 && rand() % destruction_rate <= destruction_rate / 10)
{
map->id[y][x] = 0;
map->data[y][x] = 125 + rand() % 2;

View File

@ -23,12 +23,12 @@ void display_main(struct calccity *calccity, struct camera *camera, struct map *
if (camera->zoom == 0)
{
display_large_map(calccity, camera, map);
display_around(calccity, camera, disp_cursor);
display_around(calccity, camera, map, disp_cursor);
}
else
{
display_mini_map(camera, map);
display_around(calccity, camera, 0);
display_around(calccity, camera, map, 0);
}
}
@ -92,13 +92,33 @@ void display_mini_map(struct camera *camera, struct map *map)
}
}
void display_around(struct calccity *calccity, struct camera *camera, const int disp_cursor)
void display_around(struct calccity *calccity, struct camera *camera, struct map *map, const int disp_cursor)
{
extern const bopti_image_t img_fn_keys;
extern const struct building buildings[42];
// Date in the top-left corner and treasure
char up_data[25];
sprintf(up_data, "%d-%d | %d$", calccity->month, calccity->year, calccity->misc[0]);
// Informations on top-left corner (time, treasure, building under cursor)
if (camera->display_name)
{
char id;
unsigned short loc_x = floor(camera->x + camera->cursor_x / 2);
unsigned short loc_y = floor(camera->y + camera->cursor_y / 2);
if (map->id[loc_y][loc_x] == -1)
id = get_reference_id(map->data[loc_y][loc_x]);
else
id = map->id[loc_y][loc_x];
char building_data[50];
sprintf(building_data, "%s", buildings[id].name);
int width;
dsize(building_data, NULL, &width, NULL);
drect(4, 6, 5 + width, 11, C_WHITE);
dprint_opt(5, 7, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, building_data);
}
char up_data[50];
sprintf(up_data, "%d-%d %d$", calccity->month, calccity->year, calccity->misc[0]);
int width;
dsize(up_data, NULL, &width, NULL);
drect(4, 1, 5 + width, 6, C_WHITE);
@ -120,6 +140,7 @@ void display_around(struct calccity *calccity, struct camera *camera, const int
{
unsigned short x = camera->cursor_size[0] * floor(camera->cursor_x / (floor(camera->cursor_size[0] / 8) + 1)) + 3;
unsigned short y = camera->cursor_size[1] * floor(camera->cursor_y / (floor(camera->cursor_size[1] / 8) + 1));
drect_border(x, y, x + camera->cursor_size[0], y + camera->cursor_size[1], C_NONE, 1, C_BLACK);
}

View File

@ -17,7 +17,7 @@ void display_large_map(struct calccity *calccity, struct camera *camera, struct
void display_mini_map(struct camera *camera, struct map *map);
// display_around : display the screen frame and cursor
void display_around(struct calccity *calccity, struct camera *camera, const int disp_cursor);
void display_around(struct calccity *calccity, struct camera *camera, struct map *map, const int disp_cursor);
// display_message : display the given message with lines breaks
void display_message(char* message);

View File

@ -8,20 +8,31 @@ int main(void)
{
extern font_t font_calccity;
dfont(&font_calccity);
title_screen();
// Game initialisation
struct calccity calccity;
struct camera camera;
struct map map;
gint_world_switch(GINT_CALL(read_save, (void *)&calccity, (void *)&camera, (void *)&map));
struct calccity *calccity;
calccity = (struct calccity*) malloc(sizeof *calccity);
// Game
main_loop(&calccity, &camera, &map);
struct camera *camera;
camera = (struct camera*) malloc(sizeof *camera);
struct map *map;
map = (struct map*) malloc(sizeof *map);
// Loading save
gint_world_switch(GINT_CALL(read_save, (void *)calccity, (void *)camera, (void *)map));
// Launch the game
main_loop(calccity, camera, map);
// Backup data
gint_world_switch(GINT_CALL(write_save, (void *)&calccity, (void *)&camera, (void *)&map));
gint_world_switch(GINT_CALL(write_save, (void *)calccity, (void *)camera, (void *)map));
// Free memory
free(calccity);
free(camera);
free(map);
return 1;
}

View File

@ -9,7 +9,7 @@ uint16_t const *filename_u16 = u"\\\\fls0\\CalcCity.sav";
void read_save(struct calccity *calccity, struct camera *camera, struct map *map)
{
if(gint[HWCALC] == HWCALC_G35PE2)
if (gint[HWCALC] == HWCALC_G35PE2)
{
FILE *fp;
fp = fopen(filename_u8, "rb");
@ -29,7 +29,7 @@ void read_save(struct calccity *calccity, struct camera *camera, struct map *map
else
{
int fd = BFile_Open(filename_u16, BFile_ReadOnly);
if(fd < 0)
if (fd < 0)
default_values(calccity, camera, map);
else
{
@ -44,7 +44,7 @@ void read_save(struct calccity *calccity, struct camera *camera, struct map *map
void write_save(const struct calccity *calccity, const struct camera *camera, const struct map *map)
{
if(gint[HWCALC] == HWCALC_G35PE2)
if (gint[HWCALC] == HWCALC_G35PE2)
{
FILE *fp;
fp = fopen(filename_u8, "wb");