New feature: link a Start Flag to another doodad in your level and you will play as that doodad instead of Boy. All Creatures are designed to be playable. Playing as "other" doodads leads to interesting effects, like not being able to activate buttons, switches, or warp doors and not having an inventory to pick up keys. The Anvil is fun: it can destroy other mobile doodads by jumping on them. If the actor does not specify that it has gravity, the gameplay starts in antigravity mode. This will be the vast majority of non-mobile doodads and the Bird. Other changes: * The Blue and Red Azulians now share a doodad script. * The Azulians AI is still to walk back and forth, pickup keys and press buttons. The Blue Azulian walks slower than the red one. * The Blue Azulian is no longer hidden from the doodads list. * Actor UUID values in levels are now V1 UUIDs (time-ordered). This will help to reliably resolve conflicts in draw order of overlapping doodads (newest added to level wins). * Link Tool: clicking on a pair of already-linked doodads will now unlink them, so you don't have to delete one to delete the link. * Actor Tool: deleting an actor immediately calls PruneLinks() to clean up any links that the deleted doodad might have.
44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
// Azulian (Red)
|
|
// DEPRECATED: they both share azulian.js now.
|
|
|
|
function main() {
|
|
var playerSpeed = 4;
|
|
var gravity = 4;
|
|
var Vx = Vy = 0;
|
|
|
|
var direction = "right";
|
|
|
|
Self.SetHitbox(0, 0, 32, 32)
|
|
Self.SetMobile(true);
|
|
Self.SetInventory(true);
|
|
Self.SetGravity(true);
|
|
Self.AddAnimation("walk-left", 100, ["red-wl1", "red-wl2", "red-wl3", "red-wl4"]);
|
|
Self.AddAnimation("walk-right", 100, ["red-wr1", "red-wr2", "red-wr3", "red-wr4"]);
|
|
|
|
// Sample our X position every few frames and detect if we've hit a solid wall.
|
|
var sampleTick = 0;
|
|
var sampleRate = 5;
|
|
var lastSampledX = 0;
|
|
|
|
setInterval(function () {
|
|
if (sampleTick % sampleRate === 0) {
|
|
var curX = Self.Position().X;
|
|
var delta = Math.abs(curX - lastSampledX);
|
|
if (delta < 5) {
|
|
direction = direction === "right" ? "left" : "right";
|
|
}
|
|
lastSampledX = curX;
|
|
}
|
|
sampleTick++;
|
|
|
|
// TODO: Vector() requires floats, pain in the butt for JS,
|
|
// the JS API should be friendlier and custom...
|
|
var Vx = parseFloat(playerSpeed * (direction === "left" ? -1 : 1));
|
|
Self.SetVelocity(Vector(Vx, 0.0));
|
|
|
|
if (!Self.IsAnimating()) {
|
|
Self.PlayAnimation("walk-" + direction, null);
|
|
}
|
|
}, 100);
|
|
}
|