This commit is contained in:
2026-05-06 19:12:34 -07:00
parent cf19776262
commit 9a2430edfa
111 changed files with 2085 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

BIN
top_down/Assets/finger.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
top_down/Assets/grid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

BIN
top_down/Assets/grid_b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 672 B

View File

View File

@ -0,0 +1 @@
{"name":"untitled","x":0,"y":0,"width":1280,"height":720,"elements":[{"id":15,"type":9,"name":"MenuContainer","event":"","x":10,"y":61,"width":332,"height":402,"rotation":0,"text":"My Shape","asset":"","color":-1258291200,"anchor":0,"parent":null,"children":[2,3,6,8,11,12,13,14],"visible":true},{"id":2,"type":6,"name":"SSR","event":"","x":24,"y":179,"width":150,"height":44,"rotation":0,"text":"SSR","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":3,"type":6,"name":"SSAO","event":"","x":24,"y":229,"width":150,"height":44,"rotation":0,"text":"SSAO","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":6,"type":6,"name":"Bloom","event":"","x":24,"y":129,"width":150,"height":44,"rotation":0,"text":"Bloom","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":8,"type":8,"name":"Shadows","event":"","x":24,"y":79,"width":150,"height":44,"rotation":0,"text":"High;Medium;Low","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":11,"type":0,"name":"Title","event":"","x":4,"y":9,"width":377,"height":44,"rotation":0,"text":"Graphics Settings","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":12,"type":0,"name":"ShadowsTitle","event":"","x":164,"y":79,"width":184,"height":28,"rotation":0,"text":"Shadows","asset":"","color":-6381922,"anchor":0,"parent":15,"children":[],"visible":true},{"id":13,"type":2,"name":"Apply","event":"apply_settings","x":24,"y":329,"width":150,"height":44,"rotation":0,"text":"Apply","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":14,"type":6,"name":"Voxels","event":"","x":24,"y":279,"width":150,"height":44,"rotation":0,"text":"Voxels","asset":"","color":-1,"anchor":0,"parent":15,"children":[],"visible":true},{"id":16,"type":2,"name":"Menu","event":"toggle_menu","x":5,"y":5,"width":150,"height":44,"rotation":0,"text":"Menu","asset":"","color":-1,"anchor":0,"parent":null,"children":[],"visible":true}],"assets":[]}

View File

@ -0,0 +1,20 @@
{
"rp_bloom": true,
"rp_dynres": false,
"rp_gi": true,
"rp_motionblur": false,
"rp_shadowmap_cascade": 2048,
"rp_shadowmap_cube": 512,
"rp_ssgi": true,
"rp_ssr": true,
"rp_supersample": 1.0,
"window_h": 720,
"window_maximizable": false,
"window_minimizable": true,
"window_mode": 0,
"window_msaa": 1,
"window_resizable": false,
"window_scale": 1.0,
"window_vsync": true,
"window_w": 1280
}

BIN
top_down/Bundled/step0.wav Normal file

Binary file not shown.

BIN
top_down/Bundled/step1.wav Normal file

Binary file not shown.

BIN
top_down/Bundled/sword0.wav Normal file

Binary file not shown.

BIN
top_down/Bundled/sword1.wav Normal file

Binary file not shown.

View File

@ -0,0 +1,136 @@
package lnx;
import iron.math.Vec4;
import iron.object.Object;
import iron.object.BoneAnimation;
import iron.system.Time;
import iron.system.Audio;
import iron.system.Input;
import leenkx.trait.physics.RigidBody;
class PlayerController extends iron.Trait {
#if (!lnx_physics)
public function new() { super(); }
#else
var mouse:Mouse = null;
var keyboard:Keyboard = null;
var gamepad:Gamepad = null;
var body:RigidBody;
var anim:BoneAnimation;
var armature:Object;
var stepTime = 0.0;
var dir = new Vec4();
var lastDir = new Vec4();
var lastLook:Vec4;
var state = "idle";
var soundStep0:kha.Sound = null;
var soundStep1:kha.Sound = null;
var soundSword0:kha.Sound = null;
var soundSword1:kha.Sound = null;
var stepSoundsLoaded = 0;
var swordSoundsLoaded = 0;
public function new() {
super();
// Load sounds
iron.data.Data.getSound("step0.wav", function(sound:kha.Sound) { soundStep0 = sound; stepSoundsLoaded++; });
iron.data.Data.getSound("step1.wav", function(sound:kha.Sound) { soundStep1 = sound; stepSoundsLoaded++; });
iron.data.Data.getSound("sword0.wav", function(sound:kha.Sound) { soundSword0 = sound; swordSoundsLoaded++; });
iron.data.Data.getSound("sword1.wav", function(sound:kha.Sound) { soundSword1 = sound; swordSoundsLoaded++; });
notifyOnInit(init);
notifyOnUpdate(update);
}
function init() {
// Get input devices
mouse = Input.getMouse();
keyboard = Input.getKeyboard();
gamepad = Input.getGamepad(0);
// Store references
body = object.getTrait(RigidBody);
armature = object.getChild("Armature");
anim = cast armature.children[0].animation;
}
function update() {
// Movement
dir.set(0, 0, 0);
if (keyboard.down("w")) dir.y = 1.0;
if (keyboard.down("s")) dir.y = -1.0;
if (keyboard.down("a")) dir.x = -1.0;
if (keyboard.down("d")) dir.x = 1.0;
if (gamepad != null && Math.abs(gamepad.leftStick.x) > 0.1) dir.x = gamepad.leftStick.x;
if (gamepad != null && Math.abs(gamepad.leftStick.y) > 0.1) dir.y = gamepad.leftStick.y;
dir.normalize();
// Rotate
var q = new iron.math.Quat();
q.fromTo(Vec4.yAxis(), new Vec4(lastDir.x, lastDir.y, 0.0));
armature.transform.rot.lerp(armature.transform.rot, q, 0.25);
armature.transform.buildMatrix();
updateAnim();
updateBody();
if (dir.length() > 0) lastDir.setFrom(dir);
}
function updateAnim() {
var look = armature.transform.look().normalize();
// Move
if (dir.length() > 0) {
setState("run", 1.0);
// Step sounds
stepTime += Time.delta;
if (stepTime > 0.3) {
stepTime = 0;
if (stepSoundsLoaded == 2) {
Audio.play(Std.random(2) == 0 ? soundStep0 : soundStep1);
}
}
}
// Slash
else if (state == "idle") {
if (mouse.down("left") || (gamepad != null && gamepad.down("r2") > 0.0)) {
var r = Std.random(2);
setState(r == 0 ? "slash" : "slash2", 1.5, 0.0, function() { setState("idle", 1.0, 0.0); });
iron.system.Tween.timer(0.3, function() {
if (swordSoundsLoaded == 2) {
Audio.play(r == 0 ? soundSword0 : soundSword1);
}
});
}
}
// Idle
else if (state != "slash" && state != "slash2") {
setState("idle", 1.0);
}
}
function updateBody() {
if (!body.ready) return;
body.syncTransform();
body.activate();
var linvel = body.getLinearVelocity();
body.setLinearVelocity(dir.x * 6, dir.y * 6, linvel.z - 1.0); // Push down
body.setAngularFactor(0, 0, 0); // Keep vertical
}
function setState(s:String, speed:Float, blend = 0.2, onComplete:Void->Void = null) {
if (s == state) return;
state = s;
anim.play(s, onComplete, blend, speed);
}
#end
}

View File

@ -0,0 +1,68 @@
package lnx;
import iron.Scene;
import leenkx.system.Event;
import leenkx.data.Config;
import leenkx.trait.internal.CanvasScript;
import leenkx.renderpath.RenderPathCreator;
class SettingsTrait extends iron.Trait {
var canvas:CanvasScript;
var envStrength = 0.0;
public function new() {
super();
notifyOnInit(function() {
canvas = Scene.active.getTrait(CanvasScript);
// Init UI to values loaded from config.lnx file
canvas.notifyOnReady(function() {
canvas.getElement("MenuContainer").visible = false;
canvas.getHandle("SSAO").selected = Config.raw.rp_ssgi;
canvas.getHandle("SSR").selected = Config.raw.rp_ssr;
canvas.getHandle("Bloom").selected = Config.raw.rp_bloom;
canvas.getHandle("Voxels").selected = Config.raw.rp_gi;
canvas.getHandle("Shadows").position = getShadowQuality(Config.raw.rp_shadowmap_cascade);
});
// Button events
Event.add("toggle_menu", toggleMenu);
Event.add("apply_settings", applySettings);
});
}
function toggleMenu() {
var e = canvas.getElement("MenuContainer");
e.visible = !e.visible;
}
function applySettings() {
// Apply render path settings
Config.raw.rp_ssgi = canvas.getHandle("SSAO").selected;
Config.raw.rp_ssr = canvas.getHandle("SSR").selected;
Config.raw.rp_bloom = canvas.getHandle("Bloom").selected;
Config.raw.rp_gi = canvas.getHandle("Voxels").selected;
Config.raw.rp_shadowmap_cascade = getShadowMapSize(canvas.getHandle("Shadows").position);
RenderPathCreator.applyConfig();
// Lower envmap strength when voxel ao is disabled
var p = iron.Scene.active.world.probe.raw;
if (envStrength == 0) envStrength = p.strength;
p.strength = Config.raw.rp_gi ? envStrength : envStrength / 3;
// Save config.lnx file
Config.save();
}
inline function getShadowQuality(i:Int):Int {
// 0 - High, 1 - Medium, 2 - Low
return i == 4096 ? 0 : i == 2048 ? 1 : 2;
}
inline function getShadowMapSize(i:Int):Int {
return i == 0 ? 4096 : i == 1 ? 2048 : 1024;
}
}

BIN
top_down/top_down.blend Normal file

Binary file not shown.