Link Start Flags to Change Characters
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.
This commit is contained in:
parent
a40cc0602e
commit
08ea9efc82
|
@ -4,11 +4,13 @@ ALL: build
|
||||||
build:
|
build:
|
||||||
doodad convert -t "Blue Azulian" blu-front.png blu-back.png \
|
doodad convert -t "Blue Azulian" blu-front.png blu-back.png \
|
||||||
blu-wr{1,2,3,4}.png blu-wl{1,2,3,4}.png azu-blu.doodad
|
blu-wr{1,2,3,4}.png blu-wl{1,2,3,4}.png azu-blu.doodad
|
||||||
|
doodad edit-doodad --tag "color=blue" azu-blu.doodad
|
||||||
doodad install-script azulian.js azu-blu.doodad
|
doodad install-script azulian.js azu-blu.doodad
|
||||||
|
|
||||||
doodad convert -t "Red Azulian" red-front.png red-back.png \
|
doodad convert -t "Red Azulian" red-front.png red-back.png \
|
||||||
red-wr{1,2,3,4}.png red-wl{1,2,3,4}.png azu-red.doodad
|
red-wr{1,2,3,4}.png red-wl{1,2,3,4}.png azu-red.doodad
|
||||||
doodad install-script azulian-red.js azu-red.doodad
|
doodad edit-doodad --tag "color=red" azu-red.doodad
|
||||||
|
doodad install-script azulian.js azu-red.doodad
|
||||||
|
|
||||||
# Tag the category for these doodads
|
# Tag the category for these doodads
|
||||||
for i in *.doodad; do\
|
for i in *.doodad; do\
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// Azulian (Red)
|
||||||
|
// DEPRECATED: they both share azulian.js now.
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
var playerSpeed = 4;
|
var playerSpeed = 4;
|
||||||
var gravity = 4;
|
var gravity = 4;
|
||||||
|
|
|
@ -1,38 +1,74 @@
|
||||||
function main() {
|
// Azulian (Red and Blue)
|
||||||
var playerSpeed = 12;
|
var playerSpeed = 12,
|
||||||
var gravity = 4;
|
animating = false,
|
||||||
var Vx = Vy = 0;
|
direction = "right";
|
||||||
|
|
||||||
var animating = false;
|
function setupAnimations(color) {
|
||||||
var animStart = animEnd = 0;
|
var left = color === 'blue' ? 'blu-wl' : 'red-wl',
|
||||||
var animFrame = animStart;
|
right = color === 'blue' ? 'blu-wr' : 'red-wr',
|
||||||
|
leftFrames = [left + '1', left + '2', left + '3', left + '4'],
|
||||||
|
rightFrames = [right + '1', right + '2', right + '3', right + '4'];
|
||||||
|
|
||||||
|
Self.AddAnimation("walk-left", 100, leftFrames);
|
||||||
|
Self.AddAnimation("walk-right", 100, rightFrames);
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
var color = Self.GetTag("color");
|
||||||
|
playerSpeed = color === 'blue' ? 2 : 4;
|
||||||
|
|
||||||
Self.SetMobile(true);
|
Self.SetMobile(true);
|
||||||
Self.SetGravity(true);
|
Self.SetGravity(true);
|
||||||
Self.SetInventory(true);
|
Self.SetInventory(true);
|
||||||
Self.SetHitbox(7, 4, 17, 28);
|
Self.SetHitbox(0, 0, 24, 32);
|
||||||
Self.AddAnimation("walk-left", 100, ["blu-wl1", "blu-wl2", "blu-wl3", "blu-wl4"]);
|
setupAnimations(color);
|
||||||
Self.AddAnimation("walk-right", 100, ["blu-wr1", "blu-wr2", "blu-wr3", "blu-wr4"]);
|
|
||||||
|
|
||||||
|
if (Self.IsPlayer()) {
|
||||||
|
return playerControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
// A.I. pattern: walks back and forth, turning around
|
||||||
|
// when it meets resistance.
|
||||||
|
|
||||||
|
// 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++;
|
||||||
|
|
||||||
|
var Vx = parseFloat(playerSpeed * (direction === "left" ? -1 : 1));
|
||||||
|
Self.SetVelocity(Vector(Vx, 0.0));
|
||||||
|
|
||||||
|
if (!Self.IsAnimating()) {
|
||||||
|
Self.PlayAnimation("walk-" + direction, null);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
function playerControls() {
|
||||||
|
// Note: player speed is controlled by the engine.
|
||||||
Events.OnKeypress(function (ev) {
|
Events.OnKeypress(function (ev) {
|
||||||
Vx = 0;
|
|
||||||
Vy = 0;
|
|
||||||
|
|
||||||
if (ev.Right) {
|
if (ev.Right) {
|
||||||
if (!Self.IsAnimating()) {
|
if (!Self.IsAnimating()) {
|
||||||
Self.PlayAnimation("walk-right", null);
|
Self.PlayAnimation("walk-right", null);
|
||||||
}
|
}
|
||||||
Vx = playerSpeed;
|
|
||||||
} else if (ev.Left) {
|
} else if (ev.Left) {
|
||||||
if (!Self.IsAnimating()) {
|
if (!Self.IsAnimating()) {
|
||||||
Self.PlayAnimation("walk-left", null);
|
Self.PlayAnimation("walk-left", null);
|
||||||
}
|
}
|
||||||
Vx = -playerSpeed;
|
|
||||||
} else {
|
} else {
|
||||||
Self.StopAnimation();
|
Self.StopAnimation();
|
||||||
animating = false;
|
animating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Self.SetVelocity(Point(Vx, Vy));
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,5 +91,5 @@ objects
|
||||||
onoff
|
onoff
|
||||||
warpdoor
|
warpdoor
|
||||||
doodad edit-doodad -quiet -lock -author "Noah" ../../assets/doodads/*.doodad
|
doodad edit-doodad -quiet -lock -author "Noah" ../../assets/doodads/*.doodad
|
||||||
doodad edit-doodad -hide ../../assets/doodads/azu-blu.doodad
|
doodad edit-doodad ../../assets/doodads/azu-blu.doodad
|
||||||
doodad edit-doodad -hide ../../assets/doodads/boy.doodad
|
doodad edit-doodad -hide ../../assets/doodads/boy.doodad
|
||||||
|
|
|
@ -4,6 +4,7 @@ ALL: build
|
||||||
build:
|
build:
|
||||||
# Start Flag
|
# Start Flag
|
||||||
doodad convert -t "Start Flag" start-flag.png start-flag.doodad
|
doodad convert -t "Start Flag" start-flag.png start-flag.doodad
|
||||||
|
doodad install-script start-flag.js start-flag.doodad
|
||||||
|
|
||||||
# Exit Flag
|
# Exit Flag
|
||||||
doodad convert -t "Exit Flag" exit-flag.png exit-flag.doodad
|
doodad convert -t "Exit Flag" exit-flag.png exit-flag.doodad
|
||||||
|
|
11
dev-assets/doodads/objects/start-flag.js
Normal file
11
dev-assets/doodads/objects/start-flag.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// Start Flag.
|
||||||
|
function main() {
|
||||||
|
Self.SetHitbox(22 + 16, 16, 75 - 16, 86);
|
||||||
|
|
||||||
|
// Linking a doodad to the Start Flag sets the
|
||||||
|
// player character. Destroy the original doodads.
|
||||||
|
var links = Self.GetLinks();
|
||||||
|
for (var i = 0; i < links.length; i++) {
|
||||||
|
links[i].Destroy();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user