diff options
| author | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-11-25 15:20:50 +0100 |
|---|---|---|
| committer | Aldrik Ramaekers <aldrikboy@gmail.com> | 2024-11-25 15:20:50 +0100 |
| commit | eba92835cee8e4c5564ce0e23db15db5b04ad279 (patch) | |
| tree | 51d518cb02de45dfa33a21e196afaaae061baff0 | |
| parent | 82419840618418daa9020029a5347fc0f6e5edc5 (diff) | |
close #5, close #4
| -rw-r--r-- | README.md | 22 | ||||
| -rw-r--r-- | src/include/world.h | 1 | ||||
| -rw-r--r-- | src/scenes/place_detail.c | 5 | ||||
| -rw-r--r-- | src/world.c | 24 |
4 files changed, 43 insertions, 9 deletions
@@ -2,5 +2,23 @@ Truck logistics management game written using C + OpenGL. Uses SDL2 SDL2_Mixer f Video: https://www.youtube.com/watch?v=vd9a-LMGzrs&ab_channel=Aldrik -Heuristics: -location score is based on: schedule efficiency 60%, employee happiness 10%, customer trust 30%
\ No newline at end of file +Introduction: +Manage and expand your trucking company. +players is responsible for: +- accepting jobs +- scheduling jobs +- managing employees +- managing fleet +- expanding company +- expanding to other locations +- scheduling efficiency + +Locations get better jobs based on location score. +location score is based on: +- schedule efficiency 60% +- employee happiness 10% +- customer trust 30% + +Better jobs include: +- longer jobs (by km) +- more deliveries per job (fuller schedule)
\ No newline at end of file diff --git a/src/include/world.h b/src/include/world.h index a719e57..d2e9bfc 100644 --- a/src/include/world.h +++ b/src/include/world.h @@ -124,6 +124,7 @@ typedef struct t_truck_dealer #define JOB_OFFER_REWARD_PER_CONNECTION 160
#define MAX_SHIPDAYS 4
+#define MIN_POSSIBLE_SHIPDAYS 2
typedef struct t_job_offer
{
diff --git a/src/scenes/place_detail.c b/src/scenes/place_detail.c index 4519cfa..b174b5b 100644 --- a/src/scenes/place_detail.c +++ b/src/scenes/place_detail.c @@ -1580,13 +1580,10 @@ static void place_detail_draw_location_stats(platform_window* window) {
font* fnt = fnt_rd20;
float text_pad = scale * 40.0;
-
- //s32 w = (area.w * 0.9 - (offset*2));
-
s32 text_x = area.x + text_pad + (area.w*0.75);
s32 text_y = area.y + text_pad + (area.w*0.05);
- DRAW_STARS(text_x, text_y, "Score: ", 5);
+ DRAW_STARS(text_x, text_y, "Score: ", (int)round(_active_location->score * 5));
}
static void place_detail_draw_title(platform_window* window)
diff --git a/src/world.c b/src/world.c index 3226937..ab90371 100644 --- a/src/world.c +++ b/src/world.c @@ -12,8 +12,9 @@ float dotsize = 5; static s32 get_random_number(s32 min, s32 max)
{
- log_assert(min < max, "Min cannot be larger than max");
+ log_assert(min <= max, "Min cannot be larger than max");
// it is assumed srand has been initialized at world load.
+ if (min == max) return min;
return min + rand() % (max-min);
}
@@ -652,6 +653,21 @@ static void world_find_location_deep(s32 depth, world_location* source, array* b }
}
+static s32 world_get_max_ship_days_for_location(world_location* location)
+{
+ s32 shipdays = (int)round(MAX_SHIPDAYS*location->score);
+ if (shipdays < MIN_POSSIBLE_SHIPDAYS) shipdays = MIN_POSSIBLE_SHIPDAYS;
+ return shipdays;
+}
+
+static s32 world_get_max_depth_for_location(world_location* location)
+{
+ s32 max_depth = 6;
+ s32 location_depth = (int)round(max_depth*location->score);
+ if (location_depth < 1) location_depth = 1;
+ return location_depth;
+}
+
static void world_assign_new_job_offers(world* world)
{
for (s32 i = 0; i < world->locations.length; i++)
@@ -668,7 +684,8 @@ static void world_assign_new_job_offers(world* world) job_offer new_offer = (job_offer){world->next_id++, world->simulation_time+DAYS(10), company, product, 0, {DAY_INVALID,DAY_INVALID,DAY_INVALID,DAY_INVALID}, 0};
new_offer.connections = array_create(sizeof(world_location*));
- s32 amount_of_shipdays = get_random_number(1, MAX_SHIPDAYS+1);
+ s32 max_shipdays = world_get_max_ship_days_for_location(location);
+ s32 amount_of_shipdays = get_random_number(1, max_shipdays+1);
for (s32 s = 0; s < amount_of_shipdays; s++) {
s32 random_day = get_random_number(0, NUM_DAYS);
if (!job_offer_has_ship_day(&new_offer, random_day)) {
@@ -679,7 +696,8 @@ static void world_assign_new_job_offers(world* world) }
}
- s32 amount_of_connections = get_random_number(1, 5) + 1; // +1 because we add original location to connection list.
+ s32 max_depth = world_get_max_depth_for_location(location);
+ s32 amount_of_connections = get_random_number(1, max_depth + 1) + 1; // +1 because we add original location to connection list.
array_push(&new_offer.connections, &location);
world_find_location_deep(amount_of_connections, location, &new_offer.connections);
|
