Swimming Physics and Bubble Pattern
Water pixels finally do something other than turn your character blue! * When the player character is "wet" (touching water pixels, and so appearing in a blue mask), water physics apply: gravity is slower, your jump height is halved, but you get infinite jumps to swim higher in the water. * Holding the jump key under water will incur a short delay between jumps, so that you don't just fly straight up to the surface. Tap the jump button to move up quicker, you can spam it all you want. Azulians are also able to handle being under water: * They'll sink to the bottom and keep walking back and forth normally. * If you are above them and noticed, they'll jump (swim) up towards you, aware of the water and it jumps like you do. * The Blue Azulian has the poorest vertical aggro range so it isn't a very good swimmer. The White Azulian is very good at navigating water as it can pursue the player from the furthest distance of them all. Changes to the editor: * New brush pattern added: bubbles.png * It's the default pattern now for the "water" color of all of the built-in palettes instead of ink.png * A repeating pattern of bubbles carved out showing the level wallpaper. * The old "Bubbles (circles.png)" is renamed "Circles" * The last scroll position is saved with the Level file, so when you reload the level later it's scrolled at where you left it.
This commit is contained in:
parent
4f5ea15e46
commit
7005786a31
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
const color = Self.GetTag("color");
|
const color = Self.GetTag("color");
|
||||||
var playerSpeed = color === 'blue' ? 2 : 4,
|
var playerSpeed = color === 'blue' ? 2 : 4,
|
||||||
|
swimSpeed = playerSpeed * 0.4,
|
||||||
aggroX = 250, // X/Y distance sensitivity from player
|
aggroX = 250, // X/Y distance sensitivity from player
|
||||||
aggroY = color === 'blue' ? 100 : 200,
|
aggroY = color === 'blue' ? 100 : 200,
|
||||||
jumpSpeed = color === 'blue' ? 14 : 18,
|
jumpSpeed = color === 'blue' ? 14 : 18,
|
||||||
|
swimJumpSpeed = jumpSpeed * 0.4,
|
||||||
animating = false,
|
animating = false,
|
||||||
direction = "right",
|
direction = "right",
|
||||||
lastDirection = "right";
|
lastDirection = "right";
|
||||||
|
@ -14,7 +16,9 @@ if (color === 'white') {
|
||||||
aggroX = 1000;
|
aggroX = 1000;
|
||||||
aggroY = 400;
|
aggroY = 400;
|
||||||
playerSpeed = 8;
|
playerSpeed = 8;
|
||||||
|
swimSpeed = playerSpeed * 0.4;
|
||||||
jumpSpeed = 20;
|
jumpSpeed = 20;
|
||||||
|
swimJumpSpeed = jumpSpeed * 0.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupAnimations(color) {
|
function setupAnimations(color) {
|
||||||
|
@ -30,6 +34,9 @@ function setupAnimations(color) {
|
||||||
function main() {
|
function main() {
|
||||||
playerSpeed = color === 'blue' ? 2 : 4;
|
playerSpeed = color === 'blue' ? 2 : 4;
|
||||||
|
|
||||||
|
let swimJumpCooldownTick = 0, // minimum Game Tick before we can jump while swimming
|
||||||
|
swimJumpCooldown = 10; // CONFIG: delta of ticks between jumps while swimming
|
||||||
|
|
||||||
Self.SetMobile(true);
|
Self.SetMobile(true);
|
||||||
Self.SetGravity(true);
|
Self.SetGravity(true);
|
||||||
Self.SetInventory(true);
|
Self.SetInventory(true);
|
||||||
|
@ -95,8 +102,25 @@ function main() {
|
||||||
sampleTick++;
|
sampleTick++;
|
||||||
}
|
}
|
||||||
|
|
||||||
let Vx = parseFloat(playerSpeed * (direction === "left" ? -1 : 1)),
|
// Handle being underwater.
|
||||||
Vy = jump && Self.Grounded() ? parseFloat(-jumpSpeed) : Self.GetVelocity().Y;
|
let canJump = Self.Grounded();
|
||||||
|
if (Self.IsWet()) {
|
||||||
|
let tick = GetTick();
|
||||||
|
if (tick > swimJumpCooldownTick) {
|
||||||
|
canJump = true;
|
||||||
|
swimJumpCooldownTick = tick + swimJumpCooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// How speedy would our movement and jump be?
|
||||||
|
let xspeed = playerSpeed, yspeed = jumpSpeed;
|
||||||
|
if (Self.IsWet()) {
|
||||||
|
xspeed = swimSpeed;
|
||||||
|
yspeed = swimJumpSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
let Vx = parseFloat(xspeed * (direction === "left" ? -1 : 1)),
|
||||||
|
Vy = jump && canJump ? parseFloat(-yspeed) : Self.GetVelocity().Y;
|
||||||
Self.SetVelocity(Vector(Vx, Vy));
|
Self.SetVelocity(Vector(Vx, Vy));
|
||||||
|
|
||||||
// If we changed directions, stop animating now so we can
|
// If we changed directions, stop animating now so we can
|
||||||
|
|
Loading…
Reference in New Issue
Block a user