This commit is contained in:
2026-05-06 17:52:45 -07:00
parent 9fc3f35125
commit 1463c23334
402 changed files with 3758 additions and 0 deletions

View File

@ -0,0 +1 @@
{"name":"untitled","x":0,"y":0,"width":960,"height":540,"elements":[{"id":0,"type":0,"name":"Score","event":"","x":0,"y":0,"width":150,"height":48,"text":"0","asset":"","color":-16777216,"anchor":0,"children":[]}],"assets":[]}

View File

@ -0,0 +1,31 @@
package lnx;
class GemTrait extends iron.Trait {
static var gemsCollected = 0;
var player:iron.object.Object = null;
public function new() {
super();
notifyOnUpdate(function() {
object.transform.rotate(iron.math.Vec4.zAxis(), 0.05);
if (player == null) player = iron.Scene.active.getChild("Player");
var w1 = object.transform.world;
var w2 = player.transform.world;
var d = iron.math.Vec4.distance(w1.getLoc(), w2.getLoc());
// Collect gem
if (d < 0.6) {
gemsCollected++;
object.remove();
// Update UI
var canvas = iron.Scene.active.getTrait(leenkx.trait.internal.CanvasScript);
canvas.getElement("Score").text = gemsCollected + "";
}
});
}
}

View File

@ -0,0 +1,22 @@
package lnx;
class PlayerController extends iron.Trait {
public function new() {
super();
notifyOnUpdate(function() {
var kb = iron.system.Input.getKeyboard();
var x = object.transform.loc.x;
// Move player
if ((kb.down("left") || kb.down("a")) && x > -1.8) {
object.transform.loc.x -= 0.06;
object.transform.dirty = true;
}
if ((kb.down("right") || kb.down("d")) && x < 1.8) {
object.transform.loc.x += 0.06;
object.transform.dirty = true;
}
});
}
}

View File

@ -0,0 +1,51 @@
package lnx;
class SceneBuilder extends iron.Trait {
var dist = 0.0;
var tileNum = 0;
var tilesVisible = 14;
var tiles:Array<iron.object.Object> = [];
var empty:iron.object.Object;
function spawnTile(num:Int) {
iron.Scene.active.spawnObject("Tile" + Std.random(2), null, function(o) {
// Remove old tile
if (tiles[num % tilesVisible] != null) {
tiles[num % tilesVisible].remove();
}
// Spawn new tile
tiles[num % tilesVisible] = o;
o.transform.loc.x = 0;
o.transform.loc.y = num * 4.0;
o.transform.buildMatrix();
// Spawn gem
if (Std.random(3) == 0) {
iron.Scene.active.spawnObject("Gem", o, function(go) {
go.transform.loc.x = (Math.random() - 0.5) * 1.8;
go.transform.loc.z = 0.2;
go.transform.buildMatrix();
});
}
});
}
public function new() {
super();
notifyOnUpdate(function() {
if (empty == null) empty = iron.Scene.active.getChild("Empty");
// Spawn new tiles
while (tileNum < Std.int(dist / 4 + 13)) spawnTile(tileNum++);
// Travel forward
dist += 0.1;
empty.transform.loc.y = dist;
empty.transform.buildMatrix();
});
}
}

Binary file not shown.

BIN
game_endlessrun/grid.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB