aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoriamcheeseman <[hidden email]>2026-01-15 16:17:16 -0500
committeriamcheeseman <[hidden email]>2026-01-15 16:17:16 -0500
commit86738d3406671046ce50a2d1b07d858e14b2f968 (patch)
tree3261e9fb85d7a438a6d5e37df447e209e3b26532 /src
parent4563dfa077e029fbefd192f087338d186155ebfc (diff)
Ensure upwards and downwards transitions work
Diffstat (limited to 'src')
-rw-r--r--src/assets.odin28
-rw-r--r--src/draw.odin4
-rw-r--r--src/input.odin1
-rw-r--r--src/main.odin65
-rw-r--r--src/player.odin68
-rw-r--r--src/resources.odin4
-rw-r--r--src/world.odin14
7 files changed, 141 insertions, 43 deletions
diff --git a/src/assets.odin b/src/assets.odin
index 0b6fcc9..24170ba 100644
--- a/src/assets.odin
+++ b/src/assets.odin
@@ -19,9 +19,10 @@ Animation_Id :: enum {
}
Room_Id :: enum {
- ROOM_BEGIN,
- ROOM_BEGIN_1,
- ROOM_BEGIN_SECRET_1,
+ CARRABASSETT0,
+ CARRABASSETT1,
+ CARRABASSETT2,
+ CARRABASSETT3,
}
Tileset_Id :: enum {
@@ -53,9 +54,10 @@ animations: [Animation_Id]Animation_Resource = {
}
rooms: [Room_Id]Room_Resource = {
- .ROOM_BEGIN = {width=30, 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, 27, 31, 31, 19, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 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, 9, 20, 9, 44, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 9, 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, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 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 = .PLAYER_SPAWN, pos = {240, 200}, size = {0, 0}, parallax = {0, 0}, properties = {}}, {type = .COLLISION, pos = {0, 0}, size = {48, 48}, parallax = {0, 0}, properties = {}}, }, background_image=nil},
- .ROOM_BEGIN_1 = {width=30, 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, 27, 19, 31, 31, 19, 19, 31, 19, 19, 19, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 19, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 31, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 19, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 31, 28, 40, 40, 40, 40, 40, 40, 27, 31, 31, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 18, 20, 20, 20, 20, 18, 9, 18, 9, 40, 38, 9, 18, 42, 0, 0, 0, 0, 0, 0, 0, 41, 9, 18, 18, 9, 18, 18, 20, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 43, 20, 9, 18, 9, 18, 20, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={}, background_image=nil},
- .ROOM_BEGIN_SECRET_1 = {width=30, 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, 27, 31, 31, 19, 31, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 17, 0, 0, 0, 0, 0, 10, 19, 19, 31, 19, 31, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 9, 18, 9, 18, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 9, 18, 9, 9, 9, 20, 20, 9, 18, 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, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 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},
+ .CARRABASSETT0 = {width=40, 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, 27, 31, 31, 19, 19, 28, 40, 40, 40, 40, 40, 40, 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, 11, 0, 0, 0, 0, 16, 19, 31, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 31, 19, 31, 19, 19, 19, 31, 19, 31, 19, 19, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 31, 31, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 21, 19, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 31, 31, 31, 19, 19, 31, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 18, 9, 9, 20, 9, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 5, 9, 20, 9, 20, 20, 20, 18, 20, 20, 18, 18, 9, 18, 9, 20, 20, 9, 9, 18, 6, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 11, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 43, 9, 9, 20, 20, 9, 39, 40, 40, 40, 40, 40, 40, 0, 0, 0, 5, 9, 20, 9, 44, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 9, 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, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 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 = .PLAYER_SPAWN, pos = {240, 184}, size = {0, 0}, parallax = {0, 0}, properties = {}}, {type = .COLLISION, pos = {0, 0}, size = {48, 48}, parallax = {0, 0}, properties = {}}, }, background_image=nil},
+ .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={}, 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, 5, 18, 9, 9, 20, 18, 9, 9, 18, 20, 39, 40, 40, 32, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 10, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 10, 31, 19, 31, 28, 40, 40, 40, 40, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 31, 31, 31, 28, 40, 40, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 38, 9, 9, 9, 20, 20, 18, 18, 9, 9, 42, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 5, 20, 20, 9, 39, 40, 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},
}
tilesets: [Tileset_Id]Tileset_Resource = {
@@ -154,15 +156,17 @@ tiles: []Tile_Resource = {
}
world: []Room_Position_Resource = {
- {id=.ROOM_BEGIN, x=307, y=292, width=480, height=320},
- {id=.ROOM_BEGIN_1, x=-173, y=292, width=480, height=320},
- {id=.ROOM_BEGIN_SECRET_1, x=787, y=292, width=480, height=320},
+ {id=.CARRABASSETT0, x=307, y=292, width=640, height=320},
+ {id=.CARRABASSETT1, x=-13, y=292, width=320, height=320},
+ {id=.CARRABASSETT2, x=947, y=292, width=320, height=320},
+ {id=.CARRABASSETT3, x=947, y=-348, width=320, height=640},
}
path_to_id: map[string]Resource_Id = {
- "res/rooms/room_begin_secret_1.tmj" = Room_Id.ROOM_BEGIN_SECRET_1,
- "res/rooms/room_begin.tmj" = Room_Id.ROOM_BEGIN,
- "res/rooms/room_begin_1.tmj" = Room_Id.ROOM_BEGIN_1,
+ "res/rooms/carrabassett2.tmj" = Room_Id.CARRABASSETT2,
+ "res/rooms/carrabassett0.tmj" = Room_Id.CARRABASSETT0,
+ "res/rooms/carrabassett1.tmj" = Room_Id.CARRABASSETT1,
+ "res/rooms/carrabassett3.tmj" = Room_Id.CARRABASSETT3,
"res/img/player.ase" = Image_Id.PLAYER,
"res/img/bullet.qoi" = Image_Id.BULLET,
"res/img/pistol.qoi" = Image_Id.PISTOL,
diff --git a/src/draw.odin b/src/draw.odin
index e51e0ae..8e31b96 100644
--- a/src/draw.odin
+++ b/src/draw.odin
@@ -7,7 +7,7 @@ import rl "vendor:raylib"
Color :: [4]f32
-SCREEN_WIDTH :: 480
+SCREEN_WIDTH :: 320
SCREEN_HEIGHT :: 320
SCREEN_SIZE :: Vec2{SCREEN_WIDTH, SCREEN_HEIGHT}
@@ -37,7 +37,7 @@ deinit_draw :: proc() {
draw_new_frame :: proc() {
rl.BeginTextureMode(renderer.screen)
- rl.ClearBackground(_color_to_rl(Color{0.2, 0.2, 0.2, 1}))
+ rl.ClearBackground(rl.BLACK)
}
draw_end_frame :: proc() {
diff --git a/src/input.odin b/src/input.odin
index 1513c33..7ba2884 100644
--- a/src/input.odin
+++ b/src/input.odin
@@ -59,5 +59,6 @@ get_mouse_pos :: proc() -> (mouse_pos: Vec2) {
mouse_pos = Vec2{f32(rl.GetMouseX()), f32(rl.GetMouseY())}
mouse_pos /= Vec2{f32(rl.GetScreenWidth()), f32(rl.GetScreenHeight())}
mouse_pos *= SCREEN_SIZE
+ mouse_pos += state.camera.target
return
}
diff --git a/src/main.odin b/src/main.odin
index 969c25b..0775449 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -7,7 +7,7 @@ import "core:c/libc"
import "core:fmt"
import "core:log"
import "core:mem"
-import os "core:os/os2"
+import "core:math/linalg"
import rl "vendor:raylib"
@@ -22,6 +22,7 @@ Rect :: struct {
state: struct {
debug_mode: bool,
+ camera_target: Vec2,
camera: rl.Camera2D,
platform_list: Entity_List(Platform),
bullet_list: Entity_List(Bullet),
@@ -51,18 +52,13 @@ raylib_log :: proc "c" (
}
}
-die :: proc(msg: string, args: ..any, #any_int exit_code := 1) {
- log.fatalf(msg, args)
- os.exit(exit_code)
-}
-
init :: proc() {
state.camera.zoom = 1
init_keybinds()
init_draw()
init_player()
- open_room(.ROOM_BEGIN)
+ open_room(.CARRABASSETT0)
}
frame :: proc() {
@@ -70,25 +66,74 @@ frame :: proc() {
state.debug_mode = !state.debug_mode
}
- update_player(rl.GetFrameTime())
- update_bullets(rl.GetFrameTime())
+ dt := rl.GetFrameTime()
+
+ update_player(dt)
+ update_bullets(dt)
+
+ state.camera.target = linalg.lerp(
+ state.camera.target,
+ state.camera_target,
+ 10 * dt,
+ )
draw_new_frame()
rl.BeginMode2D(state.camera)
+ renderer.tint = {0.2, 0.2, 0.2, 1}
+ draw_rect({
+ {0, 0},
+ {f32(current_room.width), f32(current_room.height)},
+ })
+ renderer.tint = {1, 1, 1, 1}
+
draw_player()
draw_room(current_room.id)
draw_bullets()
+ rl.DrawRectangleGradientH(
+ 0,
+ 0,
+ 8,
+ current_room.height,
+ rl.BLACK,
+ rl.BLANK,
+ )
+ rl.DrawRectangleGradientH(
+ current_room.width - 8,
+ 0,
+ 8,
+ current_room.height,
+ rl.BLANK,
+ rl.BLACK,
+ )
+ rl.DrawRectangleGradientV(
+ 0,
+ 0,
+ current_room.width,
+ 8,
+ rl.BLACK,
+ rl.BLANK,
+ )
+ rl.DrawRectangleGradientV(
+ 0,
+ current_room.height - 8,
+ current_room.width,
+ 8,
+ rl.BLANK,
+ rl.BLACK,
+ )
+
if state.debug_mode {
// Draw all collisions
body_it: int
- renderer.tint = {1, 0.25, 0.5, 0.5}
+ renderer.tint = {1, 0.25, 0.5, 0.25}
for body in phys.iterate_bodies(&body_it) {
rect := phys.get_rect(body)
rect.start += phys.get_position(body)
draw_linerect(transmute(Rect)rect)
+ draw_rect(transmute(Rect)rect)
}
renderer.tint = {1, 1, 1, 1}
}
diff --git a/src/player.odin b/src/player.odin
index 497407c..2029195 100644
--- a/src/player.odin
+++ b/src/player.odin
@@ -20,7 +20,7 @@ PLAYER_DASH_SPEED :: 500
PLAYER_DASH_TIME :: 0.15
PLAYER_DASH_COOLDOWN :: 0.3
-PLAYER_GUN_HEIGHT :: 7
+PLAYER_GUN_HEIGHT :: 0
PLAYER_GUN_DIST :: 5 // how far out to hold the gun
Player_State :: enum {
@@ -44,7 +44,7 @@ player: struct {
init_player :: proc() {
body := phys.make_body(
- phys.Rect{{-4, -16}, {8, 16}},
+ phys.Rect{{-4, -8}, {8, 16}},
layers = {.PLAYER},
mask = {.DEFAULT}
)
@@ -54,7 +54,7 @@ init_player :: proc() {
player.sprite.offset = Vec2 {
math.floor(f32(player.sprite.width / 2)),
- f32(player.sprite.height),
+ math.floor(f32(player.sprite.height / 2)),
}
init_sprite(&player.gun_sprite, .PISTOL)
@@ -71,6 +71,10 @@ deinit_player :: proc() {
@(private = "file")
_get_input_dir :: proc() -> f32 {
+ if !point_inside_room(phys.get_position(player.body)) {
+ return 0
+ }
+
input: f32
if is_keybind_down(actions.move_left) {
@@ -187,7 +191,6 @@ _dash_state :: proc(dt: f32) {
phys.update_body(player.body)
player.dash_timer -= dt
- // body := phys.get_body(player.body_handle)
if player.dash_timer <= 0 || phys.get_collisions(player.body) != {} {
_exit_dash()
@@ -205,26 +208,53 @@ _exit_dash :: proc() {
}
@(private = "file")
-_change_rooms :: proc() {
- width := f32(current_room.width)
- height := f32(current_room.height)
+_get_camera_target_pos :: proc() -> Vec2 {
+ pos := phys.get_position(player.body) - SCREEN_SIZE * 0.5
+ room_size := Vec2{
+ f32(current_room.width),
+ f32(current_room.height),
+ }
+
+ camera_bounds_min := Vec2{0, 0}
+ camera_bounds_max := room_size - SCREEN_SIZE
+
+ pos.x = math.clamp(pos.x, camera_bounds_min.x, camera_bounds_max.x)
+ pos.y = math.clamp(pos.y, camera_bounds_min.y, camera_bounds_max.y)
+
+ return pos
+}
+@(private = "file")
+_change_rooms :: proc() {
pos := phys.get_position(player.body)
- if pos.x < 0 ||
- pos.x > width ||
- pos.y < 0 ||
- pos.y > height {
- prev_room_pos := Vec2{f32(current_room.x), f32(current_room.y)}
- changed := open_room_at({i32(pos.x), i32(pos.y)})
+ if point_inside_room(pos) {
+ return
+ }
+
+ prev_room_pos := Vec2{f32(current_room.x), f32(current_room.y)}
+ changed := open_room_at({i32(pos.x), i32(pos.y)})
- if changed {
- new_room_pos := Vec2{f32(current_room.x), f32(current_room.y)}
+ if changed {
+ new_room_pos := Vec2{f32(current_room.x), f32(current_room.y)}
- diff := prev_room_pos - new_room_pos
- new_pos := pos + diff - {0, 0}
- phys.set_position(player.body, new_pos)
+ diff := prev_room_pos - new_room_pos
+ new_pos := pos + diff
+ phys.set_position(player.body, new_pos)
+
+ if diff.y > 0 {
+ vel := phys.get_velocity(player.body)
+ vel.y = -PLAYER_JUMP_FORCE
+ phys.set_velocity(player.body, vel.y)
+ } else if diff.y > 0 {
+ vel := phys.get_velocity(player.body)
+ vel.y = 0
+ phys.set_velocity(player.body, vel.y)
}
+
+ new_cam_pos := _get_camera_target_pos()
+ state.camera.target += diff
+ state.camera_target += diff
}
}
@@ -253,6 +283,8 @@ update_player :: proc(dt: f32) {
player.jump_buffer -= dt
player.coyote_time -= dt
+ state.camera_target = _get_camera_target_pos()
+
_change_rooms()
}
diff --git a/src/resources.odin b/src/resources.odin
index 0a4f843..537c265 100644
--- a/src/resources.odin
+++ b/src/resources.odin
@@ -1,5 +1,7 @@
package demonchime
+import "core:log"
+
import rl "vendor:raylib"
Image_Resource :: struct {
@@ -67,7 +69,7 @@ get_image :: proc(id: Image_Id) -> rl.Texture2D {
i32(len(img_res.data)),
)
if !rl.IsImageValid(rl_img) {
- die("Could not load asset %v", id)
+ log.warnf("Could not load asset %v", id)
}
img_res.texture = rl.LoadTextureFromImage(rl_img)
diff --git a/src/world.odin b/src/world.odin
index d6f611e..eca934c 100644
--- a/src/world.odin
+++ b/src/world.odin
@@ -1,5 +1,7 @@
package demonchime
+import "core:log"
+
import rl "vendor:raylib"
Object_Spawner :: proc(Object_Resource)
@@ -40,6 +42,8 @@ _open_room :: proc(room_pos: Room_Position_Resource) {
current_room = room_pos
+ log.infof("Opened room %v", current_room.id)
+
for cb in room_open_cb {
cb(current_room.id)
}
@@ -47,6 +51,16 @@ _open_room :: proc(room_pos: Room_Position_Resource) {
_spawn_objects(current_room.id)
}
+point_inside_room :: proc(pos: Vec2) -> bool {
+ width := f32(current_room.width)
+ height := f32(current_room.height)
+
+ return pos.x >= 0 &&
+ pos.x <= width &&
+ pos.y >= 0 &&
+ pos.y <= height
+}
+
open_room_at :: proc(pos: [2]i32) -> bool {
pos := pos
pos += {current_room.x, current_room.y}