2025-08-13 15:04:49 -05:00
|
|
|
(local pxl8 (require :pxl8))
|
2025-11-21 11:51:23 -06:00
|
|
|
(local menu (require :mod.menu))
|
2026-01-07 17:45:46 -06:00
|
|
|
(local music (require :mod.music))
|
2026-01-17 22:52:36 -06:00
|
|
|
(local first_person3d (require :mod.first_person3d))
|
2025-08-13 15:04:49 -05:00
|
|
|
|
|
|
|
|
(var time 0)
|
2026-01-31 09:31:17 -06:00
|
|
|
(var in-world false)
|
2026-01-21 23:19:50 -06:00
|
|
|
(var first_person3d-init? false)
|
2025-08-13 15:04:49 -05:00
|
|
|
|
2025-09-28 13:10:29 -05:00
|
|
|
(var logo-x 256)
|
|
|
|
|
(var logo-y 148)
|
|
|
|
|
(var logo-dx 100)
|
|
|
|
|
(var logo-dy 80)
|
|
|
|
|
(var logo-sprite nil)
|
2025-11-15 11:40:27 -06:00
|
|
|
(var transition nil)
|
2026-01-31 09:31:17 -06:00
|
|
|
(var transition-to-world false)
|
2025-11-15 11:40:27 -06:00
|
|
|
|
2026-01-31 09:31:17 -06:00
|
|
|
(fn start-transition []
|
|
|
|
|
(when (not transition)
|
|
|
|
|
(set transition-to-world true)
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
(set transition (pxl8.create_transition :pixelate 0.5))
|
|
|
|
|
(transition:set_color 0xFF000000)
|
|
|
|
|
(transition:start)))
|
2025-09-28 13:10:29 -05:00
|
|
|
|
2026-01-31 09:31:17 -06:00
|
|
|
(fn enter-world []
|
|
|
|
|
(when (first_person3d.is-ready)
|
|
|
|
|
(start-transition)))
|
|
|
|
|
|
2025-08-13 15:04:49 -05:00
|
|
|
(global init (fn []
|
2025-10-06 19:00:03 -05:00
|
|
|
(pxl8.load_palette "res/sprites/pxl8_logo.ase")
|
|
|
|
|
(set logo-sprite (pxl8.load_sprite "res/sprites/pxl8_logo.ase"))
|
2026-01-31 09:31:17 -06:00
|
|
|
(music.init)
|
|
|
|
|
(menu.init)
|
|
|
|
|
(first_person3d.preload)))
|
2025-08-13 15:04:49 -05:00
|
|
|
|
|
|
|
|
(global update (fn [dt]
|
2025-11-21 11:51:23 -06:00
|
|
|
(when (pxl8.key_pressed "escape")
|
2026-01-31 09:31:17 -06:00
|
|
|
(if (menu.is-paused)
|
|
|
|
|
(do
|
|
|
|
|
(menu.hide)
|
|
|
|
|
(when in-world
|
|
|
|
|
(pxl8.set_relative_mouse_mode true)))
|
|
|
|
|
(if in-world
|
|
|
|
|
(do
|
|
|
|
|
(menu.show)
|
|
|
|
|
(pxl8.set_relative_mouse_mode false))
|
|
|
|
|
(menu.toggle))))
|
2025-11-21 11:51:23 -06:00
|
|
|
|
|
|
|
|
(when (not (menu.is-paused))
|
|
|
|
|
(set time (+ time dt))
|
2026-01-31 09:31:17 -06:00
|
|
|
(music.update dt)
|
2025-11-21 11:51:23 -06:00
|
|
|
|
|
|
|
|
(when transition
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
(transition:update dt)
|
|
|
|
|
(when (transition:is_complete)
|
2026-01-31 09:31:17 -06:00
|
|
|
(when transition-to-world
|
|
|
|
|
(set in-world true)
|
|
|
|
|
(set transition-to-world false)
|
|
|
|
|
(pxl8.set_relative_mouse_mode true))
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
(transition:destroy)
|
2025-11-21 11:51:23 -06:00
|
|
|
(set transition nil)))
|
|
|
|
|
|
2026-01-31 09:31:17 -06:00
|
|
|
(if in-world
|
|
|
|
|
(do
|
|
|
|
|
(when (not first_person3d-init?)
|
|
|
|
|
(first_person3d.init)
|
|
|
|
|
(set first_person3d-init? true))
|
|
|
|
|
(first_person3d.update dt))
|
|
|
|
|
(do
|
|
|
|
|
(when (and (not (menu.is-paused))
|
|
|
|
|
(first_person3d.is-ready)
|
|
|
|
|
(or (pxl8.key_pressed "return") (pxl8.key_pressed "space")))
|
|
|
|
|
(enter-world))
|
|
|
|
|
(set logo-x (+ logo-x (* logo-dx dt)))
|
|
|
|
|
(set logo-y (+ logo-y (* logo-dy dt)))
|
|
|
|
|
(when (< logo-x 0)
|
|
|
|
|
(set logo-x 0)
|
|
|
|
|
(set logo-dx (math.abs logo-dx)))
|
|
|
|
|
(when (> logo-x 512)
|
|
|
|
|
(set logo-x 512)
|
|
|
|
|
(set logo-dx (- (math.abs logo-dx))))
|
|
|
|
|
(when (< logo-y 0)
|
|
|
|
|
(set logo-y 0)
|
|
|
|
|
(set logo-dy (math.abs logo-dy)))
|
|
|
|
|
(when (> logo-y 296)
|
|
|
|
|
(set logo-y 296)
|
|
|
|
|
(set logo-dy (- (math.abs logo-dy)))))))
|
2025-11-21 11:51:23 -06:00
|
|
|
|
|
|
|
|
(when (menu.is-paused)
|
|
|
|
|
(menu.update))))
|
2025-08-13 15:04:49 -05:00
|
|
|
|
2025-10-04 04:13:48 -05:00
|
|
|
(global frame (fn []
|
2026-01-31 09:31:17 -06:00
|
|
|
(if in-world
|
|
|
|
|
(first_person3d.frame)
|
|
|
|
|
(do
|
|
|
|
|
(pxl8.clear 0)
|
|
|
|
|
(when logo-sprite
|
|
|
|
|
(pxl8.sprite logo-sprite logo-x logo-y 128 64 (< logo-dx 0) (< logo-dy 0)))
|
|
|
|
|
(when (not (menu.is-paused))
|
|
|
|
|
(if (first_person3d.is-ready)
|
|
|
|
|
(pxl8.text "Press ENTER to start" 240 320 1)
|
|
|
|
|
(if (first_person3d.is-connected)
|
|
|
|
|
(pxl8.text "Loading world..." 260 320 1)
|
|
|
|
|
(pxl8.text "Connecting..." 275 320 1))))))
|
2025-11-15 11:40:27 -06:00
|
|
|
|
|
|
|
|
(when transition
|
refactor: reorganize pxl8 into client/src/ module structure
- core/: main entry, types, logging, I/O, RNG
- asset/: ase loader, cart, save, embed
- gfx/: graphics, animation, atlas, fonts, tilemap, transitions
- sfx/: audio
- script/: lua/fennel runtime, REPL
- hal/: platform abstraction (SDL3)
- world/: BSP, world, procedural gen
- math/: math utilities
- game/: GUI, replay
- lua/: Lua API modules
2026-01-12 21:46:31 -06:00
|
|
|
(transition:render))
|
2025-11-21 11:51:23 -06:00
|
|
|
|
|
|
|
|
(when (menu.is-paused)
|
|
|
|
|
(menu.draw))))
|