From 9180c51c40084aa30448bc4ffc06385489e7bf45 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Fri, 16 Jan 2026 13:30:02 -0500 Subject: bullets slow down and squish --- src/bullet.odin | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/bullet.odin') diff --git a/src/bullet.odin b/src/bullet.odin index eb8190b..61b920a 100644 --- a/src/bullet.odin +++ b/src/bullet.odin @@ -1,6 +1,7 @@ package demonchime import "core:math" +import "core:math/linalg" import "core:log" import "phys" @@ -9,7 +10,9 @@ Bullet :: struct { handle: Entity_Handle, body: phys.Body_Handle, sprite: Sprite, + vel: Vec2, lifetime: f32, + lifetime_max: f32, } make_bullet :: proc( @@ -24,7 +27,8 @@ make_bullet :: proc( init_sprite(&sprite, image_id) sprite.offset = { - math.round(f32(sprite.width) * 0.5), + 0, + // math.round(f32(sprite.width) * 0.5), math.round(f32(sprite.height) * 0.5), } sprite.rotation = math.atan2(vel.y, vel.x) * math.DEG_PER_RAD @@ -42,7 +46,9 @@ make_bullet :: proc( return make_entity(&state.bullet_list, Bullet{ body = body, sprite = sprite, + vel = vel, lifetime = lifetime, + lifetime_max = lifetime, }) } @@ -64,7 +70,14 @@ update_bullets :: proc(dt: f32) { continue } + phys.set_velocity( + b.body, + linalg.lerp(b.vel, Vec2{0, 0}, 1 - b.lifetime / b.lifetime_max), + ) + b.sprite.pos = phys.get_position(b.body) + + b.sprite.scale.x = math.max(b.lifetime / b.lifetime_max, 0.1) } } -- cgit v1.3-2-g0d8e