diff --git a/main.c b/main.c index 928dd95..03e3c65 100644 --- a/main.c +++ b/main.c @@ -5601,19 +5601,26 @@ void frame(void) if(it->is_npc || it->is_character) { Transform draw_with = entity_transform(it); - bool do_outline = it->is_npc && gete(gs.player->interacting_with) == it; + if(it->npc_kind == NPC_Player) { draw_thing((DrawnThing){.armature = &player_armature, .t = draw_with}); } - else if(it->npc_kind == NPC_Farmer) - { - farmer_armature.go_to_animation = MD_S8Lit("Dance"); - draw_thing((DrawnThing){.armature = &farmer_armature, .t = draw_with, .outline = do_outline}); - } - else + else { - draw_thing((DrawnThing){.mesh = &mesh_player, .t = draw_with, .outline = do_outline}); + assert(it->is_npc); + Armature *to_use = 0; + if(it->npc_kind == NPC_Farmer) + to_use = &farmer_armature; + else + assert(false); + + if(LenV2(it->vel) > 0.5f) + to_use->go_to_animation = MD_S8Lit("Running"); + else + to_use->go_to_animation = MD_S8Lit("Idle"); + + draw_thing((DrawnThing){.armature = to_use, .t = draw_with, .outline = gete(gs.player->interacting_with) == it}); } } } @@ -5957,6 +5964,11 @@ void frame(void) if(LenV2(SubV2(it->pos, last_pos)) > 0.01f) { it->last_moved = NormV2(SubV2(it->pos, last_pos)); + it->vel = MulV2F(it->last_moved, 1.0f / dt); + } + else + { + it->vel = V2(0,0); } } diff --git a/tuning.h b/tuning.h index b304429..3d619eb 100644 --- a/tuning.h +++ b/tuning.h @@ -3,7 +3,7 @@ #define LEVEL_TILES 150 // width and height of level tiles array #define LAYERS 3 #define TILE_SIZE 0.5f // in pixels -#define PLAYER_SPEED 0.2f // in meters per second +#define PLAYER_SPEED 0.15f // in meters per second #define PERCEPTION_HEARING_RAGE (TILE_SIZE*4.0f) #define CHARACTERS_PER_SEC 45.0f #define PROPAGATE_ACTIONS_RADIUS (TILE_SIZE*4.0f)