aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/assets.odin2
-rw-r--r--src/bullet.odin15
-rw-r--r--src/main.odin2
-rw-r--r--src/player.odin5
4 files changed, 19 insertions, 5 deletions
diff --git a/src/assets.odin b/src/assets.odin
index 89a5032..838bc5d 100644
--- a/src/assets.odin
+++ b/src/assets.odin
@@ -49,7 +49,7 @@ images: [Image_Id]Image_Resource = {
animations: [Animation_Id]Animation_Resource = {
.NONE = {frame_count=1, frame_durations={100}, tags={}},
- .PLAYER = {frame_count = 23, frame_durations = {100, 100, 100, 100, 100, 100, 75, 75, 75, 75, 75, 75, 75, 75, 100, 100, 100, 100, 100, 100, 100, 100, 100}, tags = {"jump_up"={from = 14, to = 15}, "run"={from = 6, to = 13}, "jump_trans"={from = 16, to = 16}, "jump_down"={from = 17, to = 18}, "idle"={from = 0, to = 5}, "sleep"={from = 19, to = 22}}},
+ .PLAYER = {frame_count = 23, frame_durations = {100, 100, 100, 100, 100, 100, 75, 75, 75, 75, 75, 75, 75, 75, 100, 100, 100, 100, 100, 100, 100, 100, 100}, tags = {"idle"={from = 0, to = 5}, "jump_trans"={from = 16, to = 16}, "run"={from = 6, to = 13}, "jump_down"={from = 17, to = 18}, "jump_up"={from = 14, to = 15}, "sleep"={from = 19, to = 22}}},
}
rooms: [Room_Id]Room_Resource = {
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)
}
}
diff --git a/src/main.odin b/src/main.odin
index 05daf35..b257bf7 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -20,7 +20,7 @@ Rect :: struct {
size: Vec2,
}
-ROOM_FADE_SIZE :: 16
+ROOM_FADE_SIZE :: 8
state: struct {
debug_mode: bool,
diff --git a/src/player.odin b/src/player.odin
index 990a7d1..9c824b4 100644
--- a/src/player.odin
+++ b/src/player.odin
@@ -150,8 +150,9 @@ _default_state :: proc(dt: f32) {
bullet_pos += mouse_dir * PLAYER_GUN_DIST
make_bullet(
- bullet_pos,
- mouse_dir * 200,
+ pos = bullet_pos,
+ vel = mouse_dir * 800,
+ lifetime = 0.25,
)
}