aboutsummaryrefslogtreecommitdiff
path: root/src/bullet.odin
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-01-16 13:30:02 -0500
committeriamcheeseman <[hidden email]>2026-01-16 13:30:02 -0500
commit9180c51c40084aa30448bc4ffc06385489e7bf45 (patch)
tree6b7c34fd18240151ba74195d20540e55bb89bf68 /src/bullet.odin
parent40491b6f5ce5c66f90539e4d9584a4478381930b (diff)
bullets slow down and squish
Diffstat (limited to 'src/bullet.odin')
-rw-r--r--src/bullet.odin15
1 files changed, 14 insertions, 1 deletions
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)
}
}