Code edit (1 edits merged)
Please save this source code
User prompt
adapt generatePlatform() to take into account the platform width.. when platform is width is 1500, then the 450 offset is ok, but when platform is shorter then the gap is too big. Fix that
Code edit (1 edits merged)
Please save this source code
User prompt
now in Platform apply this rule for assets: if index < 5 => ground if index < 20 => ground1 if index < 30 => ground2 if index < 40 => ground3 if index < 50 => ground4 if index < 50 => ground5 else ground6
Code edit (3 edits merged)
Please save this source code
User prompt
in Platform, for index > 5; select between ground1 to ground3
User prompt
in platform class, when index is > 5 select randomly between asset ground1 and ground2
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
from 20th jump, when gameSpeed is high it seems the jump height isn't enough... Please fix but don't alter current begining settings because they are ok; only adapt high speed cases (globalSpeed ~= -14)
User prompt
when gameSpeed is high it seems the jump height isn't enough to reach platforms or gravity is too high. Please fix.
Code edit (10 edits merged)
Please save this source code
User prompt
update countdown to count jumps instead of platforms
Code edit (1 edits merged)
Please save this source code
User prompt
add platform0 to 4 into activePlatforms
Code edit (1 edits merged)
Please save this source code
User prompt
platforms platform0 to platform3 should be taken into account for the PlatformManager.platformCount
User prompt
add a global index property to every platform
User prompt
complete the platform counter to start counting platforms ater first jump
Code edit (5 edits merged)
Please save this source code
User prompt
start counting from platform 3
User prompt
update the Countdown to create a passed platforms counter instead of Countdown. Keep the current style and animations.
Code edit (3 edits merged)
Please save this source code
User prompt
ok for the jump altitude, but the chicken doesn't fall fast enough when globalspeed is high that makes him jump too far
User prompt
When globalSpeed increase : jumps become too high and too far, they should be consitent
/**** * Plugins ****/ var facekit = LK.import("@upit/facekit.v1"); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Chicken = Container.expand(function () { var self = Container.call(this); self.failed = false; self.mouthClosedFlag = true; var tail = self.attachAsset('tail', { anchorX: 0.5, anchorY: 1, scaleX: 1, scaleY: 1 }); tail.x = -220; tail.y = -120; var paws = self.attachAsset('nyanCatPaws', { anchorX: 0.5, anchorY: 1, scaleX: 0.9 }); paws.x = 30; paws.y = 20; var chickenGraphics = self.attachAsset('nyanCatBody', { anchorX: 0.5, anchorY: 1, alpha: 1 }); var headIdle = self.attachAsset('nyanCatHeadIdle', { anchorX: 0.5, anchorY: 1, alpha: 1 }); var headOh = self.attachAsset('nyanCatHeadOh', { anchorX: 0.5, anchorY: 1, alpha: 0 }); var headSmile = self.attachAsset('nyanCatHeadSmile', { anchorX: 0.5, anchorY: 1, alpha: 0 }); var collisionElement = self.attachAsset('collisionElement', { anchorX: 0.5, anchorY: 0.5, width: chickenGraphics.width * 0.4, height: chickenGraphics.height * 0.2 }); headIdle.x = 180; headIdle.y = -100; headOh.x = 180; headOh.y = -100; headSmile.x = 180; headSmile.y = -100; collisionElement.alpha = 0; collisionElement.y = -30; chickenGraphics.y = 40; self.speed = 8; self.initialGlobalSpeed = typeof globalSpeed !== 'undefined' ? Math.abs(globalSpeed) : 10; self.baseJumpVelocity = -30; self.baseJumpHeight = 300; self.jumpHeight = self.baseJumpHeight; self.isJumping = true; self.jumpVelocity = 0; self.isOnPlatform = true; self.update = function () { self.y += self.jumpVelocity; if (self.failed) { return; } var gravityFactor = Math.abs(globalSpeed) / 8; self.jumpVelocity += 1 * gravityFactor; var maxFallSpeed = 30 * gravityFactor; if (self.jumpVelocity > maxFallSpeed) { self.jumpVelocity = maxFallSpeed; } if (self.isJumping && self.jumpVelocity < 0) { headIdle.alpha = 0; headOh.alpha = 0; headSmile.alpha = 1; } else if (targetPlatform && self.y > targetPlatform.y) { headIdle.alpha = 0; headOh.alpha = 1; headSmile.alpha = 0; } else { headIdle.alpha = 1; headOh.alpha = 0; headSmile.alpha = 0; } var targetPlatform = undefined; self.isOnPlatform = platforms.some(function (platform) { if (collisionElement.intersects(platform)) { if (self.y - platform.y < 100) { targetPlatform = platform; return true; } } }); if (!self.failed && self.y > 2400) { self.failed = true; xspeed = 0; LK.effects.flashScreen(0xff00FF, 100); headIdle.alpha = 0; headOh.alpha = 1; headSmile.alpha = 0; self.jumpVelocity = 0; LK.getSound('failed').play(); tween(headOh, { scaleY: 3, scaleX: 3 }, { duration: 500, easing: tween.easeOut }); tween(self, { y: 3000 }, { duration: 1600, easing: tween.easeOut, onFinish: function onFinish() { self.jumpVelocity = 20; } }); } if (self.isOnPlatform && self.jumpVelocity > 0) { self.y = targetPlatform.y + 70; if (self.isJumping) { chickenGraphics.scale.y = .8; chickenGraphics.scale.x = 1.2; tween(chickenGraphics, { scaleY: 1, scaleX: 1 }, { duration: 1000, easing: tween.elasticOut }); tween.stop(paws, { x: true }); paws.x = 0; animatePaws(); } self.isJumping = false; self.jumpVelocity = 0; } self.x = 2048 / 2; var speedScaleFactor = Math.min(Math.abs(globalSpeed / 8), 2.0); self.jumpHeight = self.baseJumpHeight * speedScaleFactor; }; function groove() { tween(self, { scaleX: 1.03, scaleY: 1.03 }, { duration: 300, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { onFinish: groove, duration: 300 }); } }); } groove(); self.jump = function (strength) { if (platforms[0].x > -1500) { return; } if (!self.isJumping && self.isOnPlatform && self.mouthClosedFlag) { self.isJumping = true; jumpCounter++; self.mouthClosedFlag = false; LK.getSound('jump').play(); if (countdown) { countdown.updateCount(jumpCounter); } var currentSpeed = typeof globalSpeed !== 'undefined' ? Math.abs(globalSpeed) : self.initialGlobalSpeed; var jumpScale = Math.sqrt(currentSpeed / self.initialGlobalSpeed); chicken.jumpVelocity = self.baseJumpVelocity * jumpScale; tween.stop(paws, { x: true }); tween(paws, { x: 0 }, { duration: 100 }); self.update(); } }; function animatePaws() { if (!self.isOnPlatform) { return; } tween(paws, { x: -10 }, { duration: 160, easing: tween.linear, onFinish: function onFinish() { tween(paws, { x: 30 }, { duration: 160, easing: tween.linear, onFinish: animatePaws }); } }); } return self; }); var Countdown = Container.expand(function () { var self = Container.call(this); var jumpCount = 0; var countdownTextShadow = new Text2("0", { size: 500, fill: 0x000000, weight: 800 }); var countdownText = new Text2("0", { size: 500, fill: 0xFFFFFF, weight: 800 }); countdownText.anchor.set(0.5, 0.5); countdownTextShadow.anchor.set(0.5, 0.5); self.addChild(countdownTextShadow); self.addChild(countdownText); self.x = 2048 / 2; self.y = 400; countdownTextShadow.x = 15; countdownTextShadow.y = 15; function tweenIt() { self.scale.set(1, 1); tween(self, { scaleX: .6, scaleY: .6 }, { duration: 300, easing: tween.bounceOut }); } self.updateCount = function (count) { if (jumpCount !== count) { jumpCount = count; countdownText.setText(jumpCount.toString()); countdownTextShadow.setText(jumpCount.toString()); tweenIt(); } }; tweenIt(); }); var DebugMarker = Container.expand(function () { var self = Container.call(this); var debugGraphics = self.attachAsset('debugMark', { anchorX: 0, anchorY: 0.5 }); debugGraphics.width = 1; self.update = function () { debugGraphics.width = facekit.mouthOpen ? 1000 : 100; debugGraphics.tint = facekit.mouthOpen ? 0x00ff00 : 0xff0000; }; return self; }); var DirtParticle = Container.expand(function () { var self = Container.call(this); var dirtGraphics = self.attachAsset('trail', { anchorX: 0.5, anchorY: 1 }); var speed = 2; var angle = 0; var scale = 1; self.livetime = 110; self.update = function () { self.livetime--; if (self.livetime < 0) { self.destroy(); return; } if (chicken.failed) { return; } if (self.x < -50) { self.destroy(); return; } self.x += Math.cos(angle) * speed; self.y += Math.sin(angle) * speed; }; }); var LargeBork = Container.expand(function () { var self = Container.call(this); self.moveMultiplier = 0; var largeBorkGraphicsChicken = self.attachAsset('NyanCat', { anchorX: 0.5, anchorY: 1, scaleX: -1 }); largeBorkGraphicsChicken.y = -300; var largeBorkGraphics = self.attachAsset('large_bork', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.moveMultiplier = xspeed * 6; self.x += globalSpeed * self.moveMultiplier; }; self.bork = function () { var speechBubbleLarge = new SpeechBubbleLarge(); var offset = Math.PI / 4 * Math.random() - Math.PI / 2 - Math.PI / 4; speechBubbleLarge.x = -360 + Math.cos(offset) * 300; speechBubbleLarge.y = -300 + Math.sin(offset) * 350; speechBubbleLarge.rotation = offset + Math.PI * 0.5 + .3; self.addChild(speechBubbleLarge); largeBorkGraphicsChicken.scale.y = 1.05; largeBorkGraphicsChicken.scale.x = -1.05; largeBorkGraphicsChicken.rotation = .2; tween(largeBorkGraphicsChicken, { scaleY: 1, scaleX: -1, rotation: 0 }, { duration: 1000, easing: tween.elasticOut }); }; }); var Particles = Container.expand(function () { var self = Container.call(this); self.moveMultiplier = 0; self.addDirtParticle = function (x, y) { var dirtParticle = new DirtParticle(); dirtParticle.x = x - self.x + 100; dirtParticle.y = y - 100; self.addChild(dirtParticle); }; self.update = function () { if (chicken.failed) { return; } self.moveMultiplier = xspeed * 6; self.x += globalSpeed * self.moveMultiplier; }; }); var Platform = Container.expand(function () { var self = Container.call(this); self.moveMultiplier = 1; self.lastX = 0; self.index = getNextPlatformIndex(); var groundGraphics = self.attachAsset('ground', { anchorX: 0, anchorY: 0 }); self.width = groundGraphics.width; self.update = function () { if (chicken.failed) { return; } self.moveMultiplier = xspeed * 6; self.x += globalSpeed * self.moveMultiplier; /*if (self.x < -self.width) { self.x += self.width + 2048 + Math.random() * 1000; }*/ }; }); var PlatformManager = Container.expand(function () { var self = Container.call(this); self.lastX = 0; self.platformGap = 1500; self.platformCount = 0; self.maxPlatforms = 10; self.activePlatforms = []; self.trackLastPlatform = function () { var lastX = 0; platforms.forEach(function (platform) { if (platform.x + platform.width > lastX) { lastX = platform.x + platform.width; } }); self.lastX = lastX; }; self.generatePlatform = function (x, y) { var platform = new Platform(); platform.x = x; platform.y = y; backgroundContainer.addChild(platform); platforms.push(platform); self.activePlatforms.push(platform); return platform; }; self.getRandomHeight = function () { var heights = [1600, 1800, 2000, 2200]; return heights[Math.floor(Math.random() * heights.length)]; }; self.update = function () { if (chicken.failed) { return; } self.trackLastPlatform(); if (self.activePlatforms.length < self.maxPlatforms) { var newX = self.lastX + 450; var newY = self.getRandomHeight(); var newPlatform = self.generatePlatform(newX, newY); self.platformCount++; } for (var i = self.activePlatforms.length - 1; i >= 0; i--) { var platform = self.activePlatforms[i]; platform.lastX = platform.x; if (platform.x + platform.width < -2000) { if (platforms.indexOf(platform) >= 5) { platforms.splice(platforms.indexOf(platform), 1); self.activePlatforms.splice(i, 1); platform.destroy(); } } } }; return self; }); var SpeechBubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.attachAsset('small_bork_speach', { anchorX: 0.8, anchorY: 1 }); self.y -= 50; self.alpha = 1; self.update = function () { self.y -= 1; self.alpha -= 0.01; if (self.alpha <= 0) { self.destroy(); } }; tween(self, { alpha: 0 }, { duration: 2000, easing: tween.linear, onFinish: function onFinish() { self.destroy(); } }); }); var SpeechBubbleLarge = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.attachAsset('large_bork_speach', { anchorX: 0.2, anchorY: 1 }); self.y -= 50; self.alpha = 1; self.scale.set(0, 0); tween(self, { scaleX: 1, scaleY: 1 }, { duration: 600, easing: tween.elasticOut }); LK.setTimeout(function () { tween(self, { alpha: 0, y: self.y - 100 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { self.destroy(); } }); }, 800); }); var Spikes = Container.expand(function () { var self = Container.call(this); self.moveMultiplier = 0; var spikesGraphics = self.attachAsset('spikes', { anchorX: 0, anchorY: 0 }); self.update = function () { self.moveMultiplier = xspeed * 6; self.x += globalSpeed * self.moveMultiplier; }; }); var StartFlag = Container.expand(function () { var self = Container.call(this); self.moveMultiplier = 0; var flagGraphics = self.attachAsset('start', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.moveMultiplier = xspeed * 6; self.x += globalSpeed * self.moveMultiplier; if (self.x < -500) { self.destroy(); startFlag = null; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var globalNextPlatformIndex = 0; var jumpCounter = 0; function getNextPlatformIndex() { globalNextPlatformIndex++; return globalNextPlatformIndex; } var volumeLabel = new Text2('Volume: 0', { size: 50, fill: 0xFFFFFF }); volumeLabel.anchor.set(1, 1); volumeLabel.alpha = .3; LK.gui.bottomRight.addChild(volumeLabel); var pitchLabel = new Text2('Mouth: closed', { size: 50, fill: 0xFFFFFF }); pitchLabel.anchor.set(0, 1); pitchLabel.alpha = .3; LK.gui.bottomLeft.addChild(pitchLabel); function addPlatformAt(x, y) { var platform = backgroundContainer.addChild(new Platform()); platform.x = x; platform.y = y; platforms.push(platform); return platform; } var backgroundContainer = new Container(); var foregroundContainer = new Container(); game.addChild(backgroundContainer); game.addChild(foregroundContainer); var xspeed = 0; var globalSpeed = -5; var platforms = []; var platform0 = addPlatformAt(1000, 2200); var platform1 = addPlatformAt(2450, 2200); var platform2 = addPlatformAt(3000 + 1450, 2200); var platform3 = addPlatformAt(5000 + 1450, 1800); var platform4 = addPlatformAt(7000 + 1450, 2200); var platformRef = platforms[0]; var chickenBork = platformRef.attachAsset('NyanCat', { anchorX: 0.5, anchorY: 1, x: platformRef.width / 2, y: -1300 }); var smallBork = platformRef.attachAsset('small_bork', { anchorX: 0.5, anchorY: 0.5, x: platformRef.width / 2, y: -1024 }); var platform2 = platforms[1]; var largeBork = backgroundContainer.addChild(new LargeBork()); largeBork.x = platform2.x + platform2.width + 250; largeBork.y = platform2.y - 1024; var lastPlatform = addPlatformAt(9000 + 1500, 1600); var trophy = lastPlatform.attachAsset('trophy', { anchorX: 0.5, anchorY: 0.5, x: lastPlatform.width / 2, y: -100 }); trophy.visible = false; var boffset = 0; var trailStarted = false; var trailWave = false; function doSmallBork() { var speechBubble = new SpeechBubble(); var offset = Math.PI / 2 * Math.random() - Math.PI / 2 - Math.PI / 4; speechBubble.x = smallBork.x + 400 + Math.cos(offset) * 300; speechBubble.y = smallBork.y - 400 + Math.sin(offset) * 300; speechBubble.rotation = offset + Math.PI * 0.5 - .1; platformRef.addChildAt(speechBubble, 0); chickenBork.scale.y = 1.05; chickenBork.scale.x = 1.05; tween(chickenBork, { scaleY: 1, scaleX: 1 }, { duration: 800, easing: tween.elasticOut }); largeBork.bork(); if (platform2.x > -1024) { LK.setTimeout(doSmallBork, 1200 + Math.random() * 300); } } doSmallBork(); var particles = backgroundContainer.addChild(new Particles()); var chicken = foregroundContainer.addChild(new Chicken()); Platform.prototype.chicken = chicken; chicken.x = 2048 / 2; chicken.y = 2200; var startFlag = foregroundContainer.addChild(new StartFlag()); startFlag.x = platform2.x + 130; startFlag.y = platform2.y - 140; var platformManager = backgroundContainer.addChild(new PlatformManager()); platformManager.platformCount = 0; platformManager.activePlatforms.push(platform0, platform1, platform2, platform3, platform4); var pitchDebugMarker = backgroundContainer.addChild(new DebugMarker()); pitchDebugMarker.x = 50; pitchDebugMarker.y = 2600; pitchDebugMarker.alpha = 0.7; var countdown = foregroundContainer.addChild(new Countdown()); countdown.alpha = 0; countdown.updateCount(0); game.update = function () { if (chicken.y > 5000) { LK.effects.flashScreen(0xff0000, 3000); LK.showGameOver(); } if (chicken.failed) { return; } if (!chicken.isJumping) { xspeed += .5; xspeed *= .4; if (facekit.mouthOpen) { chicken.jump(1.0); } else if (!facekit.mouthOpen && !chicken.mouthClosedFlag) { chicken.mouthClosedFlag = true; } } if (trailStarted) { particles.addDirtParticle(chicken.x - chicken.width / 2 + 20 * (Math.abs(globalSpeed) / 5), chicken.y + (trailWave ? -10 : 0)); } if (startFlag) { pitchLabel.setText('Start: ' + startFlag.x + ' / ' + startFlag.y); } }; LK.playMusic('nyanLikeMusic'); LK.setTimeout(function () { trailStarted = true; }, 300); LK.setTimeout(function () { tween(countdown, { alpha: 1 }, { duration: 400 }); }, 6000); LK.setInterval(function () { trailWave = !trailWave; }, 300); LK.setInterval(function () { xspeed *= 1.07; globalSpeed *= 1.07; pitchLabel.setText('Speed boost! : ' + globalSpeed); }, 3000);
===================================================================
--- original.js
+++ change.js
@@ -6,13 +6,20 @@
/****
* Classes
****/
-//<Write imports for supported plugins here>
var Chicken = Container.expand(function () {
var self = Container.call(this);
self.failed = false;
self.mouthClosedFlag = true;
+ var tail = self.attachAsset('tail', {
+ anchorX: 0.5,
+ anchorY: 1,
+ scaleX: 1,
+ scaleY: 1
+ });
+ tail.x = -220;
+ tail.y = -120;
var paws = self.attachAsset('nyanCatPaws', {
anchorX: 0.5,
anchorY: 1,
scaleX: 0.9
@@ -23,12 +30,8 @@
anchorX: 0.5,
anchorY: 1,
alpha: 1
});
- // var chickenGraphics = self.attachAsset('nyanCatBodySmartphone', {
- // anchorX: 0.5,
- // anchorY: 1
- // });
var headIdle = self.attachAsset('nyanCatHeadIdle', {
anchorX: 0.5,
anchorY: 1,
alpha: 1
@@ -58,13 +61,11 @@
collisionElement.alpha = 0;
collisionElement.y = -30;
chickenGraphics.y = 40;
self.speed = 8;
- // --- Store initial values for adaptive jump (as instance properties) ---
self.initialGlobalSpeed = typeof globalSpeed !== 'undefined' ? Math.abs(globalSpeed) : 10;
- self.baseJumpVelocity = -40;
- // Base jump height that will scale with globalSpeed
- self.baseJumpHeight = 400;
+ self.baseJumpVelocity = -30;
+ self.baseJumpHeight = 300;
self.jumpHeight = self.baseJumpHeight;
self.isJumping = true;
self.jumpVelocity = 0;
self.isOnPlatform = true;
@@ -72,18 +73,14 @@
self.y += self.jumpVelocity;
if (self.failed) {
return;
}
- // Make gravity and fall speed scale with globalSpeed for consistent jumps
var gravityFactor = Math.abs(globalSpeed) / 8;
- // Scale the gravity with globalSpeed to make falls faster at higher speeds
self.jumpVelocity += 1 * gravityFactor;
- // Scale the maximum fall speed with globalSpeed
var maxFallSpeed = 30 * gravityFactor;
if (self.jumpVelocity > maxFallSpeed) {
self.jumpVelocity = maxFallSpeed;
}
- // Show nyanCatHeadSmile during initial jump phase (negative velocity = going up)
if (self.isJumping && self.jumpVelocity < 0) {
headIdle.alpha = 0;
headOh.alpha = 0;
headSmile.alpha = 1;
@@ -112,9 +109,8 @@
headIdle.alpha = 0;
headOh.alpha = 1;
headSmile.alpha = 0;
self.jumpVelocity = 0;
- // Play cat failing sound when fails
LK.getSound('failed').play();
tween(headOh, {
scaleY: 3,
scaleX: 3
@@ -134,11 +130,8 @@
}
if (self.isOnPlatform && self.jumpVelocity > 0) {
self.y = targetPlatform.y + 70;
if (self.isJumping) {
- // for (var a = 0; a < 30; a++) {
- // particles.addDirtParticle(chicken.x, chicken.y);
- // }
chickenGraphics.scale.y = .8;
chickenGraphics.scale.x = 1.2;
tween(chickenGraphics, {
scaleY: 1,
@@ -146,9 +139,8 @@
}, {
duration: 1000,
easing: tween.elasticOut
});
- // Reset paw position and restart animation when landing
tween.stop(paws, {
x: true
});
paws.x = 0;
@@ -157,15 +149,12 @@
self.isJumping = false;
self.jumpVelocity = 0;
}
self.x = 2048 / 2;
- // Adjust jump height based on game speed to maintain jump quality
- // Scale jump height for higher speeds to ensure consistent gameplay
var speedScaleFactor = Math.min(Math.abs(globalSpeed / 8), 2.0);
self.jumpHeight = self.baseJumpHeight * speedScaleFactor;
};
function groove() {
- // Use consistent animation timing for groove effect
tween(self, {
scaleX: 1.03,
scaleY: 1.03
}, {
@@ -185,28 +174,19 @@
self.jump = function (strength) {
if (platforms[0].x > -1500) {
return;
}
- // self.isOnPlatform = platforms.some(function (platform) {
- // if (collisionElement.intersects(platform)) {
- // return self.y - platform.y < 100;
- // }
- // });
if (!self.isJumping && self.isOnPlatform && self.mouthClosedFlag) {
self.isJumping = true;
jumpCounter++;
self.mouthClosedFlag = false;
- // Play jump sound
LK.getSound('jump').play();
- // Increment jump counter if platformCounter exists
if (countdown) {
countdown.updateCount(jumpCounter);
}
- // Adaptive jump velocity based on globalSpeed (using instance properties)
var currentSpeed = typeof globalSpeed !== 'undefined' ? Math.abs(globalSpeed) : self.initialGlobalSpeed;
var jumpScale = Math.sqrt(currentSpeed / self.initialGlobalSpeed);
chicken.jumpVelocity = self.baseJumpVelocity * jumpScale;
- // Stop paw animation during jump with a quick tween back to center
tween.stop(paws, {
x: true
});
tween(paws, {
@@ -216,14 +196,12 @@
});
self.update();
}
};
- // Function to animate paws with alternating movements
function animatePaws() {
if (!self.isOnPlatform) {
return;
}
- // Use consistent animation timing regardless of game speed
tween(paws, {
x: -10
}, {
duration: 160,
@@ -300,10 +278,10 @@
var dirtGraphics = self.attachAsset('trail', {
anchorX: 0.5,
anchorY: 1
});
- var speed = 2; //Math.random() * 3;
- var angle = 0; //-Math.random() * Math.PI;
+ var speed = 2;
+ var angle = 0;
var scale = 1;
self.livetime = 110;
self.update = function () {
self.livetime--;
@@ -341,9 +319,9 @@
};
self.bork = function () {
var speechBubbleLarge = new SpeechBubbleLarge();
var offset = Math.PI / 4 * Math.random() - Math.PI / 2 - Math.PI / 4;
- speechBubbleLarge.x = -330 + Math.cos(offset) * 300;
+ speechBubbleLarge.x = -360 + Math.cos(offset) * 300;
speechBubbleLarge.y = -300 + Math.sin(offset) * 350;
speechBubbleLarge.rotation = offset + Math.PI * 0.5 + .3;
self.addChild(speechBubbleLarge);
largeBorkGraphicsChicken.scale.y = 1.05;
@@ -363,9 +341,9 @@
var self = Container.call(this);
self.moveMultiplier = 0;
self.addDirtParticle = function (x, y) {
var dirtParticle = new DirtParticle();
- dirtParticle.x = x - self.x + 100; // + Math.random() * 130 - 40;
+ dirtParticle.x = x - self.x + 100;
dirtParticle.y = y - 100;
self.addChild(dirtParticle);
};
self.update = function () {
@@ -378,10 +356,10 @@
});
var Platform = Container.expand(function () {
var self = Container.call(this);
self.moveMultiplier = 1;
- self.lastX = 0; // Track last X position for platform passing detection
- self.index = getNextPlatformIndex(); // Global index property for platform identification
+ self.lastX = 0;
+ self.index = getNextPlatformIndex();
var groundGraphics = self.attachAsset('ground', {
anchorX: 0,
anchorY: 0
});
@@ -403,9 +381,8 @@
self.platformGap = 1500;
self.platformCount = 0;
self.maxPlatforms = 10;
self.activePlatforms = [];
- // Track the last platform x position
self.trackLastPlatform = function () {
var lastX = 0;
platforms.forEach(function (platform) {
if (platform.x + platform.width > lastX) {
@@ -413,9 +390,8 @@
}
});
self.lastX = lastX;
};
- // Generate a platform at the given coordinates
self.generatePlatform = function (x, y) {
var platform = new Platform();
platform.x = x;
platform.y = y;
@@ -423,42 +399,27 @@
platforms.push(platform);
self.activePlatforms.push(platform);
return platform;
};
- // Create random platform heights
self.getRandomHeight = function () {
var heights = [1600, 1800, 2000, 2200];
return heights[Math.floor(Math.random() * heights.length)];
};
- // Check if we need to add more platforms
self.update = function () {
if (chicken.failed) {
return;
}
- // Calculate the rightmost platform edge
self.trackLastPlatform();
- // Generate new platforms if we're below our maximum
if (self.activePlatforms.length < self.maxPlatforms) {
- // Ensure distance between platforms is exactly 450 units
var newX = self.lastX + 450;
var newY = self.getRandomHeight();
var newPlatform = self.generatePlatform(newX, newY);
self.platformCount++;
- // Add spikes to some platforms for challenge
- // if (self.platformCount % 3 == 0) {
- // var newSpikes = new Spikes();
- // newSpikes.x = newPlatform.x;
- // newSpikes.y = newPlatform.y - Math.random() * 500 - 1000;
- // backgroundContainer.addChild(newSpikes);
- // }
}
- // Clean up platforms that are far behind
for (var i = self.activePlatforms.length - 1; i >= 0; i--) {
var platform = self.activePlatforms[i];
- // Still track lastX for collision detection purposes
platform.lastX = platform.x;
if (platform.x + platform.width < -2000) {
- // Don't remove the original platforms (the first 5)
if (platforms.indexOf(platform) >= 5) {
platforms.splice(platforms.indexOf(platform), 1);
self.activePlatforms.splice(i, 1);
platform.destroy();
@@ -583,14 +544,13 @@
pitchLabel.alpha = .3;
LK.gui.bottomLeft.addChild(pitchLabel);
function addPlatformAt(x, y) {
var platform = backgroundContainer.addChild(new Platform());
- platform.x = x; //i * 1900 + i * Math.random() * 1000;
+ platform.x = x;
platform.y = y;
platforms.push(platform);
return platform;
}
-// Create background and foreground containers
var backgroundContainer = new Container();
var foregroundContainer = new Container();
game.addChild(backgroundContainer);
game.addChild(foregroundContainer);
@@ -600,11 +560,8 @@
var platform0 = addPlatformAt(1000, 2200);
var platform1 = addPlatformAt(2450, 2200);
var platform2 = addPlatformAt(3000 + 1450, 2200);
var platform3 = addPlatformAt(5000 + 1450, 1800);
-// var spikes = backgroundContainer.addChild(new Spikes());
-// spikes.x = platform3.x;
-// spikes.y = platform3.y - 1500;
var platform4 = addPlatformAt(7000 + 1450, 2200);
var platformRef = platforms[0];
var chickenBork = platformRef.attachAsset('NyanCat', {
anchorX: 0.5,
@@ -628,9 +585,9 @@
anchorY: 0.5,
x: lastPlatform.width / 2,
y: -100
});
-trophy.visible = false; // TEMP DEBUG
+trophy.visible = false;
var boffset = 0;
var trailStarted = false;
var trailWave = false;
function doSmallBork() {
@@ -654,31 +611,25 @@
LK.setTimeout(doSmallBork, 1200 + Math.random() * 300);
}
}
doSmallBork();
-//<Write imports for supported plugins here>
var particles = backgroundContainer.addChild(new Particles());
var chicken = foregroundContainer.addChild(new Chicken());
Platform.prototype.chicken = chicken;
chicken.x = 2048 / 2;
chicken.y = 2200;
var startFlag = foregroundContainer.addChild(new StartFlag());
startFlag.x = platform2.x + 130;
startFlag.y = platform2.y - 140;
-// Initialize platform manager
var platformManager = backgroundContainer.addChild(new PlatformManager());
-// Set initial platformCount to 5 to account for platform0 through platform4
platformManager.platformCount = 0;
-// Add initial platforms to activePlatforms list
platformManager.activePlatforms.push(platform0, platform1, platform2, platform3, platform4);
var pitchDebugMarker = backgroundContainer.addChild(new DebugMarker());
pitchDebugMarker.x = 50;
pitchDebugMarker.y = 2600;
pitchDebugMarker.alpha = 0.7;
-// Initialize jump counter
var countdown = foregroundContainer.addChild(new Countdown());
countdown.alpha = 0;
-// Initialize with zero jumps
countdown.updateCount(0);
game.update = function () {
if (chicken.y > 5000) {
LK.effects.flashScreen(0xff0000, 3000);
@@ -695,18 +646,11 @@
} else if (!facekit.mouthOpen && !chicken.mouthClosedFlag) {
chicken.mouthClosedFlag = true;
}
}
- // if (chicken.intersects(spikes)) {
- // LK.effects.flashScreen(0xff0000, 3000);
- // LK.showGameOver();
- // }
- // Update platform manager to handle creating new platforms
- //platformManager.update();
if (trailStarted) {
particles.addDirtParticle(chicken.x - chicken.width / 2 + 20 * (Math.abs(globalSpeed) / 5), chicken.y + (trailWave ? -10 : 0));
}
- //pitchLabel.setText('Mouth: ' + (facekit.mouthOpen ? 'OPEN' : 'closed'));
if (startFlag) {
pitchLabel.setText('Start: ' + startFlag.x + ' / ' + startFlag.y);
}
};
@@ -724,9 +668,8 @@
LK.setInterval(function () {
trailWave = !trailWave;
}, 300);
LK.setInterval(function () {
- // Speed up game
xspeed *= 1.07;
globalSpeed *= 1.07;
pitchLabel.setText('Speed boost! : ' + globalSpeed);
}, 3000);
\ No newline at end of file
Row of Spikes. Computer Game Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
photo-realistic
a smartphone (black screen)
A simple wide hand-drawn symmetrical ribbon banners. The banner text reads “Open WIDE to jump!” in playful, cartoonish black lettering. The ribbon is warm beige parchment. Each side ends with simple curved, scroll-like ribbon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A simple wide hand-drawn symmetrical ribbon banners. The banner text reads “Keep mouth closed” in playful, cartoonish black lettering. The ribbon is warm beige parchment. Each side ends with simple curved, scroll-like ribbon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Simple cartoon speech bubble with closed lips icon and lowercase lettering 'mmm...'. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Simple cartoon speech bubble with big open mouth icon and uppercase lettering 'MIAW!'. Bubble tail on the right. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
lateral view of a flat cake in rectangular platform shape for a platformer game. In-Game asset. 2d. High contrast. No shadows
lateral view of a flat cake in rectangular platform shape for a platformer game. In-Game asset. 2d. High contrast. No shadows
lateral view of a flat rainbow cake in rectangular platform shape for a platformer game. In-Game asset. 2d. High contrast. No shadows
photo of a cucumber meme
open cardboard box. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows