#ifndef GAME_GAME_H #define GAME_GAME_H /* Top-level game state: world, player, camera and time of day. */ #include #include "core/input.h" #include "world/daycycle.h" #include "world/meadow.h" #include "people/talk.h" #include "world/world.h" #include "render/camera.h" #include "render/renderer.h" /* The start: arriving by car (see game_arrival.c). */ #define ARRIVAL_POINTS 12 #define ARRIVAL_SAMPLES 160 typedef enum { ARRIVAL_NONE, ARRIVAL_DRIVING, ARRIVAL_PARKED, ARRIVAL_DONE } ArrivalStage; typedef enum { TASK_NONE, TASK_HELLO, TASK_CHAT, TASK_UNLOAD } ArrivalTask; typedef struct { ArrivalStage stage; struct Object *car; Vec3 path[ARRIVAL_SAMPLES]; /* the way in, sampled ... */ float dist[ARRIVAL_SAMPLES]; /* ... how far along each sample is */ float length, s, speed, time, park_yaw; int step; /* ... who's out of the car */ bool greeted; ArrivalTask task; /* what to do now: hello, a chat, then the car and the tents */ int chat; /* the chat with Kurti: lines said so far ... */ float chat_wait; /* ... since the hello */ int welcome; /* Kurti and his sons welcoming you at the fire: lines said so far ... */ float welcome_t; /* ... until the next */ int guide; /* Kurti showing you all where to camp: 0 not yet, 1 on the way and telling, 2 shown ... */ int guide_line; /* ... his lines said so far ... */ float guide_t; /* ... since the last (or waiting for the others) */ } Arrival; /* A shopping run (game_shop.c): over to the car, out along the way in, away, back, parked, the boot open. */ typedef enum { ERRAND_NONE, ERRAND_TO_CAR, ERRAND_LEAVING, ERRAND_AWAY, ERRAND_BACK } ErrandStage; typedef struct { ErrandStage stage; struct Object *driver; int list[SHOP_ITEMS]; /* what to get (talk.h SHOP_*) */ float time; /* in this stage (s; away: game s) */ float s, speed; /* where on the way in (m), how fast */ } Errand; /* A meeting in Berlin (game_meeting.c): Grossbeerenstrasse at the start, the Herberge before every weekend. */ typedef enum { MEET_NONE, MEET_KREUZBERG, MEET_HERBERGE, MEET_END } MeetingKind; /* (the end: back in Grossbeerenstrasse) */ typedef struct { MeetingKind kind; int number; /* the Herberge: which (1: before the first weekend - who leads what) */ int step; /* the agenda so far */ float wait; /* until the next line */ int asking; /* a question waiting for your answer (Q_*: game_meeting.c), 0 none ... */ int n_options; /* ... the answers */ char option_text[TALK_CHOICES][72]; int option_value[TALK_CHOICES]; int asked_floor; /* (who leads which floor: the floor asked about ... */ int asked_mask; /* ... the floors asked about this time) */ struct Object *speaker; /* who spoke last (everybody looks at them) */ float fade; /* 0..1 how dark (going there, coming back) ... */ int fading; /* ... +1 getting dark, -1 light again */ int after; /* what happens once it's dark (AFTER_*: game_meeting.c) */ bool skipping; /* Backspace: the rest of it at once, the first answers */ bool ended; /* the end: all said (the game is over: you can still walk about) */ } Meeting; /* The ambulance (game_injury.c): called, on its way in, parked (the paramedics), on its way out. */ typedef enum { AMB_NONE, AMB_CALLED, AMB_IN, AMB_PARKED, AMB_OUT } AmbulanceStage; typedef struct { int stage; struct Object *car; /* (while it's here) */ struct Object *who; /* who it's for */ float t; /* game s since called; real s parked */ float s; /* m along the way in */ } Ambulance; /* The festival weekend (game_festival.c): the last weekend on the ground, the guests, the storm. */ typedef struct { int stage; /* FEST_* (world.h) */ int came; /* guests come so far */ int caught; /* the storm at its worst: out in it ... */ int inside; /* ... and safe inside ... */ bool counted; /* ... counted */ unsigned played; /* bit k: floor k played at all */ int review; /* Sunday at the fire: lines said so far ... */ float review_t; /* ... till the next */ int result; /* how good it was, 0..100 (-1: not over yet) */ int helped; /* the awareness team saw to people (kept here: the world's counter is set every frame) */ int harassed; /* somebody bothered (harassment) ... */ int stepped; /* ... and somebody stepped in */ /* the clean-up and the drive home (game_cleanup.c) */ int clean; /* CLEAN_*: not yet, the supporters' Sunday shift, Monday's clean-up, Kurti's look, to the car, driving, home */ int litter_start; /* the guests' litter lying about when Monday's clean-up started ... */ int litter_left; /* ... and now (counted every few seconds) */ int helpers; /* the crew still happy to help on Monday ... */ int left_early; /* ... and the ones who went home instead */ int supported; /* supporters who did their Sunday shift ... */ int supported2; /* ... and Monday's */ int verdict; /* Kurti on how you leave his land: 0 clean, 1 a bit left, 2 a mess (-1 not yet) */ float clean_t; /* real s: till the next count; in the car: the drive's clock */ float drive_s, drive_speed; /* the drive home: m along the way in (backwards), how fast */ } Festival; typedef struct { World world; Object *player; Camera camera; DayCycle daycycle; bool third_person; /* camera behind the player (V) ... */ float camera_reach; /* ... this far from the head (pulled in by walls) */ float dark; /* 0..1, fades in while the player sleeps */ bool show_keys; /* key list on screen (I) */ bool fast_sleep; /* time runs fast while asleep (hold Space) */ const char *message; /* shown for a moment (e.g. "too heavy") */ float message_time; bool holding; /* holding on to something heavy after a click (no need to keep F down) */ int click_action; /* what the held left button keeps doing (see game.c) */ float bag_timer; /* until the next piece goes into the bag (button held) */ char info[128]; /* short line about the object last used */ const struct Object *info_about; Talk talk; /* conversation with someone */ bool shouting; /* the shout menu is open (X with nobody in front) */ struct Object *shout_to[3]; /* ... the people it offers to call (nearest first) */ int shout_count; struct Object *shout_dog; char shout_lines[4][48]; float sniff_time; /* until the next remark about a smell */ bool show_stats; /* the stats panel (Tab) */ bool worn_out; /* shown "worn out" (until rested a bit: it doesn't flicker on and off) */ bool show_dev; /* dev menu (F1): change anybody's stats ... */ int dev_row, dev_who; /* ... the line picked, whose */ int stats_page; /* ... which page (arrow keys): body, skills */ bool show_pockets; /* your pockets (B) ... */ int pocket_row; /* ... the thing picked */ float fire_nag; /* until the next "you're on fire" reminder */ char hint[192]; /* what to do now (being followed, watched, at the grill, at a ladder) */ Mesh marker; /* where a woodpile would go, shown on the ground */ Meadow meadow; /* grass blades near the eye */ float climb_push; /* seconds walking against a ledge */ float brace_hold; /* hands on an edge you walked up to: kept there this much longer ... */ Vec3 brace_grip; /* ... here */ Object *putting_up; /* the ladder you are putting up (hands on it, standing still) */ Arrival arrival; /* the start: in by car */ float overcast; /* how clouded over the sky is (eases: clouds come before the rain) */ struct Object *tent; /* the tent you're working on (left button held) */ struct Object *stage; /* the floor's stage you're building on (left button held) */ float tent_hold; /* ... held this long at a standing one (a moment: you start taking it down) */ struct Object *tent_drag; /* a tent with no pegs in you're moving (F held) ... */ Vec3 drag_off; /* ... where it is from you (your right, up, ahead) ... */ float drag_turn; /* ... and how it's turned from you */ float dt; /* this frame's step */ bool rain_told; /* told it's raining (this shower) */ bool wet_told; /* "wet through" said (till dry again) */ float blow_told; /* "your tent is blowing about" said: not again for a while */ float story_hours; /* game hours since the start on the ground (the crew turns up by it: game_story.c) */ float story_check; /* until the next look at who's due */ char story_line[192]; /* what was said about it (shown as the message) */ bool show_crew; /* the crew overview (F2, dev) ... */ int crew_page; /* ... which page (Left / Right): who's who, now, the projects */ Errand errand; /* a shopping run */ Mesh quest_mesh; /* the marker over who or what to go to next (Game_questMarker) ... */ float quest_t; /* ... its bob and turn */ float mow_t; /* into this swing of the scythe (mowing: left button held) */ int snail_warned; /* the regulatory office: told of it (1 the day before, 2 on the day) */ Meeting meeting; /* a meeting in Berlin (game_meeting.c) ... */ int weekend; /* ... the weekends on the ground, the first 1 ... */ float weekend_from; /* ... this one's Friday midnight (story hours) ... */ bool weekend_warned; /* ... "we drive back at six" said */ int fest_name; /* the festival's name (chosen in Grossbeerenstrasse: game_meeting.c) */ int focus; /* what this weekend is for (the Herberge): FOCUS_* in world.h */ bool show_notes; /* your notebook (J): the festival, the why questions */ float why_check; /* until the next look round for something that makes you wonder (game_why.c) */ Festival festival; /* the festival weekend (game_festival.c) */ Ambulance ambulance; /* somebody hurt: the ambulance (game_injury.c) ... */ float you_hurt_t; /* ... you hurt: lying there this long */ bool sprain_told; /* ... your twisted ankle said */ bool on_rope; /* you on the big tree's rope (game_bigtree.c) ... */ struct Object *rope_look; /* ... the rope as it's seen (made again when it changes) ... */ int rope_shown; bool wires_shown; /* ... the phone line's wires shown torn */ } Game; /* A line of speech above someone's head, in screen pixels (y up from the bottom). */ typedef struct { char text[AI_SPEECH_MAX + 32]; float x, y; } Bubble; /* Speech bubbles to draw this frame; returns how many. */ int Game_bubbles(const Game *game, Bubble *out, int max, int screen_w, int screen_h); /* Answers the player can give right now (1..5): in a conversation or the shout menu; else 0. */ int Game_choices(const Game *game, const char *out[TALK_CHOICES]); /* Where the marker floats: over who or what to go to next (the start: Kurti, the car, Kurti showing you where to camp, your tent's spot); false: nothing to point at now. */ bool Game_questMarker(const Game *game, Vec3 *at); /* The festival's name (chosen at the first meeting); in Berlin (a meeting, or waiting there between weekends)? */ const char *Game_festivalName(const Game *game); bool Game_inBerlin(const struct Object *o); /* A line about what to do right now (someone follows or watches you), or NULL. */ const char *Game_hint(Game *game); bool Game_init(Game *game); /* The world as at the start; arrive: and the drive in (a fresh game). A save is loaded onto it without. */ bool Game_initWorld(Game *game, bool arrive); void Game_shutdown(Game *game); void Game_update(Game *game, const Input *input, float dt, float aspect); /* One bar in the stats panel: 0..1; for needs more is worse. */ typedef struct { const char *label; float value; bool need; /* true: full is bad (hunger, ...); false: full is good (energy) */ } StatBar; #define STATS_PAGES 2 /* The player's bars on the current stats page, its title, and a line under them ("Sprint 6.6 m/s ..."); returns the bar count. */ int Game_stats(const Game *game, StatBar *bars, int max, const char **title, char *about, size_t size); /* Only what's pressing, as one short line ("parched bursting"), or empty. */ void Game_needsText(const Game *game, char *out, size_t size); /* A short line to show in the middle of the screen (a burp, sleeping), or NULL. */ const char *Game_status(const Game *game); /* Shadow pass and scene pass for all world objects. */ void Game_render(Game *game, Renderer *renderer); /* Rain, smoke, chips: after the sky (they show against it too). */ void Game_renderAir(Game *game, Renderer *renderer); #define POCKET_LINES 12 /* Your pockets as lines of text: a heading, what's in them, what Enter does; *picked: the line picked. */ int Game_pocketLines(Game *game, char lines[][96], int max, int *picked); /* Your notebook (J) as lines of text, its title. Returns how many. */ int Game_notesLines(const Game *game, char lines[][128], int max, const char **title); #define DEV_LINES 13 /* The crew overview (F2) as lines of text, its title. Returns how many. */ int Game_crewLines(const Game *game, char lines[][128], int max, const char **title); /* The dev menu as lines of text; *picked: the line picked. Returns how many. */ int Game_devLines(const Game *game, char lines[][96], int max, int *picked); #endif /* GAME_GAME_H */