refactor some api things

This commit is contained in:
asrael 2025-11-15 11:55:00 -06:00
parent 27b6459b9a
commit 1634b1126b
9 changed files with 35 additions and 34 deletions

View file

@ -19,10 +19,11 @@
(var transition-pending nil)
(fn switch-demo [new-demo]
(set transition-pending new-demo)
(set transition (pxl8.transition_create :pixelate 0.5))
(pxl8.transition_set_color transition 0xFF000000)
(pxl8.transition_start transition))
(when (not= active-demo new-demo)
(set transition-pending new-demo)
(set transition (pxl8.transition_create :pixelate 0.5))
(pxl8.transition_set_color transition 0xFF000000)
(pxl8.transition_start transition)))
(global init (fn []
(cube3d.init)
@ -77,7 +78,7 @@
(global frame (fn []
(case active-demo
:logo (do
(pxl8.clr 0)
(pxl8.clear 0)
(when logo-sprite
(pxl8.sprite logo-sprite logo-x logo-y 128 64)))
@ -86,14 +87,14 @@
:tunnel (pxl8.vfx_tunnel time 2.0 0.25)
:raster (do
(pxl8.clr 0)
(pxl8.clear 0)
(local bars [{:base_y 60 :amplitude 30 :height 16 :speed 2.0 :phase 0 :color 1 :fade_color 18}
{:base_y 180 :amplitude 35 :height 16 :speed 1.8 :phase 2.0 :color 1 :fade_color 27}
{:base_y 300 :amplitude 25 :height 16 :speed 2.2 :phase 4.0 :color 1 :fade_color 24}])
(pxl8.vfx_raster_bars bars time))
:fire (do
(pxl8.clr 0)
(pxl8.clear 0)
(when particles
(when (not fire-init?)
(pxl8.particles_clear particles)
@ -102,7 +103,7 @@
(pxl8.particles_render particles)))
:rain (do
(pxl8.clr 0)
(pxl8.clear 0)
(when particles
(when (not rain-init?)
(pxl8.particles_clear particles)
@ -111,7 +112,7 @@
(pxl8.particles_render particles)))
:snow (do
(pxl8.clr 0)
(pxl8.clear 0)
(when particles
(when (not snow-init?)
(pxl8.particles_clear particles)
@ -123,7 +124,7 @@
:worldgen (worldgen.frame)
_ (pxl8.clr 0))
_ (pxl8.clear 0))
(when transition
(pxl8.transition_render transition))))

View file

@ -203,7 +203,7 @@
(pxl8.draw_triangle_3d v0 v1 v2 color)))))))
(fn frame []
(pxl8.clr 0)
(pxl8.clear 0)
(pxl8.clear_zbuffer)
(pxl8.set_affine_textures affine?)

View file

@ -143,7 +143,7 @@
(set bob-time (+ (* bob-time 0.8) (* target-phase 0.2))))))))
(fn frame []
(pxl8.clr 0)
(pxl8.clear 0)
(when (pxl8.world_is_loaded world)
(let [bob-offset (* (math.sin bob-time) bob-amount)