aboutsummaryrefslogtreecommitdiff
path: root/src/main.odin
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/main.odin
parent4563dfa077e029fbefd192f087338d186155ebfc (diff)
Ensure upwards and downwards transitions work
Diffstat (limited to 'src/main.odin')
-rw-r--r--src/main.odin65
1 files changed, 55 insertions, 10 deletions
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}
}