Finalizing game mecanics

This commit is contained in:
Shadow15510 2021-11-07 16:44:29 +01:00
parent cdc175020c
commit 755e3a0f22
9 changed files with 411 additions and 229 deletions

View File

@ -24,6 +24,7 @@ set(ASSETS_fx
assets-fx/large_tileset.png
assets-fx/mini_tileset.png
assets-fx/large_water.png
assets-fx/alerts.png
assets-fx/title.png
assets-fx/fn_keys.png
assets-fx/fn_1.png

BIN
assets-fx/alerts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -1,421 +1,430 @@
#include "calccity.h"
const struct building buildings[41] = {
const struct building buildings[42] = {
// Menu 1
{
(unsigned char []){48, 49, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134},
(char []){48, 49, 110, 111, 112, 113, 114, 120, 121, 122, 123, 124, 130, 131, 132, 133, 134, -1},
10, // cost
{1, 1}, //size
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // stat
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, // stat
{0, 0, 0}, // taxes
{0, 0, 0}, // funds
{0, 0, 0, 0}, // funds
"TERRE"
},
{
(unsigned char []){139},
(char []){139, -1},
15,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"EAU"
},
{
(unsigned char []){76},
(char []){76, -1},
15,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, -1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20},
{0, 0, 0},
{0, 0, 0, 0},
"FORET"
},
{
(unsigned char []){66},
(char []){66, -1},
100,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{100, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 10, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"MAISONS TYPE 1"
},
{
(unsigned char []){67},
(char []){67, -1},
150,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{500, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 20, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"MAISONS TYPE 2"
},
{
(unsigned char []){68},
(char []){68, -1},
200,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{1000, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 50, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"MAISONS TYPE 3"
},
{
(unsigned char []){45},
(char []){45, -1},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 500, 0, 0, 4, 0, 0, 500, 0, 0, 0, 0, 0, 0, 0, 50, 0, 0, 0, 0},
{-3, 0, 0},
{0, 0, 0, 0},
"BUREAUX TYPE 1"
},
{
(unsigned char []){46},
(char []){46, -1},
100,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 750, 0, 0, 5, 0, 0, 750, 0, 0, 0, 0, 0, 0, 0, 65, 0, 0, 0, 0},
{-6, 0, 0},
{0, 0, 0, 0},
"BUREAUX TYPE 2"
},
{
(unsigned char []){47},
(char []){47, -1},
150,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 1200, 0, 0, 6, 0, 0, 1200, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0},
{-11, 0, 0},
{0, 0, 0, 0},
"BUREAUX TYPE 3"
},
{
(unsigned char []){54},
(char []){54, -1},
200,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, -10, 0, 0, 100, 0, 0, 10, 0, 10, 0, 100, 100, 0, 0, 0, 30, 0, 100, 0, 0, 0, 0},
{0, -1, 0},
{0, 0, 0, 0},
"USINE TYPE 1"
},
{
(unsigned char []){55},
(char []){55, -1},
300,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, -30, 0, 0, 200, 0, 0, 20, 0, 20, 0, 200, 200, 0, 0, 0, 40, 0, 120, 0, 0, 0, 0},
{0, -2, 0},
{0, 0, 0, 0},
"USINE TYPE 2"
},
{
(unsigned char []){56},
(char []){56, -1},
400,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, -60, 0, 0, 500, 0, 0, 30, 0, 50, 0, 500, 500, 0, 0, 0, 50, 0, 140, 0, 0, 0, 0},
{0, -4, 0},
{0, 0, 0, 0},
"USINE TYPE 3"
},
{
(unsigned char []){9},
(char []){9, -1},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 1000, 50, 0, 0, 1, 0, 100, 0, 10, 0, 0, 0, 0, 100, 0, 10, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"FERME TYPE 1"
},
{
(unsigned char []){19},
(char []){19, -1},
75,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 1500, 100, 0, 0, 1, 0, 200, 0, 20, 0, 0, 0, 0, 100, 0, 15, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"FERME TYPE 2"
},
{
(unsigned char []){44},
(char []){44, -1},
100,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 3000, 150, 0, 0, 1, 0, 300, 0, 30, 0, 0, 0, 0, 200, 0, 30, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"FERME TYPE 3"
},
// Menu 2
{
(unsigned char []){80, 81, 82, 83, 90, 91, 92, 93, 100, 101, 102},
(char []){83, 80, 81, 82, 90, 91, 92, 93, 100, 101, 102, -1},
10,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 50, 0, 0, 0, 10, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"ROUTE"
},
{
(unsigned char []){62, 63, 64, 65},
(char []){62, 63, 64, 65, -1},
500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 50, 1000, 0, 1, 0, 0, 0, 0, 0, 1000, 1000, 0, 20, 0, 30, 0, 0, 0, 0},
{0, 0, -8},
{0, 0, 0, 0},
"PORT"
},
{
(unsigned char []){0, 1, 2, 12},
(char []){0, 1, -1},
3500,
{2, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 150, 5000, 0, 1, 0, 200, 0, 0, 0, 5000, 5000, 0, 40, 0, 30, 0, 0, 0, 0},
{0, 0, -20},
{0, 0, 0, 0},
"AEROPORT"
},
{
(unsigned char []){84, 85, 86, 87, 94, 95, 96, 97, 104, 105, 106},
(char []){87, 84, 85, 86, 94, 95, 96, 97, 104, 105, 106, -1},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 100, 0, 0, 0, 1, 0, 0, 0, 0, 0, 10, 0, 0, 5, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"RAIL"
},
{
(unsigned char []){71},
(char []){71, -1},
500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 10, 0, 0, 3000, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"CENTRALE ELECTRIQUE 1"
},
{
(unsigned char []){72},
(char []){72, -1},
1000,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 5, 0, 0, 0, 5000, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"CENTRALE ELECTRIQUE 2"
},
{
(unsigned char []){50, 51, 60, 61},
(char []){50, 51, 60, 61, -1},
25000,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 30, 1, 0, 0, 0, 0, 100, 1000, 0, 0, 250000, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"CENTALE NUCLEAIRE"
},
{
(unsigned char []){3, 4, 13, 14},
(char []){3, 4, 13, 14, -1},
2500,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 25, 0, 0, 0, 0, 50, 0, 0, 0, 0, 0, 200, 10, 0, 0, 3000, -1000, 0, 100},
{0, 0, 0},
{0, 0, 0, 0},
"INCINERATEUR"
},
{
(unsigned char []){77},
(char []){77, -1},
50,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 50, 0, 10000, 15, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"STATION D'EPURATION"
},
{
(unsigned char []){78},
(char []){78, -1},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 100, 10, 0, 20, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 5, 3, 0, 2, 0, 0, 0, 100},
{0, 0, 0},
{0, 0, 0, 0},
"TERRAIN DE SPORT"
},
{
(unsigned char []){69},
(char []){69, -1},
150,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 100, 5, 0, 20, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 5, 3, 0, 2, 0, 0, 0, 100},
{0, 0, 0},
{0, 0, 0, 0},
"AIRE DE JEUX"
},
{
(unsigned char []){42, 43, 52, 53},
(char []){42, 43, 52, 53, -1},
10000,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 20, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 200, 10, 0, 100, 0, 0, 0, 200},
{0, 0, 0},
{0, 0, 0, 0},
"STADE"
},
{
(unsigned char []){70},
(char []){70, -1},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 50, 0, -1000, 1, 0, 3, 0, 0, 0, 0, 0, 0, 10, 0, 10, 0, 0, 0, 0},
{0, 0, 0},
{25, 0, 0, 0},
"CASERNE DE POLICE"
},
{
(unsigned char []){58},
(char []){58, -1},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 50, 0, 0, -1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0},
{0, 0, 0},
{0, 25, 0, 0},
"CASERNE DE POMPIERS"
},
{
(unsigned char []){59},
(char []){59, -1},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 1000, 0, 0, 50, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 30, 0, 30, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 25},
"HOPITAL"
},
{
(unsigned char []){75},
(char []){75, -1},
2500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 150, 0, 0, 1, 0, -20000, 0, 0, 0, 0, 0, 500, 40, 0, 30, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"CENTRE ECOLOGIQUE"
},
{
(unsigned char []){73},
(char []){73, -1},
250,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 100, 0, 15, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 10, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 5, 0},
"ECOLE TYPE 1"
},
{
(unsigned char []){74},
(char []){74, -1},
500,
{1, 1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 300, 0, 50, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 15, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 10, 0},
"ECOLE TYPE 2"
},
{
(unsigned char []){28, 29, 38, 39},
(char []){28, 29, 38, 39, -1},
2500,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 1500, 0, 100, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 250, 0},
"UNIVERSITE"
},
{
(unsigned char []){10, 11, 20, 21},
(char []){10, 11, 20, 21, -1},
2500,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 25, 0, 0, 50, 0, 0, 0, 0, 0, 0, 0, 100, 10, 0, 10, 0, 0, 1000, 100},
{0, 0, 0},
{0, 0, 0, 0},
"EGLISE ET CIMETIERE"
},
// Others buildings
{
(unsigned char []){5, 6, 15, 56},
(char []){5, 6, 15, 56, -1},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{10000, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 150, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0},
"IMMEUBLE"
},
{
(unsigned char []){7, 8, 17, 18},
(char []){7, 8, 17, 18, -1},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 5000, 0, 0, 30, 0, 0, 10000, 0, 0, 0, 0, 0, 100, 0, 300, 0, 0, 0, 0},
{-25, 0, 0},
{0, 0, 0, 0},
"TOUR DE BUREAUX"
},
{
(unsigned char []){30, 31, 40, 41},
(char []){30, 31, 40, 41, -1},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0},
{0, -200, 0, 0, 5000, 0, 0, 80, 0, 1000, 0, 5000, 5000, 0, 0, 0, 50, 0, 400, 0, 0, 0, 0},
{0, -6, 0},
{0, 0, 0, 0},
"USINE"
},
{
(unsigned char []){26, 27, 36, 37},
(char []){26, 27, 36, 37, -1},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 150, 0, -20000, 1, 0, 3, 0, 0, 0, 0, 0, 0, 20, 0, 110, 0, 0, 0, 0},
{0, 0, 0},
{250, 0, 0, 0},
"CASERNE DE POLICE"
},
{
(unsigned char []){22, 23, 32, 33},
(char []){22, 23, 32, 33, -1},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 0, 150, 0, 0, -50000, 0, 1, 0, 0, 0, 0, 0, 0, 20, 0, 110, 0, 0, 0, 0},
{0, 0, 0},
{0, 250, 0, 0},
"CASERNE DE POMPIERS"
},
{
(unsigned char []){24, 25, 34, 35},
(char []){24, 25, 34, 35, -1},
0,
{2, 2},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0},
{0, 50000, 0, 0, 250, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 100, 0, 0, 0, 0},
{0, 0, 0},
{0, 0, 0, 250},
"HOPITAL"
},
{
(char []){2, 12, -1},
3500,
{1, 2},
{0, 0, 0, 0, 150, 5000, 0, 1, 0, 200, 0, 0, 0, 5000, 5000, 0, 40, 0, 30, 0, 0, 0, 0},
{0, 0, -20},
{0, 0, 0, 0},
"AEROPORT"
},
};

View File

@ -8,45 +8,48 @@ struct calccity
// main statistics
/*
housing,
health,
education,
food,
work,
transport,
0 housing,
1 health,
2 education,
3 food,
4 work,
5 transport,
crime,
firehazard,
nuclearhazard,
pollution,
6 crime,
7 firehazard,
8 nuclearhazard,
9 pollution,
commercial,
industrial,
production,
import,
export,
annual_cost,
10 commercial,
11 industrial,
12 production,
13 import,
14 export,
15 annual_cost,
water_consumption,
power_consumption,
power_supply,
grabage
graves,
16 water_consumption,
17 water_supply,
18 power_consumption,
19 power_supply,
20 grabage,
21 graves,
22 happyness
*/
unsigned long stat[21];
int stat[23];
// some others statistics = {treasure, population, safety, hapyness, birth_rate, death_rate, immigration, emigration, water_supply}
unsigned long misc[9];
// some others statistics = {treasure, population, safety, population in, population out}
int misc[5];
// taxes in percents on {housing, trade, industry, export}
unsigned int taxes[4];
int taxes[4];
// fund in percents on {police, fireman, education, heathcare}
unsigned int funds[4];
int funds[4];
// in-game time
int month, year;
int blinker;
int blinker_water;
int blinker_alert;
int tick;
// in-game options
@ -71,48 +74,24 @@ struct camera
struct map
{
unsigned char data[50][50];
unsigned char id[50][50];
};
struct building
{
unsigned char *id;
long unsigned int cost;
char *id;
int cost;
unsigned char size[2];
/*
housing,
health,
education,
food,
work,
transport,
crime,
firehazard,
nuclearhazard,
pollution,
commercial,
industrial,
production,
import,
export,
annual_cost,
water_consumption,
power_consumption,
power_supply,
grabage
graves,
*/
unsigned int stat[21];
int stat[23];
// commercial, industrial, export
unsigned int taxes[3];
int taxes[3];
// police, firemen, education, heathcare
unsigned int funds[4];
int funds[4];
char *name;
};
@ -120,6 +99,4 @@ struct building
#define ENGINE_TICK 100
extern const struct building buildings[41];
#endif /* _CALCCITY_H */

View File

@ -35,7 +35,6 @@ void default_values(struct calccity *calccity, struct camera *camera, struct map
calccity->month = 1;
calccity->year = 1900;
calccity->blinker = 0;
calccity->disaster = 1;
calccity->animation = 1;
@ -57,13 +56,19 @@ void default_values(struct calccity *calccity, struct camera *camera, struct map
{
// Water
if ((x * y == 0) || (x == 49 || y == 49))
{
map->data[y][x] = 139;
map->id[y][x] = 1;
}
// Ground
else
{
map->data[y][x] = 48 + rand() % 2;
map->id[y][x] = 0;
}
// Shorelines
switch (y)
{
case 1:
@ -125,13 +130,16 @@ int rtc_key(void)
}
void next_step(struct calccity *calccity)
void next_step(struct calccity *calccity, struct map *map)
{
calccity->tick += ENGINE_TICK;
// In-game animation
if (calccity->animation && !(calccity->tick % 1000))
calccity->blinker = (calccity->blinker + 1 ) % 2;
{
calccity->blinker_water = (calccity->blinker_water + 1 ) % 2;
calccity->blinker_alert = (calccity->blinker_alert + 1) % 3;
}
// In-game time
if (!(calccity->tick % calccity->time_speed))
@ -141,6 +149,7 @@ void next_step(struct calccity *calccity)
{
calccity->month = 1;
calccity->year ++;
update_stat(calccity, map);
}
}
}
@ -154,7 +163,7 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
if (t >= 0) timer_start(t);
struct building building = {0};
int end = 0, key = 0, build_mode = 0;
int end = 0, key = 0, build_mode = -1;
while (!end)
{
@ -162,11 +171,11 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
while (!tick) sleep();
tick = 0;
if (!build_mode) next_step(calccity);
if (build_mode < 0) next_step(calccity, map);
dclear(C_WHITE);
display_main(calccity, camera, map, 1);
if (build_mode)
if (build_mode >= 0)
{
dprint_opt(4, 7, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "$%d", building.cost);
dprint_opt(4, 13, C_BLACK, C_WHITE, DTEXT_LEFT, DTEXT_TOP, "%s", building.name);
@ -186,7 +195,7 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
if (key == KEY_F1) building = menu_12(calccity, camera, map, &build_mode, 1);
if (key == KEY_F2) building = menu_12(calccity, camera, map, &build_mode, 2);
if (build_mode)
if (build_mode >= 0)
{
camera->cursor_size[0] = building.size[0] * 15;
camera->cursor_size[1] = building.size[1] * 15;
@ -206,7 +215,7 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
break;
}
if (build_mode)
if (build_mode >= 0)
{
// Build annulation
if (key == KEY_ALPHA)
@ -217,7 +226,7 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
{
unsigned short loc_x = building.size[0] * floor(camera->x + camera->cursor_x / (floor(camera->cursor_size[0] / 8) + 1));
unsigned short loc_y = building.size[1] * floor(camera->y + camera->cursor_y / (floor(camera->cursor_size[1] / 8) + 1));
int index = 0;
unsigned char index = 0;
for (int y = loc_y; y < loc_y + building.size[1]; y ++)
{
for (int x = loc_x; x < loc_x + building.size[0]; x ++)
@ -226,7 +235,9 @@ void main_loop(struct calccity *calccity, struct camera *camera, struct map *map
index ++;
}
}
map->id[loc_y][loc_x] = build_mode;
calccity->misc[0] -= building.cost;
update_stat(calccity, map);
}
}
@ -307,7 +318,7 @@ bool can_build(struct calccity *calccity, struct camera *camera, struct map *map
}
// Build on another building
if (map->data[y][x] != 48 && map->data[y][x] != 49 && map->data[y][x] < 110)
if (map->data[y][x] != 48 && map->data[y][x] != 49 && map->data[y][x] < 110 && building->id[0] != 48)
{
display_message("VOUS NE POUVEZ PAS CONSTRUIRE SUR BATIMENT EXISTANT.");
return false;
@ -322,7 +333,162 @@ bool can_build(struct calccity *calccity, struct camera *camera, struct map *map
void exit_build_mode(struct camera *camera, int *build_mode)
{
*build_mode = 0;
*build_mode = -1;
camera->cursor_size[0] = 8;
camera->cursor_size[1] = 8;
}
/*struct building get_building(const int id)
{
extern const struct building buildings[42];
for (int i = 0; i < 42; i ++)
{
for (int j = 0; buildings[i].id[j] != -1; j ++)
{
if (buildings[i].id[j] == id)
return buildings[i];
}
}
struct building building = {0};
return building;
}*/
void update_stat(struct calccity *calccity, struct map *map)
{
extern const struct building buildings[42];
// Reset stat
for (int i = 0; i < 23; i ++)
calccity->stat[i] = 0;
// Buildings stats
for (int y = 0; y < 50; y ++)
{
for (int x = 0; x < 50; x ++)
{
if (map->id[y][x] > 1)
{
struct building building = buildings[map->id[y][x]];
for (int i = 0; i < 23; i ++)
{
switch (i)
{
// TAXES : commercial & work
case 4: case 10:
calccity->stat[i] += building.stat[i] + building.taxes[0] * calccity->taxes[1];
break;
// TAXES : industrial & production
case 11: case 12:
calccity->stat[i] += building.stat[i] + building.taxes[1] * calccity->taxes[2];
break;
// TAXES : import & export
case 13: case 14:
calccity->stat[i] += building.stat[i] + building.taxes[2] * calccity->taxes[3];
break;
// FUNDS : health
case 1:
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));
break;
// FUNDS : firehazard
case 7:
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));
break;
// special calculation of the annual cost
case 15:
for (int j = 0; j < 4; j ++)
{
if (building.funds[j])
calccity->stat[i] += building.funds[j] * calccity->funds[j];
}
calccity->stat[i] += building.stat[i];
break;
default:
calccity->stat[i] += building.stat[i];
break;
}
}
}
}
}
calccity->stat[17] -= calccity->stat[16];
if (calccity->stat[17] < 0) calccity->stat[17] = 0;
calccity->stat[19] -= calccity->stat[18];
if (calccity->stat[19] < 0) calccity->stat[19] = 0;
// Others stats
calccity->stat[0] -= floor(calccity->misc[1] / 2);
calccity->stat[1] -= floor(calccity->misc[1] / 10);
calccity->stat[2] -= floor(0.3 * (calccity->misc[1] + calccity->stat[14]) - 0.7 * calccity->stat[13]);
calccity->stat[3] -= floor(calccity->misc[1] / 10);
calccity->stat[4] -= floor(calccity->misc[1] / 2);
calccity->stat[5] -= floor(calccity->misc[1] / 2);
calccity->stat[6] += floor(calccity->misc[1] / 10);
calccity->stat[7] += floor(calccity->misc[1] / 2);
calccity->stat[9] += floor(calccity->misc[1] / 2);
calccity->stat[20] += floor(calccity->misc[1] / 1000);
calccity->stat[21] -= floor(calccity->misc[1] / 1000);
// Happyness
calccity->stat[22] = floor((calccity->misc[1] + calccity->stat[22] + calccity->stat[0] + calccity->stat[1] + calccity->stat[2] + calccity->stat[3] - calccity->stat[6] - calccity->stat[7] - calccity->stat[9] - 10 * calccity->taxes[0]) / calccity->misc[1]);
// Population out
if (calccity->stat[17] < 0 || calccity->stat[19] < 0 || calccity->stat[3] < 0) calccity->misc[4] += 20;
if ((calccity->stat[20] > 0 || calccity->stat[1] < 0) && calccity->misc[1] > 30000) calccity->misc[4] += 13;
for (int i = 0; i < 6; i ++)
if (calccity->stat[i] <= 0) calccity->misc[4] += 25;
if (calccity->stat[5] <= -1000) calccity->misc[4] += 30;
if (calccity->stat[6] > 1000) calccity->misc[4] += 30;
if (calccity->stat[7] > 1000) calccity->misc[4] += 30;
if (calccity->stat[9] > 1000) calccity->misc[4] += 4;
if (calccity->stat[22] < 0) calccity->misc[4] += 4;
if (calccity->misc[1] > 100 && calccity->taxes[0] > 10) calccity->misc[4] += 5;
if (calccity->misc[1] > 100 && calccity->taxes[0] > 30) calccity->misc[4] += 10;
if (calccity->misc[1] > 500 && calccity->taxes[0] > 50) calccity->misc[4] += 50;
if (calccity->misc[1] > 1000 && calccity->taxes[0] > 70) calccity->misc[4] += 100;
// Population in
if (calccity->stat[17] > 0 && calccity->stat[19] > 0)
{
for (int i = 0; i < 6; i ++)
if (calccity->stat[i] > 0) calccity->misc[3] += 10;
if (calccity->stat[6] < 0) calccity->misc[3] += 10;
if (calccity->stat[7] < 0) calccity->misc[3] += 10;
if (calccity->stat[9] < 0) calccity->misc[3] += 10;
if (calccity->stat[12] > 0) calccity->misc[3] += 10;
if (calccity->taxes[0] <= 10) calccity->misc[3] += 5;
}
calccity->misc[1] = calccity->misc[1] + calccity->misc[3] - calccity->misc[4];
if (calccity->misc[1] < 0) calccity->misc[1] = 0;
}

View File

@ -15,7 +15,7 @@ void default_values(struct calccity *current_game, struct camera *camera, struct
int rtc_key(void);
// next_step : compute in-game time
void next_step(struct calccity *calccity);
void next_step(struct calccity *calccity, struct map *map);
// main_loop : game main loop, manage key, menu, map actualization and building
void main_loop(struct calccity *calccity, struct camera *camera, struct map *map);
@ -29,4 +29,7 @@ bool can_build(struct calccity *calccity, struct camera *camera, struct map *map
// exit_build_mode : reset build mode and cusor
void exit_build_mode(struct camera *camera, int *build_mode);
// update_stat : compute the new stat with buildings
void update_stat(struct calccity *calccity, struct map *map);
#endif /* _CORE_H */

View File

@ -36,6 +36,7 @@ void display_large_map(struct calccity *calccity, struct camera *camera, struct
{
extern const bopti_image_t img_large_tileset;
extern const bopti_image_t img_large_water;
extern const bopti_image_t img_alerts;
for (int y = 0; y < 4; y++)
{
@ -45,7 +46,7 @@ void display_large_map(struct calccity *calccity, struct camera *camera, struct
// Water
if (cam_y > 49 || cam_x > 49 || map->data[cam_y][cam_x] == 139)
dsubimage(3 + x * 15, y * 15, &img_large_water, 15 * calccity->blinker, 0, 15 * (calccity->blinker + 1), 15, DIMAGE_NONE);
dsubimage(3 + x * 15, y * 15, &img_large_water, 15 * calccity->blinker_water, 0, 15 * (calccity->blinker_water + 1), 15, DIMAGE_NONE);
else
{
unsigned tile_id = map->data[cam_y][cam_x];
@ -53,10 +54,25 @@ void display_large_map(struct calccity *calccity, struct camera *camera, struct
unsigned int tile_y = 15 * (tile_id / 10);
dsubimage(3 + x * 15, y * 15, &img_large_tileset, tile_x, tile_y, 15, 15, DIMAGE_NONE);
// Visual alerts in case of low energy and low water
if (calccity->animation && map->id[cam_y][cam_x] > 2 && map->data[cam_y][cam_x] < 79)
{
// Low water
if (calccity->stat[17] - calccity->stat[16] < 0 && calccity->blinker_alert == 0)
dsubimage(3 + x * 15, y * 15, &img_alerts, 15, 0, 15, 15, DIMAGE_NONE);
// Low energy
if (calccity->stat[19] - calccity->stat[18] < 0 && calccity->blinker_alert == 1)
dsubimage(3 + x * 15, y * 15, &img_alerts, 0, 0, 15, 15, DIMAGE_NONE);
}
}
}
}
unsigned short loc_x = floor(camera->x + camera->cursor_x / (floor(camera->cursor_size[0] / 8) + 1));
unsigned short loc_y = floor(camera->y + camera->cursor_y / (floor(camera->cursor_size[1] / 8) + 1));
dprint_opt(3, 7, C_BLACK, C_WHITE, 0, 0, "%d", map->id[loc_y][loc_x]);
}

View File

@ -9,7 +9,7 @@ struct building menu_12(struct calccity *calccity, struct camera *camera, struct
{
extern const bopti_image_t img_fn_1;
extern const bopti_image_t img_fn_2;
extern const struct building buildings[41];
extern const struct building buildings[42];
int key = 0, end = 0, x = 0, y = 0;
@ -64,15 +64,21 @@ struct building menu_12(struct calccity *calccity, struct camera *camera, struct
if (end == 1)
{
*build_mode = 1;
if (menu == 1)
{
*build_mode = x + y * 3;
return buildings[x + y * 3];
}
else
{
*build_mode = 15 + x + y * 4;
return buildings[15 + x + y * 4];
}
}
else
{
*build_mode = 0;
*build_mode = -1;
struct building default_building = {0};
return default_building;
}
@ -149,10 +155,11 @@ void menu_5(struct calccity *calccity)
int opt = GETKEY_DEFAULT & GETKEY_REP_ARROWS;
int timeout = 0;
static const char *names[28] = {
static const char *names[27] = {
"GENERAL",
"ARGENT",
"POPULATION",
"BONHEUR",
"LOGEMENT",
"SANTE",
"EDUCATION",
@ -172,39 +179,42 @@ void menu_5(struct calccity *calccity)
"EXPORT",
"COUT ANNUEL",
"DIVERS",
"CONSO. EAU",
"PRODU. EAU",
"CONSO. ENERGIE",
"PRODU. ENERGIE",
"EAU",
"ENERGIE",
"DECHETS",
"TOMBES"
};
long values[28] = {0};
long values[27] = {0};
int offset = 0;
for (int i = 0; i < 28; i ++)
for (int i = 0; i < 27; i ++)
{
switch (i)
{
case 0: case 9: case 14: case 21:
case 0: case 10: case 15: case 22:
values[i] = 0;
offset ++;
break;
case 1:
values[i] = calccity->misc[0];
case 1: case 2:
values[i] = calccity->misc[i - 1];
offset ++;
break;
case 2:
values[i] = calccity->misc[1];
case 3:
values[i] = calccity->stat[22];
offset ++;
break;
case 23:
values[i] = calccity->misc[8];
offset ++;
values[i] = calccity->stat[17] - calccity->stat[16];
offset --;
break;
case 24:
values[i] = calccity->stat[19] - calccity->stat[18];
offset --;
break;
default:
@ -229,17 +239,17 @@ void menu_5(struct calccity *calccity)
// Scroll bar
dline(5, 6, 5, 63, C_BLACK);
drect(2, scroll + 8, 3, 8 + scroll + 33, C_BLACK);
drect(2, scroll + 8, 3, 8 + scroll + 34, C_BLACK);
for (int i = 0; i < 8; i ++)
{
if (i + scroll == 0 || i + scroll == 9 || i + scroll == 14 || i + scroll == 21)
if (i + scroll == 0 || i + scroll == 10 || i + scroll == 15 || i + scroll == 22)
{
drect(5, 7 * i + 7, 127, 7 * i + 13, C_BLACK);
dtext(12, 7 * i + 8, C_WHITE, names[i + scroll]);
}
else
dprint(7, 7 * i + 8, C_BLACK, "%s %lu", names[i + scroll], values[i + scroll]);
dprint(7, 7 * i + 8, C_BLACK, "%s %d", names[i + scroll], values[i + scroll]);
}
dupdate();
@ -253,7 +263,7 @@ void menu_5(struct calccity *calccity)
break;
case KEY_DOWN:
if (scroll < 20) scroll ++;
if (scroll < 19) scroll ++;
break;
}