move some files around

This commit is contained in:
asrael 2025-10-06 19:00:03 -05:00
parent 47c4f2045c
commit cfe7501fe2
12 changed files with 78 additions and 49 deletions

View file

@ -26,8 +26,8 @@
(fn init-texture []
(when (not texture-initialized)
(pxl8.load_palette "sprites/pxl8_logo.ase")
(set texture-id (pxl8.load_sprite "sprites/pxl8_logo.ase"))
(pxl8.load_palette "res/sprites/pxl8_logo.ase")
(set texture-id (pxl8.load_sprite "res/sprites/pxl8_logo.ase"))
(pxl8.upload_atlas)
(set texture-initialized true)))
@ -71,37 +71,57 @@
(set fps-accumulator 0)
(set fps-frame-count 0))
(let [wheel-y (pxl8.mouse_wheel_y)
zoom-speed 0.5]
(when (not= wheel-y 0)
(let [forward-x (* (math.sin cam-yaw) wheel-y zoom-speed)
forward-z (* (math.cos cam-yaw) wheel-y zoom-speed)]
(set cam-x (+ cam-x forward-x))
(set cam-z (- cam-z forward-z)))))
(let [wheel-y (pxl8.mouse_wheel_y)]
(when (and (not= wheel-y 0) (not (pxl8.ui_has_mouse_focus)))
(if orthographic
(set zoom (math.max 0.5 (math.min (- zoom (* wheel-y 0.2)) 10.0)))
(let [zoom-speed 0.5
forward-x (* (math.sin cam-yaw) wheel-y zoom-speed)
forward-z (* (math.cos cam-yaw) wheel-y zoom-speed)]
(set cam-x (+ cam-x forward-x))
(set cam-z (- cam-z forward-z))))))
(let [move-speed 5.0
rot-speed 2.0
zoom-speed 2.0
forward-x (* (math.sin cam-yaw) move-speed dt)
forward-z (* (math.cos cam-yaw) move-speed dt)
right-x (* (math.cos cam-yaw) move-speed dt)
right-z (* (- (math.sin cam-yaw)) move-speed dt)]
(when (pxl8.key_down "w")
(set cam-x (+ cam-x forward-x))
(set cam-z (- cam-z forward-z)))
(when (pxl8.key_down "s")
(set cam-x (- cam-x forward-x))
(set cam-z (+ cam-z forward-z)))
(when (pxl8.key_down "a")
(set cam-x (- cam-x right-x))
(set cam-z (- cam-z right-z)))
(when (pxl8.key_down "d")
(set cam-x (+ cam-x right-x))
(set cam-z (+ cam-z right-z)))
(when (pxl8.key_down "q")
(set cam-y (- cam-y (* move-speed dt))))
(when (pxl8.key_down "e")
(set cam-y (+ cam-y (* move-speed dt))))
(if orthographic
(do
(when (pxl8.key_down "w")
(set zoom (math.max 0.5 (- zoom (* zoom-speed dt)))))
(when (pxl8.key_down "s")
(set zoom (math.min 10.0 (+ zoom (* zoom-speed dt)))))
(when (pxl8.key_down "a")
(set cam-x (- cam-x right-x))
(set cam-z (- cam-z right-z)))
(when (pxl8.key_down "d")
(set cam-x (+ cam-x right-x))
(set cam-z (+ cam-z right-z)))
(when (pxl8.key_down "q")
(set cam-y (- cam-y (* move-speed dt))))
(when (pxl8.key_down "e")
(set cam-y (+ cam-y (* move-speed dt)))))
(do
(when (pxl8.key_down "w")
(set cam-x (+ cam-x forward-x))
(set cam-z (- cam-z forward-z)))
(when (pxl8.key_down "s")
(set cam-x (- cam-x forward-x))
(set cam-z (+ cam-z forward-z)))
(when (pxl8.key_down "a")
(set cam-x (- cam-x right-x))
(set cam-z (- cam-z right-z)))
(when (pxl8.key_down "d")
(set cam-x (+ cam-x right-x))
(set cam-z (+ cam-z right-z)))
(when (pxl8.key_down "q")
(set cam-y (- cam-y (* move-speed dt))))
(when (pxl8.key_down "e")
(set cam-y (+ cam-y (* move-speed dt))))))
(when (pxl8.key_down "left")
(set cam-yaw (- cam-yaw (* rot-speed dt))))
@ -144,7 +164,7 @@
(pxl8.set_wireframe wireframe)
(if orthographic
(let [size 2.5
(let [size zoom
aspect (/ (pxl8.get_width) (pxl8.get_height))
w (* size aspect)
h size]

View file

@ -3,8 +3,7 @@
(fn render [state]
(var new-state {})
(when state.show-debug-ui
(let [window-h (if state.use-texture 210 180)
window-open (pxl8.ui_window_begin "Debug Menu (F8)" 10 10 250 window-h)]
(let [window-open (pxl8.ui_window_begin "Debug Menu (F8)" 10 10 256 128)]
(when window-open
(pxl8.ui_layout_row 1 0 0)
(pxl8.ui_label (string.format "FPS: %.0f" (or state.fps 0)))