diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/assets.odin | 4 | ||||
| -rw-r--r-- | src/bullet.odin | 6 | ||||
| -rw-r--r-- | src/constants.odin | 21 | ||||
| -rw-r--r-- | src/main.odin | 4 | ||||
| -rw-r--r-- | src/player.odin | 32 | ||||
| -rw-r--r-- | src/sprite.odin | 7 | ||||
| -rw-r--r-- | src/upgrade_pickup.odin | 8 |
7 files changed, 45 insertions, 37 deletions
diff --git a/src/assets.odin b/src/assets.odin index 35536f1..592937b 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}, "jump_down"={from = 17, to = 18}, "jump_trans"={from = 16, to = 16}, "sleep"={from = 19, to = 22}, "run"={from = 6, to = 13}, "idle"={from = 0, to = 5}}}, + .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 = { @@ -57,7 +57,7 @@ rooms: [Room_Id]Room_Resource = { .Carrabassett1 = {width=20, height=20, tile_width=16, tile_height=16, layers={{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 31, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 31, 31, 17, 0, 0, 0, 16, 19, 28, 40, 40, 40, 40, 40, 40, 40, 27, 31, 31, 17, 0, 0, 0, 0, 0, 0, 0, 0, 16, 28, 40, 40, 40, 40, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 28, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 28, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 38, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 40, 43, 9, 9, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 18, 20, 20, 40, 40, 40, 40, 40, 43, 9, 9, 9, 9, 9, 9, 18, 9, 18, 18, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={{type = .Upgrade, pos = {160, 240}, size = {0, 0}, parallax = {0, 0}, properties = {"image"="res/img/dash_pickup.qoi", "type"=0}}, }, background_image=nil}, .Carrabassett2 = {width=20, height=20, tile_width=16, tile_height=16, layers={{40, 40, 40, 8, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 10, 31, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 20, 42, 0, 0, 0, 10, 19, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 27, 31, 19, 28, 38, 18, 6, 0, 0, 0, 0, 10, 19, 28, 40, 40, 40, 40, 40, 27, 17, 0, 0, 10, 28, 40, 38, 20, 42, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 17, 0, 0, 0, 0, 16, 19, 31, 19, 17, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 39, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 18, 9, 9, 39, 40, 40, 40, 40, 40, 40, 20, 9, 18, 9, 9, 9, 20, 20, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={}, background_image=nil}, .Carrabassett3 = {width=20, height=40, tile_width=16, tile_height=16, layers={{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 19, 31, 19, 19, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 19, 31, 17, 0, 0, 0, 0, 0, 16, 19, 28, 40, 40, 40, 40, 40, 40, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 19, 28, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 20, 9, 39, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 18, 9, 18, 39, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 41, 20, 20, 18, 18, 39, 40, 40, 40, 40, 40, 21, 28, 40, 40, 32, 0, 0, 0, 0, 10, 31, 31, 19, 19, 28, 40, 40, 40, 40, 27, 17, 7, 40, 40, 43, 42, 0, 0, 0, 0, 0, 0, 0, 0, 10, 19, 19, 19, 31, 17, 0, 7, 40, 40, 40, 38, 18, 18, 20, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 38, 20, 20, 18, 6, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 6, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 43, 6, 0, 0, 0, 0, 0, 7, 40, 40, 21, 28, 40, 21, 31, 28, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 7, 40, 40, 32, 16, 19, 17, 0, 16, 19, 19, 31, 28, 40, 38, 9, 20, 6, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 16, 19, 31, 19, 19, 17, 0, 0, 7, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 20, 18, 9, 9, 18, 20, 39, 40, 40, 43, 6, 0, 0, 0, 0, 0, 41, 20, 20, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 42, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 20, 20, 42, 0, 10, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 19, 19, 28, 40, 8, 0, 0, 0, 10, 31, 19, 31, 28, 40, 40, 40, 40, 40, 40, 32, 0, 0, 10, 19, 17, 0, 0, 0, 0, 0, 0, 0, 16, 31, 31, 31, 19, 31, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 38, 9, 9, 9, 20, 20, 18, 18, 9, 9, 42, 0, 0, 0, 0, 0, 0, 0, 0, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 5, 20, 20, 9, 9, 18, 40, 40, 40, 21, 31, 31, 19, 31, 31, 19, 19, 17, 0, 5, 39, 40, 40, 40, 40, 40, 40, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 28, 40, 40, 40, 40, 40, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 41, 20, 18, 20, 39, 40, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 6, 0, 0, 0, 0, 41, 9, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 43, 6, 0, 0, 41, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={}, background_image=nil}, - .Carrabassett4 = {width=20, height=20, tile_width=16, tile_height=16, layers={{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 19, 19, 17, 0, 10, 31, 19, 31, 28, 40, 40, 40, 40, 40, 40, 40, 21, 31, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 19, 31, 19, 28, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 5, 18, 9, 20, 9, 20, 20, 9, 9, 39, 40, 40, 18, 9, 20, 18, 20, 9, 9, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={{type = .Upgrade, pos = {160, 241}, size = {0, 0}, parallax = {0, 0}, properties = {"image"="res/img/double_jump_pickup.qoi", "type"=1}}, }, background_image=nil}, + .Carrabassett4 = {width=20, height=20, tile_width=16, tile_height=16, layers={{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 19, 19, 17, 0, 10, 31, 19, 31, 28, 40, 40, 40, 40, 40, 40, 40, 21, 31, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 19, 31, 19, 28, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 5, 18, 9, 20, 9, 20, 20, 9, 9, 39, 40, 40, 18, 9, 20, 18, 20, 9, 9, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={{type = .Upgrade, pos = {160, 241}, size = {0, 0}, parallax = {0, 0}, properties = {"type"=1, "image"="res/img/double_jump_pickup.qoi"}}, }, background_image=nil}, } tilesets: [Tileset_Id]Tileset_Resource = { diff --git a/src/bullet.odin b/src/bullet.odin index f2e2e47..da6af73 100644 --- a/src/bullet.odin +++ b/src/bullet.odin @@ -25,12 +25,8 @@ make_bullet :: proc( ) -> (Entity_Handle, ^Bullet) { sprite: Sprite init_sprite(&sprite, image_id) + set_sprite_offset_percentage(&sprite, {0, 0.5}) - sprite.offset = { - 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 sprite.pos = pos diff --git a/src/constants.odin b/src/constants.odin index d415c3e..2875f4c 100644 --- a/src/constants.odin +++ b/src/constants.odin @@ -2,3 +2,24 @@ package demonchime GRAVITY :: 1000 TERMINAL_VELOCITY :: 900 + +CAMERA_ACCEL :: 15 + +PLAYER_SPEED :: 100 +PLAYER_ACCEL :: 30 +PLAYER_JUMP_FORCE :: 350 +PLAYER_DOUBLE_JUMP_FORCE :: 250 + +PLAYER_JUMP_BUFFERING :: 0.07 +PLAYER_COYOTE_TIME :: 0.06 +PLAYER_JUMP_RELEASE_CUT :: -100 + +PLAYER_DASH_SPEED :: 500 +PLAYER_DASH_TIME :: 0.15 +PLAYER_DASH_COOLDOWN :: 0.3 + +PLAYER_GUN_HEIGHT :: 0 +PLAYER_GUN_DIST :: 7 // how far out to hold the gun +PLAYER_GUN_KICKBACK :: 4 // how far to move the gun back when you shoot + +PLAYER_SCARF_DIST :: 5 diff --git a/src/main.odin b/src/main.odin index d141014..6e299c8 100644 --- a/src/main.odin +++ b/src/main.odin @@ -74,10 +74,10 @@ frame :: proc() { cb(dt) } - state.camera.target = linalg.lerp( + state.camera.target = dt_lerp( state.camera.target, state.camera_target, - 10 * dt, + CAMERA_ACCEL, ) draw_new_frame() diff --git a/src/player.odin b/src/player.odin index 9cec035..c87d2a6 100644 --- a/src/player.odin +++ b/src/player.odin @@ -8,24 +8,6 @@ import rl "vendor:raylib" import "phys" -PLAYER_SPEED :: 100 -PLAYER_ACCEL :: 10 -PLAYER_JUMP_FORCE :: 350 -PLAYER_DOUBLE_JUMP_FORCE :: 250 -PLAYER_JUMP_BUFFERING :: 0.07 -PLAYER_COYOTE_TIME :: 0.06 -PLAYER_JUMP_RELEASE_CUT :: -100 - -PLAYER_DASH_SPEED :: 500 -PLAYER_DASH_TIME :: 0.15 -PLAYER_DASH_COOLDOWN :: 0.3 - -PLAYER_GUN_HEIGHT :: 0 -PLAYER_GUN_DIST :: 7 // how far out to hold the gun -PLAYER_GUN_KICKBACK :: 4 // how far to move the gun back when you shoot - -PLAYER_SCARF_DIST :: 5 - Player_State :: enum { Default, Dash, @@ -61,23 +43,19 @@ init_player :: proc() { player.body = body init_sprite(&player.sprite, .Player) - - player.sprite.offset = Vec2 { - math.floor(f32(player.sprite.width / 2)), - math.floor(f32(player.sprite.height / 2)), - } + set_sprite_offset_percentage(&player.sprite, {0.5, 0.5}) init_sprite(&player.gun.sprite, .Pistol) player.gun.sprite.offset = Vec2 { -PLAYER_GUN_DIST, - math.round(f32(player.gun.sprite.height / 2)), + math.round(f32(player.gun.sprite.height) * 0.5), } player.scarf = { point_max_dist = 2, point_rad = 2, - color_start = [4]f32{0.18, 0.13, 0.18, 1} * 0.5, + color_start = Color {0.18, 0.13, 0.18, 1} * 0.5, color_end = {0.18, 0.13, 0.18, 1}, } } @@ -184,10 +162,10 @@ _default_state :: proc(dt: f32) { vel.y = PLAYER_JUMP_RELEASE_CUT } - vel.x = math.lerp( + vel.x = dt_lerp( vel.x, input * PLAYER_SPEED, - math.pow(0.5, dt * PLAYER_ACCEL), + PLAYER_ACCEL, ) vel.y = math.min(vel.y + GRAVITY * dt, TERMINAL_VELOCITY) diff --git a/src/sprite.odin b/src/sprite.odin index ab7df6e..09b68ae 100644 --- a/src/sprite.odin +++ b/src/sprite.odin @@ -1,6 +1,7 @@ package demonchime import "core:log" +import "core:math/linalg" import rl "vendor:raylib" @@ -48,6 +49,12 @@ set_sprite_active_tag :: proc(sprite: ^Sprite, tag_name: string) { sprite.current_tag = anim.tags[tag_name] } +set_sprite_offset_percentage :: proc(sprite: ^Sprite, offset: Vec2) { + sprite.offset = linalg.round( + Vec2{f32(sprite.width), f32(sprite.height)} * offset, + ) +} + update_sprite :: proc(sprite: ^Sprite, dt: f32) { sprite.just_finished_loop = false diff --git a/src/upgrade_pickup.odin b/src/upgrade_pickup.odin index b491bd5..30b262c 100644 --- a/src/upgrade_pickup.odin +++ b/src/upgrade_pickup.odin @@ -32,7 +32,13 @@ draw_upgrade :: proc() { return } - draw_texture(get_image(upgrade.image_id), upgrade.pos) + tex := get_image(upgrade.image_id) + + draw_texture( + tex, + upgrade.pos, + offset = linalg.round(Vec2{f32(tex.width), f32(tex.height)} * 0.5) + ) } object_spawner_upgrade :: proc(obj: Object_Resource) { |
