Animations for Thief + No More Moonwalking
* Adds walking animations for the Thief. * Mobile doodads no longer moonwalk: their A.I. used to wait for the animation to finish before setting the appropriate animation, so when it changed directions it would "moonwalk" for a time. Their A.I. is now updated to cancel the animation if they change directions so to immediately play the correct animation.
|
@ -1,7 +1,8 @@
|
|||
// Azulian (Red and Blue)
|
||||
var playerSpeed = 12,
|
||||
animating = false,
|
||||
direction = "right";
|
||||
direction = "right",
|
||||
lastDirection = "right";
|
||||
|
||||
function setupAnimations(color) {
|
||||
var left = color === 'blue' ? 'blu-wl' : 'red-wl',
|
||||
|
@ -49,9 +50,17 @@ function main() {
|
|||
var Vx = parseFloat(playerSpeed * (direction === "left" ? -1 : 1));
|
||||
Self.SetVelocity(Vector(Vx, 0.0));
|
||||
|
||||
// If we changed directions, stop animating now so we can
|
||||
// turn around quickly without moonwalking.
|
||||
if (direction !== lastDirection) {
|
||||
Self.StopAnimation();
|
||||
}
|
||||
|
||||
if (!Self.IsAnimating()) {
|
||||
Self.PlayAnimation("walk-" + direction, null);
|
||||
}
|
||||
|
||||
lastDirection = direction;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ function main() {
|
|||
var Vx = Vy = 0;
|
||||
var altitude = Self.Position().Y; // original height in the level
|
||||
|
||||
var direction = "left";
|
||||
var direction = "left",
|
||||
lastDirection = "left";
|
||||
var states = {
|
||||
flying: 0,
|
||||
diving: 1,
|
||||
|
@ -51,9 +52,17 @@ function main() {
|
|||
var Vx = parseFloat(speed * (direction === "left" ? -1 : 1));
|
||||
Self.SetVelocity(Vector(Vx, 0.0));
|
||||
|
||||
// If we changed directions, stop animating now so we can
|
||||
// turn around quickly without moonwalking.
|
||||
if (direction !== lastDirection) {
|
||||
Self.StopAnimation();
|
||||
}
|
||||
|
||||
if (!Self.IsAnimating()) {
|
||||
Self.PlayAnimation("fly-" + direction, null);
|
||||
}
|
||||
|
||||
lastDirection = direction;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ ALL: build
|
|||
.PHONY: build
|
||||
build:
|
||||
doodad convert -t "Thief" stand-right.png stand-left.png \
|
||||
walk-right-{1,2,3}.png walk-left-{1,2,3}.png \
|
||||
thief.doodad
|
||||
doodad install-script thief.js thief.doodad
|
||||
|
||||
|
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
@ -5,8 +5,8 @@ function main() {
|
|||
Self.SetGravity(true);
|
||||
Self.SetInventory(true);
|
||||
Self.SetHitbox(0, 0, 32, 58);
|
||||
Self.AddAnimation("walk-left", 200, ["stand-left"]); //, "walk-left-1", "walk-left-2", "walk-left-3", "walk-left-2", "walk-left-1"]);
|
||||
Self.AddAnimation("walk-right", 200, ["stand-right"]); //, "walk-right-1", "walk-right-2", "walk-right-3", "walk-right-2", "walk-right-1"]);
|
||||
Self.AddAnimation("walk-left", 200, ["stand-left", "walk-left-1", "walk-left-2", "walk-left-3", "walk-left-2", "walk-left-1"]);
|
||||
Self.AddAnimation("walk-right", 200, ["stand-right", "walk-right-1", "walk-right-2", "walk-right-3", "walk-right-2", "walk-right-1"]);
|
||||
|
||||
// All thieves can steal items.
|
||||
stealable();
|
||||
|
@ -71,6 +71,7 @@ function ai() {
|
|||
var Vx = Vy = 0.0,
|
||||
playerSpeed = 4,
|
||||
direction = "right",
|
||||
lastDirection = "right",
|
||||
lastSampledX = 0,
|
||||
sampleTick = 0,
|
||||
sampleRate = 2;
|
||||
|
@ -89,8 +90,17 @@ function ai() {
|
|||
Vx = parseFloat(playerSpeed * (direction === "left" ? -1 : 1));
|
||||
Self.SetVelocity(Vector(Vx, Vy));
|
||||
|
||||
// If we changed directions, stop animating now so we can
|
||||
// turn around quickly without moonwalking.
|
||||
if (direction !== lastDirection) {
|
||||
Self.StopAnimation();
|
||||
}
|
||||
|
||||
if (!Self.IsAnimating()) {
|
||||
Self.PlayAnimation("walk-" + direction, null);
|
||||
}
|
||||
|
||||
lastDirection = direction;
|
||||
}, 100);
|
||||
}
|
||||
|
||||
|
|
BIN
dev-assets/doodads/thief/walk-left-1.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
dev-assets/doodads/thief/walk-left-2.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
dev-assets/doodads/thief/walk-left-3.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
dev-assets/doodads/thief/walk-right-1.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
dev-assets/doodads/thief/walk-right-2.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
dev-assets/doodads/thief/walk-right-3.png
Normal file
After Width: | Height: | Size: 1.5 KiB |