From 23d391a1a2c203938c8f240e714851cde1b4ac3a Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Mon, 28 Aug 2023 19:27:06 -0700 Subject: [PATCH] More todo, room transition functionality. BUG: animations are frozen for some reason --- main.c | 74 +++++++++++++++++++++++++++++++++++++++++--------------- todo.txt | 18 ++++++++++---- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/main.c b/main.c index 4e09cca..8b38c34 100644 --- a/main.c +++ b/main.c @@ -2009,7 +2009,7 @@ Entity *new_entity(GameState *gs) } } assert(false); - return NULL; + return 0; } typedef struct ToVisit { @@ -2143,25 +2143,24 @@ Vec2 point_plane(Vec3 p) #define parse_enumstr(arena, enum_str, errors, string_array, enum_kind_name, prefix) parse_enumstr_impl(arena, enum_str, string_array, ARRLEN(string_array), errors, enum_kind_name, prefix) -void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *level) +ThreeDeeLevel level_threedee = {0}; + +void transition_to_room(GameState *gs, ThreeDeeLevel *level, MD_String8 new_room_name) { - memset(gs, 0, sizeof(GameState)); - rnd_gamerand_seed(&gs->random, RANDOM_SEED); + Log("Transitioning to %.*s...\n", MD_S8VArg(new_room_name)); + assert(gs); - // the target room will be whichever room has the player - for(Room *cur_room = level->room_list; cur_room; cur_room = cur_room->next) + bool already_player_in_gamestate = gs->player != 0; + Entity player_entity = {0}; + if(already_player_in_gamestate) { - for(PlacedEntity *cur = cur_room->placed_entity_list; cur; cur = cur->next) - { - if(cur->npc_kind == NPC_Player) - { - gs->current_room_name = cur_room->name; - break; - } - } - if(gs->current_room_name.size > 0) break; + player_entity = *(gs->player); } + gs->current_room_name = new_room_name; + + memset(gs->entities, 0, sizeof(gs->entities)); + Room *in_room = get_cur_room(gs, level); bool found_player = false; for(PlacedEntity *cur = in_room->placed_entity_list; cur; cur = cur->next) @@ -2176,12 +2175,20 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve gs->player = cur_entity; } } - assert(found_player); + if(already_player_in_gamestate) + { + assert(!found_player); + gs->player = new_entity(gs); + *(gs->player) = player_entity; + } + else + { + assert(found_player); + } gs->world_entity = new_entity(gs); gs->world_entity->is_world = true; - ENTITIES_ITER(gs->entities) { it->rotation = PI32; @@ -2378,9 +2385,36 @@ void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *leve it->perceptions_dirty = false; // nobody should say anything about jester memories } } + + +} + + +void initialize_gamestate_from_threedee_level(GameState *gs, ThreeDeeLevel *level) +{ + memset(gs, 0, sizeof(GameState)); + rnd_gamerand_seed(&gs->random, RANDOM_SEED); + + // the target room will be whichever room has the player + MD_String8 target_room_name = {0}; + for(Room *cur_room = level->room_list; cur_room; cur_room = cur_room->next) + { + for(PlacedEntity *cur = cur_room->placed_entity_list; cur; cur = cur->next) + { + if(cur->npc_kind == NPC_Player) + { + target_room_name = cur_room->name; + break; + } + } + if(target_room_name.size > 0) break; + } + assert(target_room_name.size > 0); + + transition_to_room(gs, &level_threedee, target_room_name); + } -ThreeDeeLevel level_threedee = {0}; void reset_level() { @@ -3380,7 +3414,7 @@ void init(void) shifted_farmer_armature = load_armature(persistent_arena, binary_file, MD_S8Lit("Farmer.bin")); shifted_farmer_armature.image = image_shifted_farmer; - Log("Done.\n"); + Log("Done. Used %f of the frame arena, %llu kB\n", (double) frame_arena->pos / (double)frame_arena->cap, (frame_arena->pos/1024)); MD_ArenaClear(frame_arena); @@ -6096,7 +6130,7 @@ void frame(void) draw_centered_text((TextParams){false, mission_text, V2(screen_size().x * 0.5f, screen_size().y * 0.25f + vert), blendalpha(WHITE, visible), mission_font_scale, .use_font = &font_for_text_input, .layer = LAYER_ANGEL_SCREEN}); if(imbutton(aabb_centered(V2(screen_size().x/2.0f, screen_size().y*0.25f - vert), MulV2F(V2(170.0f, button_height), visible)), visible, MD_S8Lit("Accept"), .layer = LAYER_ANGEL_SCREEN, .font = &font_for_text_input)) { - Log("Accepting mission...\n"); + transition_to_room(&gs, &level_threedee, MD_S8Lit("Forest")); } } else diff --git a/todo.txt b/todo.txt index e390bb5..27bdd90 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,17 @@ Urgent: -- White sidebars on angel's speech that recede away. -- Mystical particles that float upwards. -- Gradient png on the bottom that has more alpha, controlled by same parameter as white sidebars. -- Fix everything about the shotgun, put shotgun away. Make them understand they're holding their shotgun more. REALLY look into characters not being able to shoot eachother -- On startup if devtools print the estimated cost per generation request of the worst offending character +- Remove (MD_) prefix from project +- Fix camera angle on forest map, probably introduce custom camera angles per map +- In debugtools show number of arenas allocated, and total megabytes allocated in arenas + +- Angel dialog improvements: + - White sidebars on angel's speech that recede away. + - Mystical particles that float upwards. + - Gradient png on the bottom that has more alpha, controlled by same parameter as white sidebars. + +- Fix everything about the shotgun, test put shotgun away. Make them understand they're holding their shotgun more. REALLY look into characters not being able to shoot eachother +- Cost estimation: + - On startup if devtools print the estimated cost per generation request of the worst offending character + - Show in upper right a $ amount for AI costs so far to user - simple room transition system for angel/real map interop, angel room - angel character that gives you randomized goals such as (kill so and so) or (befriend blank) or (get john to go to other room), and decides itself with gpt when you're done with the game, when you've 'learned your lesson'. - can't interact with characters while they're thinking