From 1f76fef313773585124c774711ba802934a898e1 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Fri, 31 Mar 2023 20:45:51 -0700 Subject: [PATCH] New art in and "shadow rendering" --- .gitignore | 1 + assets.mdesk | 12 ++++++ assets/new_level.json | 4 +- main.c | 93 +++++++++++++++++++++++++++++-------------- makeprompt.h | 4 ++ run_codegen.bat | 6 ++- todo.txt | 6 +-- 7 files changed, 90 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 5859cfb..5605354 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ build_web_release/ build_web/ # copyrighted assets which must be bought +rpgpt_private_assets/ assets/copyrighted/ ForgottenMemories/ ForgottenMemories.zip diff --git a/assets.mdesk b/assets.mdesk index 787bb5f..d2a8e3c 100644 --- a/assets.mdesk +++ b/assets.mdesk @@ -22,6 +22,18 @@ { filepath: "_Roll.png", } +@image new_knight_idle: +{ + filepath: "copyrighted/knight_idle.png", +} +@image new_knight_run: +{ + filepath: "copyrighted/knight_run_start.png", +} +@image new_knight_attack: +{ + filepath: "copyrighted/knight_attack.png", +} @image death: { filepath: "copyrighted/wraith.png", diff --git a/assets/new_level.json b/assets/new_level.json index e25bb55..50417ed 100644 --- a/assets/new_level.json +++ b/assets/new_level.json @@ -359,8 +359,8 @@ "rotation":0, "visible":true, "width":32, - "x":518, - "y":579 + "x":529.333333333333, + "y":566.333333333333 }, { "class":"", diff --git a/main.c b/main.c index f9b6dea..de4fad7 100644 --- a/main.c +++ b/main.c @@ -692,26 +692,24 @@ void end_text_input(char *what_player_said) } } - - AnimatedSprite knight_idle = { - .img = &image_knight_idle, - .time_per_frame = 0.3, - .num_frames = 10, - .start = {16.0f, 0.0f}, - .horizontal_diff_btwn_frames = 120.0, - .region_size = {80.0f, 80.0f}, + .img = &image_new_knight_idle, + .time_per_frame = 0.4, + .num_frames = 6, + .start = {0.0f, 0.0f}, + .horizontal_diff_btwn_frames = 64.0, + .region_size = {64.0f, 64.0f}, }; AnimatedSprite knight_running = { - .img = &image_knight_run, - .time_per_frame = 0.06, - .num_frames = 10, - .start = {19.0f, 0.0f}, - .horizontal_diff_btwn_frames = 120.0, - .region_size = {80.0f, 80.0f}, + .img = &image_new_knight_run, + .time_per_frame = 0.1, + .num_frames = 7, + .start = {64.0f*10, 0.0f}, + .horizontal_diff_btwn_frames = 64.0, + .region_size = {64.0f, 64.0f}, }; AnimatedSprite knight_rolling = @@ -728,12 +726,12 @@ AnimatedSprite knight_rolling = AnimatedSprite knight_attack = { - .img = &image_knight_attack, + .img = &image_new_knight_attack, .time_per_frame = 0.06, - .num_frames = 4, - .start = {37.0f, 0.0f}, - .horizontal_diff_btwn_frames = 120.0, - .region_size = {80.0f, 80.0f}, + .num_frames = 7, + .start = {0.0f, 0.0f}, + .horizontal_diff_btwn_frames = 64.0, + .region_size = {64.0f, 64.0f}, .no_wrap = true, }; @@ -1755,6 +1753,25 @@ float y_coord_sorting_at(Vec2 pos) return 1.0f - y_coord_sorting; } +void draw_shadow_for(DrawParams d) +{ + Quad sheared_quad = d.quad; + float height = d.quad.ur.y - d.quad.lr.y; + Vec2 shear_addition = V2(-height*0.35f, -height*0.2f); + sheared_quad.ul = AddV2(sheared_quad.ul, shear_addition); + sheared_quad.ur = AddV2(sheared_quad.ur, shear_addition); + d.quad = sheared_quad; + d.tint = (Color){0,0,0,0.2f}; + d.y_coord_sorting -= 0.05f; + d.alpha_clip_threshold = 0.0f; + d.queue_for_translucent = true; + dbgline(sheared_quad.ul, sheared_quad.ur); + dbgline(sheared_quad.ur, sheared_quad.lr); + dbgline(sheared_quad.lr, sheared_quad.ll); + dbgline(sheared_quad.ll, sheared_quad.ul); + draw_quad(d); +} + void draw_animated_sprite(AnimatedSprite *s, double elapsed_time, bool flipped, Vec2 pos, Color tint) { float y_sort_pos = y_coord_sorting_at(pos); @@ -1785,7 +1802,9 @@ void draw_animated_sprite(AnimatedSprite *s, double elapsed_time, bool flipped, } region.lower_right = AddV2(region.upper_left, s->region_size); - draw_quad((DrawParams){true, q, spritesheet_img, region, tint, .y_coord_sorting = y_sort_pos, .alpha_clip_threshold = 0.2f}); + DrawParams d = (DrawParams){true, q, spritesheet_img, region, tint, .y_coord_sorting = y_sort_pos, .alpha_clip_threshold = 0.2f}; + draw_shadow_for(d); + draw_quad(d); } // gets aabbs overlapping the input aabb, including gs.entities and tiles @@ -2579,7 +2598,8 @@ void frame(void) { if(it->held_by_player) { - it->pos = AddV2(player->pos, V2(5.0f * (player->facing_left ? -1.0f : 1.0f), 0.0f)); + Vec2 held_spot = V2(15.0f * (player->facing_left ? -1.0f : 1.0f), 7.0f); + it->pos = AddV2(player->pos, held_spot); } else { @@ -2633,6 +2653,10 @@ void frame(void) *it = (Entity){0}; it->generation = gen; } + if(it->perceptions_dirty && !npc_does_dialog(it)) + { + it->perceptions_dirty = false; + } if(it->perceptions_dirty) { PromptBuff prompt = {0}; @@ -2931,7 +2955,8 @@ void frame(void) #endif // draw drop shadow - if(it->is_character || it->is_npc || it->is_prop) + //if(it->is_character || it->is_npc || it->is_prop) + if(false) { //if(it->npc_kind != DEATH) { @@ -3003,7 +3028,9 @@ void frame(void) else if(it->npc_kind == NPC_GodRock) { Vec2 prop_size = V2(46.0f, 40.0f); - draw_quad((DrawParams){true, quad_centered(AddV2(it->pos, V2(-0.0f, 0.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(15.0f, 219.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.7f}); + DrawParams d = (DrawParams){true, quad_centered(AddV2(it->pos, V2(-0.0f, 0.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(15.0f, 219.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.7f}; + draw_shadow_for(d); + draw_quad(d); } else if(npc_is_knight_sprite(it)) { @@ -3066,22 +3093,28 @@ void frame(void) } else if(it->is_prop) { + DrawParams d = {0}; if(it->prop_kind == TREE0) { - Vec2 prop_size = V2(74.0f, 137.0f); - draw_quad((DrawParams){true, quad_centered(AddV2(it->pos, V2(-5.0f, 45.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(2.0f, 4.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.7f}); + Vec2 prop_size = V2(74.0f, 122.0f); + d = (DrawParams){true, quad_centered(AddV2(it->pos, V2(-5.0f, 45.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(2.0f, 4.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.7f}; } - - if(it->prop_kind == TREE1) + else if(it->prop_kind == TREE1) { Vec2 prop_size = V2(102.0f, 145.0f); - draw_quad((DrawParams){true, quad_centered(AddV2(it->pos, V2(-4.0f, 55.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(5.0f, 684.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.4f}); + d = ((DrawParams){true, quad_centered(AddV2(it->pos, V2(-4.0f, 55.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(5.0f, 684.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.4f}); } - if(it->prop_kind == TREE2) + else if(it->prop_kind == TREE2) { Vec2 prop_size = V2(128.0f, 192.0f); - draw_quad((DrawParams){true, quad_centered(AddV2(it->pos, V2(-2.5f, 70.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(385.0f, 479.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.4f}); + d = ((DrawParams){true, quad_centered(AddV2(it->pos, V2(-2.5f, 70.0)), prop_size), image_props_atlas, aabb_at_yplusdown(V2(385.0f, 479.0f), prop_size), WHITE, .y_coord_sorting = y_coord_sorting_at(AddV2(it->pos, V2(0.0f, 20.0f))), .alpha_clip_threshold = 0.4f}); + } + else + { + assert(false); } + draw_shadow_for(d); + draw_quad(d); } else { diff --git a/makeprompt.h b/makeprompt.h index db0ba90..9ecc784 100644 --- a/makeprompt.h +++ b/makeprompt.h @@ -255,6 +255,10 @@ int action_to_index(Entity *it, Action a) return index; } +bool npc_does_dialog(Entity *it) +{ + return it->npc_kind < ARRLEN(prompt_table); +} void generate_prompt(Entity *it, PromptBuff *into) { diff --git a/run_codegen.bat b/run_codegen.bat index 166e761..d41d229 100644 --- a/run_codegen.bat +++ b/run_codegen.bat @@ -3,6 +3,7 @@ echo Asset packs which must be bought and unzipped into root directory before running this script: echo https://rafaelmatos.itch.io/epic-rpg-world-pack-ancient-ruins echo https://sventhole.itch.io/undead-pixel-art-characters +echo You must also get access to the rpgpt_private_assets megasync folder from creikey, and put it in this repo under that exact filename. Contact him for access rmdir /S /q assets\copyrighted @@ -17,10 +18,13 @@ copy "EPIC RPG World Pack - Ancient Ruins V 1.7\EPIC RPG World Pack - Ancient Ru copy "EPIC RPG World Pack - Ancient Ruins V 1.7\EPIC RPG World Pack - Ancient Ruins V 1.7\Characters\Moose\moose1-all animations-347x192.png" "assets\copyrighted\moose.png" || goto :error copy "Undead - Pixel Art Characters\Undead - Pixel Art Characters\Sprites\Wraith_Red.png" "assets\copyrighted\wraith.png" || goto :error copy "Undead - Pixel Art Characters\Undead - Pixel Art Characters\Sprites\Skeleton_Blue.png" "assets\copyrighted\skeleton.png" || goto :error -copy "ForgottenMemories\Props.png" "assets\copyrighted\Props.png" || goto :error +copy "rpgpt_private_assets\props_modified.png" "assets\copyrighted\Props.png" || goto :error copy "ForgottenMemories\TileSet.png" "assets\copyrighted\TileSet.png" || goto :error copy "ForgottenMemories\Trees.png" "assets\copyrighted\Trees.png" || goto :error copy "ForgottenMemories\WaterTiles-6frames.png" "assets\copyrighted\WaterTiles-6frames.png" || goto :error +copy "rpgpt_private_assets\knight_idle.png" "assets\copyrighted\knight_idle.png" || goto :error +copy "rpgpt_private_assets\knight_attack.png" "assets\copyrighted\knight_attack.png" || goto :error +copy "rpgpt_private_assets\knight_run_start.png" "assets\copyrighted\knight_run_start.png" || goto :error rmdir /S /q gen mkdir gen diff --git a/todo.txt b/todo.txt index 026f4b0..c686bad 100644 --- a/todo.txt +++ b/todo.txt @@ -3,10 +3,10 @@ DONE - Payment working DONE - Fixed timesep the gameplay (which means separate player rendering) DONE - Maybe factor actions! into the game to replace ** stuff. In beginning of each line before quotes, have ACT@fights_player, or other actions, and by default ACT@nothing to force AI to say something about what action is performed DONE - Help you fight and fight you actions - - Handle wanting another request, dirty perception, when already waiting on a request - - Do not use webhooks (shitty, bad idea propagated by bad docs) query stripe for if the payment went through on request if not fulfilled yet + DONE- Handle wanting another request, dirty perception, when already waiting on a request +DONE - Do not use webhooks (shitty, bad idea propagated by bad docs) query stripe for if the payment went through on request if not fulfilled yet - New characters/items from fate - - New art in +DONE - New art in - Old man in beginning is invincible - Make new openai key (it was leaked) - Add cancel button