aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/assets.odin80
-rw-r--r--src/main.odin3
-rw-r--r--src/player.odin12
-rw-r--r--src/resources.odin1
-rw-r--r--src/sprite.odin4
-rw-r--r--src/world.odin20
6 files changed, 96 insertions, 24 deletions
diff --git a/src/assets.odin b/src/assets.odin
index f4ffc00..5d78333 100644
--- a/src/assets.odin
+++ b/src/assets.odin
@@ -9,24 +9,29 @@ package demonchime
import rl "vendor:raylib"
Image_Id :: enum {
- PLAYER,
TILESETS,
+ PLAYER,
}
Animation_Id :: enum {
- PLAYER,
NONE,
+ PLAYER,
}
Room_Id :: enum {
- ROOM_BEGIN_1,
ROOM_BEGIN,
+ ROOM_BEGIN_1,
+ ROOM_BEGIN_SECRET_1,
}
Tileset_Id :: enum {
TILESET,
}
+Object_Type :: enum {
+ PLAYER_SPAWN,
+}
+
Resource_Id :: union {
Image_Id,
Animation_Id,
@@ -35,24 +40,23 @@ Resource_Id :: union {
}
images: [Image_Id]Image_Resource = {
- .PLAYER = {data = #load("../.compiled-res/player-sheet.qoi"), anim = .PLAYER},
.TILESETS = {data = #load("../.compiled-res/tilesets.qoi"), anim = .NONE},
+ .PLAYER = {data = #load("../.compiled-res/player-sheet.qoi"), anim = .PLAYER},
}
animations: [Animation_Id]Animation_Resource = {
- .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}}},
.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}}},
}
-//odinfmt: disable
-
rooms: [Room_Id]Room_Resource = {
- .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, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 19, 19, 19, 19, 31, 31, 28, 40, 40, 40, 40, 40, 40, 40, 27, 31, 19, 31, 31, 31, 19, 19, 31, 31, 31, 31, 19, 19, 19, 17, 0, 0, 0, 0, 0, 0, 10, 28, 40, 40, 21, 19, 31, 31, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 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, 7, 40, 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, 7, 40, 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, 7, 40, 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, 7, 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, 7, 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, 7, 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, 7, 40, 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, 7, 40, 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, 7, 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, 7, 40, 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, 16, 27, 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, 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, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 9, 20, 20, 20, 18, 18, 18, 20, 8, 0, 0, 0, 0, 0, 0, 5, 18, 9, 9, 20, 20, 20, 18, 9, 18, 9, 18, 18, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 43, 20, 20, 9, 20, 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}}, objects={}, background_image=nil},
- .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, 31, 31, 11, 0, 0, 0, 0, 7, 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, 7, 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, 16, 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, 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, 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, 41, 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, 7, 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, 7, 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, 7, 32, 0, 0, 0, 0, 0, 0, 5, 9, 20, 9, 20, 20, 20, 18, 20, 20, 18, 18, 9, 18, 9, 18, 6, 0, 0, 0, 0, 0, 7, 32, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 0, 0, 0, 7, 11, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 9, 9, 18, 18, 9, 39, 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, 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={}, background_image=nil},
+ .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, 31, 31, 11, 0, 0, 0, 0, 7, 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, 7, 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, 16, 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, 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, 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, 41, 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, 7, 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, 7, 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, 7, 32, 0, 0, 0, 0, 0, 0, 5, 9, 20, 9, 20, 20, 20, 18, 20, 20, 18, 18, 9, 18, 9, 18, 6, 0, 0, 0, 0, 0, 7, 32, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 0, 0, 0, 7, 11, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 9, 9, 18, 18, 9, 39, 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, 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, 149}, 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, 0, 0, 0, 10, 28, 40, 40, 40, 40, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 28, 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, 7, 40, 40, 40, 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, 16, 28, 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, 7, 40, 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, 7, 40, 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, 7, 40, 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, 7, 40, 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, 7, 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, 7, 40, 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, 16, 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, 40, 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, 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, 27, 19, 31, 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, 31, 17, 0, 0, 0, 0, 16, 31, 31, 19, 31, 28, 40, 40, 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, 10, 19, 28, 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, 18, 18, 20, 18, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 9, 9, 20, 9, 18, 18, 18, 9, 18, 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, 40, 40, 40, 40, 40, 40, 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},
}
tilesets: [Tileset_Id]Tileset_Resource = {
- .TILESET = {tiles={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44}, image=.TILESETS},
+ .TILESET = {tiles={45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88}, image=.TILESETS},
}
tiles: []Tile_Resource = {
@@ -100,20 +104,64 @@ tiles: []Tile_Resource = {
{tileset=.TILESET, rect=Rect{start = {128, 48}, size = {16, 16}}, id=42, collisions={Rect{start = {0, 8}, size = {8, 8}}}},
{tileset=.TILESET, rect=Rect{start = {144, 48}, size = {16, 16}}, id=43, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {0, 0}, size = {8, 8}}}},
{tileset=.TILESET, rect=Rect{start = {160, 48}, size = {16, 16}}, id=44, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {8, 0}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {0, 0}, size = {16, 16}}, id=45, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {16, 0}, size = {16, 16}}, id=46, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {32, 0}, size = {16, 16}}, id=47, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {48, 0}, size = {16, 16}}, id=48, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {64, 0}, size = {16, 16}}, id=49, collisions={Rect{start = {8, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {80, 0}, size = {16, 16}}, id=50, collisions={Rect{start = {0, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {96, 0}, size = {16, 16}}, id=51, collisions={Rect{start = {8, 0}, size = {8, 16}}}},
+ {tileset=.TILESET, rect=Rect{start = {112, 0}, size = {16, 16}}, id=52, collisions={Rect{start = {0, 0}, size = {8, 16}}}},
+ {tileset=.TILESET, rect=Rect{start = {128, 0}, size = {16, 16}}, id=53, collisions={Rect{start = {0, 8}, size = {16, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {144, 0}, size = {16, 16}}, id=54, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {160, 0}, size = {16, 16}}, id=55, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {0, 16}, size = {16, 16}}, id=56, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {16, 16}, size = {16, 16}}, id=57, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {32, 16}, size = {16, 16}}, id=58, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {48, 16}, size = {16, 16}}, id=59, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {64, 16}, size = {16, 16}}, id=60, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {80, 16}, size = {16, 16}}, id=61, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {96, 16}, size = {16, 16}}, id=62, collisions={Rect{start = {0, 8}, size = {16, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {112, 16}, size = {16, 16}}, id=63, collisions={Rect{start = {0, 0}, size = {16, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {128, 16}, size = {16, 16}}, id=64, collisions={Rect{start = {0, 8}, size = {16, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {144, 16}, size = {16, 16}}, id=65, collisions={Rect{start = {8, 0}, size = {8, 8}}, Rect{start = {0, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {160, 16}, size = {16, 16}}, id=66, collisions={Rect{start = {8, 8}, size = {8, 8}}, Rect{start = {0, 0}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {0, 32}, size = {16, 16}}, id=67, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {16, 32}, size = {16, 16}}, id=68, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {32, 32}, size = {16, 16}}, id=69, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {48, 32}, size = {16, 16}}, id=70, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {64, 32}, size = {16, 16}}, id=71, collisions={Rect{start = {8, 0}, size = {8, 8}}, Rect{start = {0, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {80, 32}, size = {16, 16}}, id=72, collisions={Rect{start = {8, 8}, size = {8, 8}}, Rect{start = {0, 0}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {96, 32}, size = {16, 16}}, id=73, collisions={Rect{start = {0, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {112, 32}, size = {16, 16}}, id=74, collisions={Rect{start = {8, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {128, 32}, size = {16, 16}}, id=75, collisions={Rect{start = {0, 0}, size = {16, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {144, 32}, size = {16, 16}}, id=76, collisions={Rect{start = {0, 0}, size = {8, 16}}}},
+ {tileset=.TILESET, rect=Rect{start = {160, 32}, size = {16, 16}}, id=77, collisions={Rect{start = {8, 0}, size = {8, 16}}}},
+ {tileset=.TILESET, rect=Rect{start = {0, 48}, size = {16, 16}}, id=78, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {16, 48}, size = {16, 16}}, id=79, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {32, 48}, size = {16, 16}}, id=80, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {48, 48}, size = {16, 16}}, id=81, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {64, 48}, size = {16, 16}}, id=82, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {0, 0}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {80, 48}, size = {16, 16}}, id=83, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {8, 0}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {96, 48}, size = {16, 16}}, id=84, collisions={}},
+ {tileset=.TILESET, rect=Rect{start = {112, 48}, size = {16, 16}}, id=85, collisions={Rect{start = {8, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {128, 48}, size = {16, 16}}, id=86, collisions={Rect{start = {0, 8}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {144, 48}, size = {16, 16}}, id=87, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {0, 0}, size = {8, 8}}}},
+ {tileset=.TILESET, rect=Rect{start = {160, 48}, size = {16, 16}}, id=88, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {8, 0}, size = {8, 8}}}},
}
-//odinfmt: enable
-
world: []Room_Position_Resource = {
- {id=.ROOM_BEGIN_1, x=-528, y=-64, width=480, height=320},
- {id=.ROOM_BEGIN, x=-48, y=-64, width=480, height=320},
+ {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},
}
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/img/player.ase" = Image_Id.PLAYER,
"res/img/tilesets.png" = Image_Id.TILESETS,
- "res/room_begin.tmj" = Room_Id.ROOM_BEGIN,
- "res/room_begin_1.tmj" = Room_Id.ROOM_BEGIN_1,
}
load_resources :: proc() {
diff --git a/src/main.odin b/src/main.odin
index 0ce4fac..3b0f203 100644
--- a/src/main.odin
+++ b/src/main.odin
@@ -140,9 +140,10 @@ main :: proc() {
rl.SetTraceLogCallback(raylib_log)
rl.InitWindow(480 * 2, 360 * 2, "Demonchime")
-
rl.SetWindowState({.WINDOW_RESIZABLE})
+ rl.SetTargetFPS(240)
+
init()
for !rl.WindowShouldClose() {
diff --git a/src/player.odin b/src/player.odin
index 71b015b..f2afd6c 100644
--- a/src/player.odin
+++ b/src/player.odin
@@ -218,3 +218,15 @@ update_player :: proc(dt: f32) {
draw_player :: proc() {
draw_sprite(player.sprite)
}
+
+@(private = "file")
+already_spawned_player := false
+
+player_spawn_object_spawner :: proc(obj: Object_Resource) {
+ if already_spawned_player {
+ return
+ }
+ already_spawned_player = true
+
+ phys.set_body_position(player.body_handle, obj.pos)
+}
diff --git a/src/resources.odin b/src/resources.odin
index 49e9603..0997585 100644
--- a/src/resources.odin
+++ b/src/resources.odin
@@ -20,6 +20,7 @@ Animation_Resource :: struct {
}
Object_Resource :: struct {
+ type: Object_Type,
pos: Vec2,
parallax: Vec2,
properties: map[string]any,
diff --git a/src/sprite.odin b/src/sprite.odin
index 803dd85..549373b 100644
--- a/src/sprite.odin
+++ b/src/sprite.odin
@@ -40,8 +40,6 @@ init_sprite :: proc(
sprite.width = i32(f32(sprite.image.width) / f32(anim.frame_count))
sprite.height = i32(sprite.image.height)
- log.debug(sprite.width, anim.frame_count, sprite.anim_id)
-
sprite.scale = Vec2{1, 1}
return true
@@ -96,6 +94,4 @@ draw_sprite :: proc(sprite: Sprite) {
sprite.rotation,
sprite.scale,
)
-
- // log.debug(rect)
}
diff --git a/src/world.odin b/src/world.odin
index 3248d65..4f3ee7f 100644
--- a/src/world.odin
+++ b/src/world.odin
@@ -1,16 +1,28 @@
package demonchime
-import "core:log"
-
import rl "vendor:raylib"
+Object_Spawner :: proc(Object_Resource)
+
current_room: Room_Position_Resource
+object_spawners := [Object_Type]Object_Spawner{
+ .PLAYER_SPAWN = player_spawn_object_spawner,
+}
+
+@(private = "file")
+spawn_objects :: proc(room_id: Room_Id) {
+ room := get_room(room_id)
+
+ for obj in room.objects {
+ object_spawners[obj.type](obj)
+ }
+}
+
open_room_at :: proc(pos: [2]i32) -> bool {
pos := pos
pos += {current_room.x, current_room.y}
- log.debug("trying to change room...", pos)
for room_pos in world {
if room_pos.id == current_room.id {
continue
@@ -21,6 +33,7 @@ open_room_at :: proc(pos: [2]i32) -> bool {
pos.y >= room_pos.y &&
pos.y <= room_pos.y + room_pos.height {
current_room = room_pos
+ spawn_objects(current_room.id)
return true
}
}
@@ -31,6 +44,7 @@ open_room :: proc(id: Room_Id) -> bool {
for room_pos in world {
if room_pos.id == id {
current_room = room_pos
+ spawn_objects(current_room.id)
return true
}
}