User prompt
Create a introduction with a play button if the player taps the play button the play button sends the player to the first level
User prompt
Please fix the bug: 'ReferenceError: idleStartTime is not defined' in or related to this line: 'if (currentTime - idleStartTime > 5000) {' Line Number: 675
User prompt
If the player swipe at anywhere the player gets a point if the player stands more than 5 seconds the player gets 1 million points ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Delete the fact I said if the player swipe left the player goes left same thing with right
User prompt
Make grass on the bottom big
User prompt
When the player touch the ground the ground got deleted
User prompt
When the player goes on the ground and glitches back to the platform
User prompt
This is a mobile game so if the player go on the ground a glitch back give the Player points
User prompt
The ground can't kill the player the player only allowed to go up and down
User prompt
The player not allowed on the ground the players only allowed on the platform
User prompt
The player not allowed to give off of the platform
User prompt
The player stays on the platform if the player swipes up the player goes up same thing with down
User prompt
If the player swipes up and left the player goes up and left same thing with up and right down and up down and right down and left
User prompt
Make the help button a shape of a rectangle
User prompt
Add a enemy in level 3 the monster asset is at one of the platforms
User prompt
Move the help button to the bottom of each level
User prompt
In level one it has a new asset called help button if the player taps the help button it gives the player instructions how to play the game in level 2 it has a help button if the player taps the help button it goes the player the rules of the game same thing with level 3
User prompt
At level 3 level 3 has 800 Stars we have to collect them all if player swipes left the player gets 100 Stars if the player swipes right the player gets 700 Stars
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);' Line Number: 406
User prompt
Add a second level
User prompt
Create a monster asset that's supposed to stop the player
User prompt
If I swipe up I get three stars but if I swipe down I get all of the stars and I go to the next level
User prompt
Add the player ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add the sprunkis
User prompt
Sprunki: The Bouncy Adventure
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Goal = Container.expand(function () {
var self = Container.call(this);
var goalGraphics = self.attachAsset('goal', {
anchorX: 0.5,
anchorY: 1.0
});
self.lastWasIntersecting = false;
self.update = function () {
// Waving flag animation
goalGraphics.rotation = Math.sin(LK.ticks / 20) * 0.1;
};
return self;
});
var Hazard = Container.expand(function () {
var self = Container.call(this);
var hazardGraphics = self.attachAsset('hazard', {
anchorX: 0.5,
anchorY: 0.5
});
self.lastWasIntersecting = false;
return self;
});
var Monster = Container.expand(function () {
var self = Container.call(this);
// Create monster graphics
var monsterGraphics = self.attachAsset('hazard', {
anchorX: 0.5,
anchorY: 0.5
});
// Make it bigger to look more like a monster
monsterGraphics.scale.set(2, 2);
// Movement properties
self.speed = 2;
self.direction = 1; // 1 = right, -1 = left
self.moveRange = 300;
self.startX = 0;
self.lastWasIntersecting = false;
// Update monster movement
self.update = function () {
// Move back and forth
self.x += self.speed * self.direction;
// Change direction at range limits
if (Math.abs(self.x - self.startX) > self.moveRange) {
self.direction *= -1;
}
// Visual effect based on direction
monsterGraphics.scale.x = 2 * self.direction;
};
return self;
});
// Set game background
var Platform = Container.expand(function () {
var self = Container.call(this);
var platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.0
});
self.checkCollision = function (sprunki) {
if (!sprunki.compressed && sprunki.vy > 0) {
// Only check collisions when Sprunki is falling
var lastWasAbove = sprunki.lastY + 100 <= self.y;
var nowBelow = sprunki.y + 100 > self.y;
var horizontalOverlap = Math.abs(sprunki.x - self.x) < platformGraphics.width / 2 + 50;
if (lastWasAbove && nowBelow && horizontalOverlap) {
sprunki.y = self.y - 100;
sprunki.vy *= -self.bounce;
sprunki.grounded = true;
LK.getSound('bounce').play();
return true;
}
}
return false;
};
return self;
});
var Sprunki = Container.expand(function () {
var self = Container.call(this);
// Create spring character
var springGraphics = self.attachAsset('spring', {
anchorX: 0.5,
anchorY: 0.5
});
// Physics properties
self.vx = 0;
self.vy = 0;
self.gravity = 0.5;
self.bounce = 0.7;
self.grounded = false;
self.compressed = false;
self.compressHeight = 0;
self.maxCompressHeight = 80;
self.lastX = 0;
self.lastY = 0;
self.lastWasIntersecting = false;
// Swipe detection
self.swipeStartY = 0;
self.swipeDirection = null;
// Switch to compressed spring
self.compress = function () {
if (self.compressed) return;
self.compressed = true;
self.removeChild(springGraphics);
springGraphics = self.attachAsset('spring_compressed', {
anchorX: 0.5,
anchorY: 0.5
});
// Animate the compression
tween(self.scale, {
x: 1.4,
y: 0.7
}, {
duration: 200,
easing: tween.easeOut
});
};
// Switch back to normal spring and launch
self.release = function () {
if (!self.compressed) return;
// Calculate launch velocity based on compression time
var launchPower = 10 + self.compressHeight / 10;
self.compressed = false;
self.removeChild(springGraphics);
springGraphics = self.attachAsset('spring', {
anchorX: 0.5,
anchorY: 0.5
});
// Add upward velocity based on compression time
self.vy = -launchPower;
// Add slight horizontal movement
self.vx = Math.random() * 10 - 5;
// Animate the spring stretching effect
tween(self.scale, {
x: 0.7,
y: 1.4
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
// Return to normal scale
tween(self.scale, {
x: 1,
y: 1
}, {
duration: 200,
easing: tween.easeInOut
});
}
});
// Play bounce sound
LK.getSound('bounce').play();
// Reset compression height
self.compressHeight = 0;
};
// Apply physics and check collisions
self.update = function () {
// Store last position for collision detection
self.lastX = self.x;
self.lastY = self.y;
if (!self.compressed) {
// Apply gravity and movement
self.vy += self.gravity;
self.x += self.vx;
self.y += self.vy;
// Screen boundaries
if (self.x < 50) {
self.x = 50;
self.vx *= -0.5;
} else if (self.x > 2048 - 50) {
self.x = 2048 - 50;
self.vx *= -0.5;
}
// Bottom boundary with bounce
if (self.y > 2732 - 50) {
self.y = 2732 - 50;
self.vy *= -self.bounce;
self.grounded = true;
LK.getSound('bounce').play();
} else {
self.grounded = false;
}
// Dampen horizontal movement
self.vx *= 0.98;
}
};
// User input handlers
self.down = function (x, y, obj) {
if (self.grounded) {
self.compress();
self.compressHeight = 0;
}
// Track start position for swipe detection
self.swipeStartY = y;
self.swipeDirection = null;
};
self.up = function (x, y, obj) {
if (self.compressed) {
self.release();
}
// Calculate swipe distance and direction
var swipeDist = y - self.swipeStartY;
if (Math.abs(swipeDist) > 50) {
// Swipe detected (more than 50px distance)
if (swipeDist < 0) {
// Swipe up - collect 3 stars
collectStarsBySwipe(3);
} else {
// Swipe down - collect all stars and go to next level
collectStarsBySwipe(100); // A large number to ensure all stars are collected
if (currentLevel < 2) {
loadLevel(currentLevel + 1);
} else {
LK.showYouWin(); // Show win after final level
}
}
}
};
return self;
});
var Star = Container.expand(function () {
var self = Container.call(this);
var starGraphics = self.attachAsset('star', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.lastWasIntersecting = false;
self.update = function () {
// Rotate star for visual effect
starGraphics.rotation += 0.02;
// Floating animation
self.y += Math.sin(LK.ticks / 20) * 0.5;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Set game background
game.setBackgroundColor(0x87CEEB); // Sky blue background
// Create Sprunki instance
var sprunki = new Sprunki();
sprunki.x = 200;
sprunki.y = 200;
game.addChild(sprunki);
// Create game elements
// Create platforms
var platforms = [];
function createPlatform(x, y) {
var platform = new Platform();
platform.x = x;
platform.y = y;
platforms.push(platform);
game.addChild(platform);
return platform;
}
// Create monsters
var monsters = [];
function createMonster(x, y, range) {
var monster = new Monster();
monster.x = x;
monster.y = y;
monster.startX = x;
monster.moveRange = range || 300;
monsters.push(monster);
game.addChild(monster);
return monster;
}
// Create hazards
var hazards = [];
function createHazard(x, y) {
var hazard = new Hazard();
hazard.x = x;
hazard.y = y;
hazards.push(hazard);
game.addChild(hazard);
return hazard;
}
// Create stars
var stars = [];
function createStar(x, y) {
var star = new Star();
star.x = x;
star.y = y;
stars.push(star);
game.addChild(star);
return star;
}
// Create goal variable
var goal = null;
// Load initial level
loadLevel(1);
// Create score display and level tracking
var currentLevel = 1;
var starCount = 0;
var maxStars = 0;
var scoreTxt = new Text2('Level: ' + currentLevel + ' - Stars: ' + starCount + '/0', {
size: 70,
fill: 0xFFFFFF
});
// Function to load level based on current level number
function loadLevel(levelNumber) {
// Clear existing game elements
clearLevel();
// Set current level
currentLevel = levelNumber;
// Reset star count
starCount = 0;
if (levelNumber === 1) {
// Level 1 setup
createPlatform(500, 800);
createPlatform(1200, 1000);
createPlatform(800, 1400);
createPlatform(400, 1800);
createPlatform(1400, 1600);
createPlatform(1000, 2200);
createPlatform(600, 2500);
createStar(500, 700);
createStar(1200, 900);
createStar(800, 1300);
createStar(400, 1700);
createStar(1400, 1500);
createHazard(700, 1200);
createHazard(1100, 1800);
createHazard(500, 2400);
createMonster(500, 750, 200);
createMonster(1200, 950, 400);
createMonster(800, 1350, 300);
// Create goal
goal = new Goal();
goal.x = 600;
goal.y = 2500;
game.addChild(goal);
} else if (levelNumber === 2) {
// Level 2 setup - more challenging
createPlatform(400, 600);
createPlatform(900, 500);
createPlatform(1500, 700);
createPlatform(1800, 1100);
createPlatform(1300, 1400);
createPlatform(800, 1600);
createPlatform(400, 1900);
createPlatform(1000, 2200);
createPlatform(1600, 2400);
createStar(400, 500);
createStar(900, 400);
createStar(1500, 600);
createStar(1800, 1000);
createStar(1300, 1300);
createStar(800, 1500);
createStar(400, 1800);
createHazard(600, 800);
createHazard(1200, 1000);
createHazard(1500, 1800);
createHazard(900, 2000);
// More monsters in level 2
createMonster(400, 550, 150);
createMonster(900, 450, 300);
createMonster(1500, 650, 200);
createMonster(1300, 1350, 250);
createMonster(800, 1550, 200);
// Create goal
goal = new Goal();
goal.x = 1600;
goal.y = 2400;
game.addChild(goal);
}
// Reset position
sprunki.x = 200;
sprunki.y = 200;
sprunki.vx = 0;
sprunki.vy = 0;
// Update max stars count
maxStars = stars.length;
scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);
}
// Function to clear existing level elements
function clearLevel() {
// Remove all platforms
for (var i = platforms.length - 1; i >= 0; i--) {
game.removeChild(platforms[i]);
platforms.splice(i, 1);
}
// Remove all stars
for (var i = stars.length - 1; i >= 0; i--) {
game.removeChild(stars[i]);
stars.splice(i, 1);
}
// Remove all hazards
for (var i = hazards.length - 1; i >= 0; i--) {
game.removeChild(hazards[i]);
hazards.splice(i, 1);
}
// Remove all monsters
for (var i = monsters.length - 1; i >= 0; i--) {
game.removeChild(monsters[i]);
monsters.splice(i, 1);
}
// Remove goal if it exists
if (goal) {
game.removeChild(goal);
goal = null;
}
}
// Function to collect stars by swipe
function collectStarsBySwipe(count) {
var collected = 0;
for (var i = 0; i < stars.length && collected < count; i++) {
if (!stars[i].collected) {
stars[i].collected = true;
stars[i].visible = false;
starCount++;
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 100);
collected++;
}
}
scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);
}
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Handle user interaction
game.down = function (x, y, obj) {
sprunki.down(x, y, obj);
};
game.up = function (x, y, obj) {
sprunki.up(x, y, obj);
};
// Compress indicator
game.move = function (x, y, obj) {
if (sprunki.compressed) {
sprunki.compressHeight = Math.min(sprunki.compressHeight + 2, sprunki.maxCompressHeight);
// Visual feedback for compression
var compressionScale = 1 + sprunki.compressHeight / 200;
sprunki.scale.set(compressionScale, 1 / compressionScale);
}
};
// Main game loop
game.update = function () {
// Update Sprunki
sprunki.update();
// Update game elements
for (var i = 0; i < stars.length; i++) {
if (!stars[i].collected) {
stars[i].update();
// Check star collection
if (!stars[i].lastWasIntersecting && sprunki.intersects(stars[i])) {
stars[i].collected = true;
stars[i].visible = false;
starCount++;
scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 100);
}
stars[i].lastWasIntersecting = sprunki.intersects(stars[i]);
}
}
// Update goal
goal.update();
// Check if reached goal
if (!goal.lastWasIntersecting && sprunki.intersects(goal)) {
// Level complete!
if (currentLevel < 2) {
// Go to next level
loadLevel(currentLevel + 1);
} else {
// Final level completed
LK.showYouWin();
}
}
goal.lastWasIntersecting = sprunki.intersects(goal);
// Check platform collisions
for (var i = 0; i < platforms.length; i++) {
platforms[i].checkCollision(sprunki);
}
// Check hazard collisions
for (var i = 0; i < hazards.length; i++) {
if (!hazards[i].lastWasIntersecting && sprunki.intersects(hazards[i])) {
// Game over when hitting hazard
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
}
hazards[i].lastWasIntersecting = sprunki.intersects(hazards[i]);
}
// Update and check monster collisions
for (var i = 0; i < monsters.length; i++) {
// Update monster movement
monsters[i].update();
// Check collision with sprunki
if (!monsters[i].lastWasIntersecting && sprunki.intersects(monsters[i])) {
// Game over when colliding with monster
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
}
monsters[i].lastWasIntersecting = sprunki.intersects(monsters[i]);
}
// Check if Sprunki fell off the bottom of the screen
if (sprunki.y > 2732 + 200) {
LK.effects.flashScreen(0xFF0000, 1000);
LK.showGameOver();
}
// Visual feedback for compression
if (sprunki.compressed) {
var scale = 1 + sprunki.compressHeight / 200;
sprunki.scale.set(scale, 1 / scale);
} else {
sprunki.scale.set(1, 1);
}
}; ===================================================================
--- original.js
+++ change.js
@@ -213,9 +213,13 @@
collectStarsBySwipe(3);
} else {
// Swipe down - collect all stars and go to next level
collectStarsBySwipe(100); // A large number to ensure all stars are collected
- LK.showYouWin(); // Go to next level
+ if (currentLevel < 2) {
+ loadLevel(currentLevel + 1);
+ } else {
+ LK.showYouWin(); // Show win after final level
+ }
}
}
};
return self;
@@ -296,40 +300,124 @@
stars.push(star);
game.addChild(star);
return star;
}
-// Create level
-createPlatform(500, 800);
-createPlatform(1200, 1000);
-createPlatform(800, 1400);
-createPlatform(400, 1800);
-createPlatform(1400, 1600);
-createPlatform(1000, 2200);
-createPlatform(600, 2500);
-createStar(500, 700);
-createStar(1200, 900);
-createStar(800, 1300);
-createStar(400, 1700);
-createStar(1400, 1500);
-createHazard(700, 1200);
-createHazard(1100, 1800);
-createHazard(500, 2400);
-// Add monsters that patrol platforms
-createMonster(500, 750, 200);
-createMonster(1200, 950, 400);
-createMonster(800, 1350, 300);
-// Create goal
-var goal = new Goal();
-goal.x = 600;
-goal.y = 2500;
-game.addChild(goal);
-// Create score display
+// Create goal variable
+var goal = null;
+// Load initial level
+loadLevel(1);
+// Create score display and level tracking
+var currentLevel = 1;
var starCount = 0;
-var maxStars = stars.length;
-var scoreTxt = new Text2('Stars: ' + starCount + '/' + maxStars, {
+var maxStars = 0;
+var scoreTxt = new Text2('Level: ' + currentLevel + ' - Stars: ' + starCount + '/0', {
size: 70,
fill: 0xFFFFFF
});
+// Function to load level based on current level number
+function loadLevel(levelNumber) {
+ // Clear existing game elements
+ clearLevel();
+ // Set current level
+ currentLevel = levelNumber;
+ // Reset star count
+ starCount = 0;
+ if (levelNumber === 1) {
+ // Level 1 setup
+ createPlatform(500, 800);
+ createPlatform(1200, 1000);
+ createPlatform(800, 1400);
+ createPlatform(400, 1800);
+ createPlatform(1400, 1600);
+ createPlatform(1000, 2200);
+ createPlatform(600, 2500);
+ createStar(500, 700);
+ createStar(1200, 900);
+ createStar(800, 1300);
+ createStar(400, 1700);
+ createStar(1400, 1500);
+ createHazard(700, 1200);
+ createHazard(1100, 1800);
+ createHazard(500, 2400);
+ createMonster(500, 750, 200);
+ createMonster(1200, 950, 400);
+ createMonster(800, 1350, 300);
+ // Create goal
+ goal = new Goal();
+ goal.x = 600;
+ goal.y = 2500;
+ game.addChild(goal);
+ } else if (levelNumber === 2) {
+ // Level 2 setup - more challenging
+ createPlatform(400, 600);
+ createPlatform(900, 500);
+ createPlatform(1500, 700);
+ createPlatform(1800, 1100);
+ createPlatform(1300, 1400);
+ createPlatform(800, 1600);
+ createPlatform(400, 1900);
+ createPlatform(1000, 2200);
+ createPlatform(1600, 2400);
+ createStar(400, 500);
+ createStar(900, 400);
+ createStar(1500, 600);
+ createStar(1800, 1000);
+ createStar(1300, 1300);
+ createStar(800, 1500);
+ createStar(400, 1800);
+ createHazard(600, 800);
+ createHazard(1200, 1000);
+ createHazard(1500, 1800);
+ createHazard(900, 2000);
+ // More monsters in level 2
+ createMonster(400, 550, 150);
+ createMonster(900, 450, 300);
+ createMonster(1500, 650, 200);
+ createMonster(1300, 1350, 250);
+ createMonster(800, 1550, 200);
+ // Create goal
+ goal = new Goal();
+ goal.x = 1600;
+ goal.y = 2400;
+ game.addChild(goal);
+ }
+ // Reset position
+ sprunki.x = 200;
+ sprunki.y = 200;
+ sprunki.vx = 0;
+ sprunki.vy = 0;
+ // Update max stars count
+ maxStars = stars.length;
+ scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);
+}
+// Function to clear existing level elements
+function clearLevel() {
+ // Remove all platforms
+ for (var i = platforms.length - 1; i >= 0; i--) {
+ game.removeChild(platforms[i]);
+ platforms.splice(i, 1);
+ }
+ // Remove all stars
+ for (var i = stars.length - 1; i >= 0; i--) {
+ game.removeChild(stars[i]);
+ stars.splice(i, 1);
+ }
+ // Remove all hazards
+ for (var i = hazards.length - 1; i >= 0; i--) {
+ game.removeChild(hazards[i]);
+ hazards.splice(i, 1);
+ }
+ // Remove all monsters
+ for (var i = monsters.length - 1; i >= 0; i--) {
+ game.removeChild(monsters[i]);
+ monsters.splice(i, 1);
+ }
+ // Remove goal if it exists
+ if (goal) {
+ game.removeChild(goal);
+ goal = null;
+ }
+}
// Function to collect stars by swipe
function collectStarsBySwipe(count) {
var collected = 0;
for (var i = 0; i < stars.length && collected < count; i++) {
@@ -341,9 +429,9 @@
LK.setScore(LK.getScore() + 100);
collected++;
}
}
- scoreTxt.setText('Stars: ' + starCount + '/' + maxStars);
+ scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);
}
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Handle user interaction
@@ -374,9 +462,9 @@
if (!stars[i].lastWasIntersecting && sprunki.intersects(stars[i])) {
stars[i].collected = true;
stars[i].visible = false;
starCount++;
- scoreTxt.setText('Stars: ' + starCount + '/' + maxStars);
+ scoreTxt.setText('Level: ' + currentLevel + ' - Stars: ' + starCount + '/' + maxStars);
LK.getSound('collect').play();
LK.setScore(LK.getScore() + 100);
}
stars[i].lastWasIntersecting = sprunki.intersects(stars[i]);
@@ -386,9 +474,15 @@
goal.update();
// Check if reached goal
if (!goal.lastWasIntersecting && sprunki.intersects(goal)) {
// Level complete!
- LK.showYouWin();
+ if (currentLevel < 2) {
+ // Go to next level
+ loadLevel(currentLevel + 1);
+ } else {
+ // Final level completed
+ LK.showYouWin();
+ }
}
goal.lastWasIntersecting = sprunki.intersects(goal);
// Check platform collisions
for (var i = 0; i < platforms.length; i++) {
Star. In-Game asset. High contrast. No shadows
Monster. In-Game asset. High contrast. No shadows
Gray sprunki . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Mad gray and dark grey sprunki . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Cute Cube . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat