only support indexed color mode, get rid of enum/branching on color modes
This commit is contained in:
parent
9f657ffcf9
commit
e0a5d34d29
25 changed files with 142 additions and 286 deletions
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
(local SIM_FLAG_GROUNDED 4)
|
||||
|
||||
(local door-spawn-x 860)
|
||||
(local door-spawn-z 416)
|
||||
(local door-spawn-yaw 1.5708)
|
||||
|
||||
(local sim-cfg (pxl8.sim_config {:move_speed 150
|
||||
:gravity 600
|
||||
:jump_velocity 180
|
||||
|
|
@ -48,7 +52,7 @@
|
|||
(var light-time 0)
|
||||
(var glows nil)
|
||||
(var lights nil)
|
||||
(var bsp-materials-setup false)
|
||||
(var materials-for-chunk 0)
|
||||
(var network nil)
|
||||
(var portal-cooldown 0)
|
||||
(var real-time 0)
|
||||
|
|
@ -136,17 +140,25 @@
|
|||
(setup-textures 1))
|
||||
|
||||
(fn setup-materials []
|
||||
(when (and world (not bsp-materials-setup) floor-tex trim-tex wall-tex)
|
||||
(when (not world) (lua "return"))
|
||||
(when (not network) (lua "return"))
|
||||
(let [net-chunk (network:chunk_id)]
|
||||
(when (or (= net-chunk 0) (= materials-for-chunk net-chunk)) (lua "return"))
|
||||
(when (not= current-bsp-id net-chunk)
|
||||
(setup-textures net-chunk))
|
||||
(when (not floor-tex) (lua "return"))
|
||||
(when (not wall-tex) (lua "return"))
|
||||
(let [chunk (world:active_chunk)]
|
||||
(when (and chunk (chunk:ready))
|
||||
(let [floor-mat (pxl8.create_material {:texture floor-tex :lighting true :double_sided true})
|
||||
trim-mat (pxl8.create_material {:texture trim-tex :lighting true :double_sided true})
|
||||
wall-mat (pxl8.create_material {:texture wall-tex :lighting true :double_sided true})]
|
||||
(world:set_bsp_material 0 floor-mat)
|
||||
(world:set_bsp_material 1 wall-mat)
|
||||
(world:set_bsp_material 3 trim-mat)
|
||||
(entities.setup-lighting (chunk:bsp) 2)
|
||||
(set bsp-materials-setup true))))))
|
||||
(when (not chunk) (lua "return"))
|
||||
(when (not (chunk:ready)) (lua "return"))
|
||||
(let [floor-mat (pxl8.create_material {:texture floor-tex :lighting true :double_sided true})
|
||||
trim-mat (pxl8.create_material {:texture trim-tex :lighting true :double_sided true})
|
||||
wall-mat (pxl8.create_material {:texture wall-tex :lighting true :double_sided true})]
|
||||
(world:set_bsp_material 0 floor-mat)
|
||||
(world:set_bsp_material 1 wall-mat)
|
||||
(world:set_bsp_material 3 trim-mat)
|
||||
(entities.setup-lighting (chunk:bsp) 2)
|
||||
(set materials-for-chunk net-chunk)))))
|
||||
|
||||
(fn sample-input []
|
||||
(when (pxl8.key_pressed "`")
|
||||
|
|
@ -187,27 +199,31 @@
|
|||
(if (= current-id 1)
|
||||
(do
|
||||
(pxl8.info "Door: BSP 1 -> BSP 2")
|
||||
(network:enter_scene 1 2 416 0 416)
|
||||
(world:init_local_player 416 0 416)
|
||||
(set cam-x 416)
|
||||
(network:enter_scene 1 2 door-spawn-x 0 door-spawn-z)
|
||||
(world:init_local_player door-spawn-x 0 door-spawn-z)
|
||||
(world:set_look door-spawn-yaw 0)
|
||||
(set cam-x door-spawn-x)
|
||||
(set cam-y 0)
|
||||
(set cam-z 416)
|
||||
(set smooth-cam-x 416)
|
||||
(set smooth-cam-z 416)
|
||||
(set bsp-materials-setup false)
|
||||
(set cam-z door-spawn-z)
|
||||
(set cam-yaw door-spawn-yaw)
|
||||
(set cam-pitch 0)
|
||||
(set smooth-cam-x door-spawn-x)
|
||||
(set smooth-cam-z door-spawn-z)
|
||||
(setup-textures 2)
|
||||
(set portal-cooldown 2.0))
|
||||
(= current-id 2)
|
||||
(do
|
||||
(pxl8.info "Door: BSP 2 -> BSP 1")
|
||||
(network:enter_scene 1 1 416 0 416)
|
||||
(world:init_local_player 416 0 416)
|
||||
(set cam-x 416)
|
||||
(network:enter_scene 1 1 door-spawn-x 0 door-spawn-z)
|
||||
(world:init_local_player door-spawn-x 0 door-spawn-z)
|
||||
(world:set_look door-spawn-yaw 0)
|
||||
(set cam-x door-spawn-x)
|
||||
(set cam-y 0)
|
||||
(set cam-z 416)
|
||||
(set smooth-cam-x 416)
|
||||
(set smooth-cam-z 416)
|
||||
(set bsp-materials-setup false)
|
||||
(set cam-z door-spawn-z)
|
||||
(set cam-yaw door-spawn-yaw)
|
||||
(set cam-pitch 0)
|
||||
(set smooth-cam-x door-spawn-x)
|
||||
(set smooth-cam-z door-spawn-z)
|
||||
(setup-textures 1)
|
||||
(set portal-cooldown 2.0)))))))
|
||||
|
||||
|
|
@ -282,7 +298,8 @@
|
|||
r2 (* 0.04 (math.sin (+ (* real-time 3.2) phase)))
|
||||
light-radius (* 150 (+ 0.95 r1 r2))]
|
||||
(lights:clear)
|
||||
(lights:add light-x light-y light-z 2 light-intensity light-radius)
|
||||
(when (= current-bsp-id 1)
|
||||
(lights:add light-x light-y light-z 2 light-intensity light-radius))
|
||||
|
||||
(pxl8.push_target)
|
||||
(pxl8.begin_frame_3d camera lights {
|
||||
|
|
@ -300,7 +317,7 @@
|
|||
(pxl8.set_wireframe (menu.is-wireframe))
|
||||
(world:render [smooth-cam-x eye-y smooth-cam-z])
|
||||
|
||||
(when chunk
|
||||
(when (and chunk (= current-bsp-id 1))
|
||||
(entities.render-fireball light-x light-y light-z (menu.is-wireframe)))
|
||||
|
||||
(entities.render-door (menu.is-wireframe) 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue