feat: distinct material palette for BSP 2 courtyard

This commit is contained in:
asrael 2026-02-27 08:21:12 -06:00
parent 2fb4042fba
commit 9f657ffcf9
2 changed files with 25 additions and 10 deletions

View file

@ -41,6 +41,7 @@
(var cam-z 416) (var cam-z 416)
(var camera nil) (var camera nil)
(var ceiling-tex nil) (var ceiling-tex nil)
(var current-bsp-id 1)
(var floor-tex nil) (var floor-tex nil)
(var land-squash 0) (var land-squash 0)
(var last-dt 0.016) (var last-dt 0.016)
@ -63,6 +64,11 @@
(local STONE_WALL_START 2) (local STONE_WALL_START 2)
(local WOOD_COLOR 88) (local WOOD_COLOR 88)
(local ASHLAR_COLOR 64)
(local ASHLAR_MOSS 68)
(local STONE_FLOOR_COLOR 72)
(local STONE_TRIM_COLOR 72)
(fn preload [] (fn preload []
(when (not network) (when (not network)
(set network (net.get)) (set network (net.get))
@ -83,6 +89,20 @@
(let [chunk (world:active_chunk)] (let [chunk (world:active_chunk)]
(and chunk (chunk:ready))))) (and chunk (chunk:ready)))))
(fn setup-textures [bsp-id]
(if (= bsp-id 2)
(do
(set floor-tex (textures.rough-stone 44442 STONE_FLOOR_COLOR))
(set wall-tex (textures.ashlar-wall 55552 ASHLAR_COLOR ASHLAR_MOSS))
(set trim-tex (textures.rough-stone 77772 STONE_TRIM_COLOR))
(set ceiling-tex (textures.plaster-wall 66662 PLASTER_COLOR)))
(do
(set floor-tex (textures.wood-planks 44444 WOOD_COLOR))
(set wall-tex (textures.cobble-timber 55555 STONE_WALL_START MOSS_COLOR WOOD_COLOR))
(set trim-tex (textures.wood-trim 77777 WOOD_COLOR))
(set ceiling-tex (textures.plaster-wall 66666 PLASTER_COLOR))))
(set current-bsp-id bsp-id))
(fn init [] (fn init []
(pxl8.set_relative_mouse_mode true) (pxl8.set_relative_mouse_mode true)
(pxl8.load_palette "res/palettes/palette.ase") (pxl8.load_palette "res/palettes/palette.ase")
@ -113,14 +133,7 @@
(set smooth-cam-x cam-x) (set smooth-cam-x cam-x)
(set smooth-cam-z cam-z)) (set smooth-cam-z cam-z))
(when (not ceiling-tex) (setup-textures 1))
(set ceiling-tex (textures.plaster-wall 66666 PLASTER_COLOR)))
(when (not floor-tex)
(set floor-tex (textures.wood-planks 44444 WOOD_COLOR)))
(when (not trim-tex)
(set trim-tex (textures.wood-trim 77777 WOOD_COLOR)))
(when (not wall-tex)
(set wall-tex (textures.cobble-timber 55555 STONE_WALL_START MOSS_COLOR WOOD_COLOR))))
(fn setup-materials [] (fn setup-materials []
(when (and world (not bsp-materials-setup) floor-tex trim-tex wall-tex) (when (and world (not bsp-materials-setup) floor-tex trim-tex wall-tex)
@ -182,6 +195,7 @@
(set smooth-cam-x 416) (set smooth-cam-x 416)
(set smooth-cam-z 416) (set smooth-cam-z 416)
(set bsp-materials-setup false) (set bsp-materials-setup false)
(setup-textures 2)
(set portal-cooldown 2.0)) (set portal-cooldown 2.0))
(= current-id 2) (= current-id 2)
(do (do
@ -194,6 +208,7 @@
(set smooth-cam-x 416) (set smooth-cam-x 416)
(set smooth-cam-z 416) (set smooth-cam-z 416)
(set bsp-materials-setup false) (set bsp-materials-setup false)
(setup-textures 1)
(set portal-cooldown 2.0))))))) (set portal-cooldown 2.0)))))))
(when world (when world

View file

@ -4,7 +4,7 @@ use alloc::collections::BTreeMap;
use crate::chunk::{Chunk, ChunkId}; use crate::chunk::{Chunk, ChunkId};
use crate::math::Vec3; use crate::math::Vec3;
use crate::procgen::{ProcgenParams, generate_rooms}; use crate::procgen::{ProcgenParams, generate};
pub struct World { pub struct World {
active: Option<ChunkId>, active: Option<ChunkId>,
@ -69,7 +69,7 @@ impl World {
..Default::default() ..Default::default()
}; };
let p = params.unwrap_or(&default_params); let p = params.unwrap_or(&default_params);
let bsp = generate_rooms(p); let bsp = generate(p);
self.chunks.insert(chunk_id, Chunk::Bsp { id, bsp, version: 1 }); self.chunks.insert(chunk_id, Chunk::Bsp { id, bsp, version: 1 });
} }
self.chunks.get(&chunk_id).unwrap() self.chunks.get(&chunk_id).unwrap()