diff --git a/code/foundation/src/world/world.c b/code/foundation/src/world/world.c index 5ca0ee1..b18afbe 100644 --- a/code/foundation/src/world/world.c +++ b/code/foundation/src/world/world.c @@ -48,7 +48,7 @@ entity_view* world_build_entity_view(int64_t e) { view.vx = vel->x; view.vy = vel->y; } - + const Rotation* rot = ecs_get(world_ecs(), e, Rotation); if (rot) { view.angle = rot->angle; diff --git a/code/games/survival/src/renderer.c b/code/games/survival/src/renderer.c index b6340ba..74c4355 100644 --- a/code/games/survival/src/renderer.c +++ b/code/games/survival/src/renderer.c @@ -61,7 +61,7 @@ void renderer_draw_entry(uint64_t key, entity_view *data, game_world_render_entr case EKIND_WEAPON: { float x = data->x; float y = data->y; - DrawSpriteEco(&main_sprite_sheet, data->frame, x, y, 0.0f, 2.0f, WHITE); + DrawSpriteEco(&main_sprite_sheet, data->frame, x, y, data->angle, 2.0f, WHITE); } break; case EKIND_DEVICE:{ float x = data->x - 32.f; diff --git a/code/games/survival/src/system_weapon.c b/code/games/survival/src/system_weapon.c index 0779290..2c6b816 100644 --- a/code/games/survival/src/system_weapon.c +++ b/code/games/survival/src/system_weapon.c @@ -28,6 +28,10 @@ void WeaponKnifeMechanic(ecs_iter_t *it) { .origin_x=pos[i].x, .origin_y=pos[i].y }); + + ecs_set(it->world, e, Rotation, { + .angle=zpl_to_degrees(zpl_arctan2(input[i].hx, input[i].hy)) + }); ecs_set(it->world, e, Velocity, { .x=input[i].hx*WEAPON_PROJECTILE_SPEED,