Code edit (10 edits merged)
Please save this source code
User prompt
if chicken y > targetPlatform.y show headOh
Code edit (3 edits merged)
Please save this source code
User prompt
animate walk with a looping move of the paws back and forth ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'undefined is not an object (evaluating 'headIdle.x = 0')' in or related to this line: 'headIdle.x = 0;' Line Number: 44
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
show nyanCatHeadSmile during 1st jump phase
User prompt
particles (trail) should be behind body
Code edit (14 edits merged)
Please save this source code
User prompt
in Chicken class, replace NyanCat by NyanCatBody and add new head assets with alpha 0
Code edit (1 edits merged)
Please save this source code
User prompt
use trail asset for DirtParticle
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: x' in or related to this line: 'if (x < -50) {' Line Number: 192
User prompt
Please fix the bug: 'ReferenceError: Can't find variable: x' in or related to this line: 'if (x < -50) {' Line Number: 192
Code edit (5 edits merged)
Please save this source code
User prompt
use trail asset for DirtParticle
User prompt
use trail asset for DirtParticle
User prompt
make trail move to the left
Code edit (1 edits merged)
Please save this source code
User prompt
Ajoute une trail en créant un trail manager pour cela
User prompt
Accélère un peu la vitesse horizontale du chat
User prompt
Fais sauter le chat un peu plus haut
/**** * Plugins ****/ var facekit = LK.import("@upit/facekit.v1"); var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ //<Write imports for supported plugins here> var Chicken = Container.expand(function () { var self = Container.call(this); var chickenGraphics = self.attachAsset('NyanCat', { anchorX: 0.5, anchorY: 1 }); var collisionElement = self.attachAsset('collisionElement', { anchorX: 0.5, anchorY: 0.5, width: chickenGraphics.width * 0.4, height: chickenGraphics.height * 0.2 }); collisionElement.alpha = 0; collisionElement.y = -30; chickenGraphics.y = 40; self.speed = 8; self.jumpHeight = 400; self.isJumping = true; self.jumpVelocity = 0; self.update = function () { self.y += self.jumpVelocity; self.jumpVelocity += 1; if (self.jumpVelocity > 30) { self.jumpVelocity = 30; } var targetPlatform = undefined; var isOnPlatform = platforms.some(function (platform) { if (collisionElement.intersects(platform)) { if (self.y - platform.y < 100) { targetPlatform = platform; return true; } } }); if (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, scaleX: 1 }, { duration: 1000, easing: tween.elasticOut }); } self.isJumping = false; self.jumpVelocity = 0; } self.x = 2048 / 2; }; 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; } var isOnPlatform = platforms.some(function (platform) { if (collisionElement.intersects(platform)) { return self.y - platform.y < 100; } }); if (!self.isJumping && isOnPlatform) { self.isJumping = true; for (var a = 0; a < 30; a++) { particles.addDirtParticle(chicken.x, chicken.y); } chicken.jumpVelocity = -40; self.update(); } }; }); var Countdown = Container.expand(function () { var self = Container.call(this); var currentNumber = 16; var countdownTextShadow = new Text2("GO!", { size: 500, fill: 0x000000, weight: 800 }); var countdownText = new Text2("GO!", { 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: .8, scaleY: .8 }, { duration: 400, easing: tween.bounceOut }); } var countdownInterval = LK.setInterval(function () { currentNumber--; if (currentNumber > 0) { countdownText.setText(currentNumber.toString()); countdownTextShadow.setText(currentNumber.toString()); } else { self.destroy(); LK.clearInterval(countdownInterval); LK.effects.flashScreen(0xff0000, 3000); LK.showGameOver(); } tweenIt(); }, 1000); 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('dirtparticle', { anchorX: 0.5, anchorY: 1 }); var speed = Math.random() * 3; var angle = -Math.random() * Math.PI; var scale = 1; self.update = function () { scale -= 0.02; self.scale.set(scale, scale); if (scale <= 0) { self.destroy(); } 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; self.moveSpeed = -5; var largeBorkGraphicsChicken = self.attachAsset('NyanCat', { anchorX: 0.5, anchorY: 1 }); largeBorkGraphicsChicken.y = -50; var largeBorkGraphics = self.attachAsset('large_bork', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.moveMultiplier = xspeed * 6; self.x += self.moveSpeed * self.moveMultiplier; }; self.bork = function () { var speechBubbleLarge = new SpeechBubbleLarge(); var offset = Math.PI / 4 * Math.random() - Math.PI / 2 - Math.PI / 4; speechBubbleLarge.x = -50 + Math.cos(offset) * 350; speechBubbleLarge.y = -100 + 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.moveSpeed = -5; self.addDirtParticle = function (x, y) { var dirtParticle = new DirtParticle(); dirtParticle.x = x - self.x + Math.random() * 130 - 40; dirtParticle.y = y + 90; self.addChild(dirtParticle); }; self.update = function () { self.moveMultiplier = xspeed * 6; self.x += self.moveSpeed * self.moveMultiplier; }; }); var Platform = Container.expand(function () { var self = Container.call(this); self.moveSpeed = -5; self.moveMultiplier = 1; var groundGraphics = self.attachAsset('ground', { anchorX: 0, anchorY: 0 }); self.width = groundGraphics.width; self.update = function () { self.moveMultiplier = xspeed * 6; self.x += self.moveSpeed * self.moveMultiplier; /*if (self.x < -self.width) { self.x += self.width + 2048 + Math.random() * 1000; }*/ }; }); 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: 800, 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; self.moveSpeed = -5; var spikesGraphics = self.attachAsset('spikes', { anchorX: 0, anchorY: 0 }); self.update = function () { self.moveMultiplier = xspeed * 6; self.x += self.moveSpeed * self.moveMultiplier; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ 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 = game.addChild(new Platform()); platform.x = x; //i * 1900 + i * Math.random() * 1000; platform.y = y; //2200; platforms.push(platform); return platform; } var xspeed = 0; var platforms = []; addPlatformAt(1000, 2200); addPlatformAt(2450, 2200); addPlatformAt(3000 + 1500, 2200); var platform3 = addPlatformAt(5000 + 1500, 1800); var spikes = game.addChild(new Spikes()); spikes.x = platform3.x; spikes.y = platform3.y - 1500; addPlatformAt(7000 + 1500, 2200); var platform1 = platforms[0]; var smallBork = platform1.attachAsset('small_bork', { anchorX: 0.5, anchorY: 0.5, x: platform1.width / 2 - 500, y: -550 }); var chickenBork = platform1.attachAsset('NyanCat', { anchorX: 0.5, anchorY: 1, x: smallBork.x - 50, y: -700 }); var platform2 = platforms[1]; var largeBork = game.addChild(new LargeBork()); largeBork.x = platform2.x + platform2.width + 250; largeBork.y = platform2.y - 500; var startFlag = platform2.attachAsset('start', { anchorX: 0.5, anchorY: 0.5, x: 130, y: -140 }); var lastPlatform = addPlatformAt(9000 + 1500, 1600); var trophy = lastPlatform.attachAsset('trophy', { anchorX: 0.5, anchorY: 0.5, x: lastPlatform.width / 2, y: -100 }); var boffset = 0; function doSmallBork() { var speechBubble = new SpeechBubble(); var offset = Math.PI / 2 * Math.random() - Math.PI / 2 - Math.PI / 4; speechBubble.x = smallBork.x - 25 + Math.cos(offset) * 150; speechBubble.y = smallBork.y - 150 + Math.sin(offset) * 150; speechBubble.rotation = offset + Math.PI * 0.5 - .1; platform1.addChild(speechBubble); LK.setTimeout(doSmallBork, 200 + Math.random() * 200); chickenBork.scale.y = 1.05; chickenBork.scale.x = 1.05; tween(chickenBork, { scaleY: 1, scaleX: 1 }, { duration: 800, easing: tween.elasticOut }); if (boffset++ % 3 == 0) { largeBork.bork(); } } doSmallBork(); //<Write imports for supported plugins here> var chicken = game.addChild(new Chicken()); var particles = game.addChild(new Particles()); Platform.prototype.chicken = chicken; chicken.x = 2048 / 2; chicken.y = 2200; var pitchDebugMarker = game.addChild(new DebugMarker()); pitchDebugMarker.x = 50; pitchDebugMarker.y = 2600; pitchDebugMarker.alpha = 0.7; var countdown; game.update = function () { if (platform1.x < -500 && !countdown) { countdown = game.addChild(new Countdown()); } if (!chicken.isJumping) { xspeed += .5; particles.addDirtParticle(chicken.x, chicken.y); xspeed *= .4; if (facekit.mouthOpen) { chicken.jump(1.0); } } if (chicken.y > 3000) { LK.effects.flashScreen(0xff0000, 3000); LK.showGameOver(); } if (chicken.intersects(spikes)) { LK.effects.flashScreen(0xff0000, 3000); LK.showGameOver(); } if (chicken.intersects(trophy)) { LK.showYouWin(); } volumeLabel.setText('Volume: ' + facekit.volume.toFixed(2)); pitchLabel.setText('Mouth: ' + (facekit.mouthOpen ? 'OPEN' : 'closed')); }; LK.playMusic('nyanLikeMusic');
===================================================================
--- original.js
+++ change.js
@@ -6,8 +6,9 @@
/****
* Classes
****/
+//<Write imports for supported plugins here>
var Chicken = Container.expand(function () {
var self = Container.call(this);
var chickenGraphics = self.attachAsset('NyanCat', {
anchorX: 0.5,
@@ -44,9 +45,9 @@
if (isOnPlatform && self.jumpVelocity > 0) {
self.y = targetPlatform.y + 70;
if (self.isJumping) {
for (var a = 0; a < 30; a++) {
- particles.addDirtParticle(chicken.x - chicken.width / 2, chicken.y);
+ particles.addDirtParticle(chicken.x, chicken.y);
}
chickenGraphics.scale.y = .8;
chickenGraphics.scale.x = 1.2;
tween(chickenGraphics, {
@@ -159,21 +160,23 @@
return self;
});
var DirtParticle = Container.expand(function () {
var self = Container.call(this);
- var dirtGraphics = self.attachAsset('trail', {
+ var dirtGraphics = self.attachAsset('dirtparticle', {
anchorX: 0.5,
anchorY: 1
});
var speed = Math.random() * 3;
var angle = -Math.random() * Math.PI;
+ var scale = 1;
self.update = function () {
- if (self.x < -50) {
+ scale -= 0.02;
+ self.scale.set(scale, scale);
+ if (scale <= 0) {
self.destroy();
- } else {
- self.x += Math.cos(angle) * speed;
- self.y += Math.sin(angle) * speed;
}
+ self.x += Math.cos(angle) * speed;
+ self.y += Math.sin(angle) * speed;
};
});
var LargeBork = Container.expand(function () {
var self = Container.call(this);
@@ -217,9 +220,9 @@
self.moveMultiplier = 0;
self.moveSpeed = -5;
self.addDirtParticle = function (x, y) {
var dirtParticle = new DirtParticle();
- dirtParticle.x = x;
+ dirtParticle.x = x - self.x + Math.random() * 130 - 40;
dirtParticle.y = y + 90;
self.addChild(dirtParticle);
};
self.update = function () {
@@ -238,12 +241,11 @@
self.width = groundGraphics.width;
self.update = function () {
self.moveMultiplier = xspeed * 6;
self.x += self.moveSpeed * self.moveMultiplier;
- // If the platform moves off screen to the left, reposition it to the right
- if (self.x < -self.width) {
+ /*if (self.x < -self.width) {
self.x += self.width + 2048 + Math.random() * 1000;
- }
+ }*/
};
});
var SpeechBubble = Container.expand(function () {
var self = Container.call(this);
@@ -311,54 +313,8 @@
self.moveMultiplier = xspeed * 6;
self.x += self.moveSpeed * self.moveMultiplier;
};
});
-var TrailManager = Container.expand(function () {
- var self = Container.call(this);
- var trailParticles = [];
- var spawnInterval = 5;
- var trailLength = 20;
- var frameCount = 0;
- self.update = function () {
- frameCount++;
- while (trailParticles.length > trailLength) {
- var oldParticle = trailParticles.shift();
- oldParticle.destroy();
- }
- if (frameCount % spawnInterval === 0 && chicken) {
- var particle = self.attachAsset('trail', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: 30,
- height: 200
- });
- particle.x = chicken.x - chicken.width / 2;
- particle.y = chicken.y;
- particle.moveSpeed = -5;
- particle.creationTime = Date.now();
- trailParticles.push(particle);
- tween(particle, {
- alpha: 0
- }, {
- duration: 1000,
- easing: tween.linear,
- onFinish: function onFinish() {
- var index = trailParticles.indexOf(particle);
- if (index !== -1) {
- trailParticles.splice(index, 1);
- }
- particle.destroy();
- }
- });
- }
- // Update all particles
- for (var i = 0; i < trailParticles.length; i++) {
- var trailParticle = trailParticles[i];
- trailParticle.x += trailParticle.moveSpeed * xspeed * 0.5;
- }
- };
- return self;
-});
/****
* Initialize Game
****/
@@ -384,10 +340,10 @@
pitchLabel.alpha = .3;
LK.gui.bottomLeft.addChild(pitchLabel);
function addPlatformAt(x, y) {
var platform = game.addChild(new Platform());
- platform.x = x;
- platform.y = y;
+ platform.x = x; //i * 1900 + i * Math.random() * 1000;
+ platform.y = y; //2200;
platforms.push(platform);
return platform;
}
var xspeed = 0;
@@ -397,9 +353,9 @@
addPlatformAt(3000 + 1500, 2200);
var platform3 = addPlatformAt(5000 + 1500, 1800);
var spikes = game.addChild(new Spikes());
spikes.x = platform3.x;
-spikes.y = platform3.y - 1750;
+spikes.y = platform3.y - 1500;
addPlatformAt(7000 + 1500, 2200);
var platform1 = platforms[0];
var smallBork = platform1.attachAsset('small_bork', {
anchorX: 0.5,
@@ -452,12 +408,11 @@
largeBork.bork();
}
}
doSmallBork();
-// Initialize chicken
+//<Write imports for supported plugins here>
var chicken = game.addChild(new Chicken());
var particles = game.addChild(new Particles());
-var trailManager = game.addChild(new TrailManager());
Platform.prototype.chicken = chicken;
chicken.x = 2048 / 2;
chicken.y = 2200;
var pitchDebugMarker = game.addChild(new DebugMarker());
@@ -470,8 +425,9 @@
countdown = game.addChild(new Countdown());
}
if (!chicken.isJumping) {
xspeed += .5;
+ particles.addDirtParticle(chicken.x, chicken.y);
xspeed *= .4;
if (facekit.mouthOpen) {
chicken.jump(1.0);
}
@@ -486,9 +442,8 @@
}
if (chicken.intersects(trophy)) {
LK.showYouWin();
}
- // DEBUG
volumeLabel.setText('Volume: ' + facekit.volume.toFixed(2));
pitchLabel.setText('Mouth: ' + (facekit.mouthOpen ? 'OPEN' : 'closed'));
};
LK.playMusic('nyanLikeMusic');
\ 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