User prompt
add a blue visual effect when colliding with platforms for which points are awarded
User prompt
add a white visual effect when colliding with platforms for which points are awarded
User prompt
add a red visual effect when colliding with platforms for which points are awarded
User prompt
add a white visual effect when colliding with platforms for which points are awarded
User prompt
add a red visual effect when colliding with platforms for which points are awarded
User prompt
add a visual effect when colliding with platforms for which points are awarded
User prompt
do not award points for hitting the bouncing_platform
User prompt
with each new thousand points reached, the platforms must move faster
User prompt
with each new hundred points, the game should get faster.
User prompt
the player must bounce twice as high off the platform
User prompt
Add rocking behavior to the UltraFastMovingPlatform class
User prompt
assign a 10 point reward when hitting move_platform
User prompt
more sway when falling for ultra_fast_moving_platform
User prompt
make the sway vary from platform to platform.
User prompt
not all platforms are rocking. Correct the error.
User prompt
not all platforms are rocking. Correct the error.
User prompt
add sway when falling for all platforms
User prompt
add sway when falling for all platforms
User prompt
ΠΌ
User prompt
add sway when falling for all platforms
User prompt
platforms should rotate slightly when dropped
User prompt
the platforms should jerk once when the player is hit.
User prompt
Fix Bug: 'TypeError: platform.shakeEffect is not a function' in this line: 'platform.shakeEffect();' Line Number: 282
User prompt
Fix Bug: 'TypeError: platform.shakeEffect is not a function' in this line: 'platform.shakeEffect();' Line Number: 266
User prompt
Fix Bug: 'TypeError: platform.shakeEffect is not a function' in this line: 'platform.shakeEffect();' Line Number: 266
/**** * Classes ****/ // Define the Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player character', 0.5, 1); self.velocityY = 0; self.velocityX = 0; self.isOnGround = false; self.jump = function () { self.velocityY = -15; // Jump force }; self.update = function () { self.x += self.velocityX; // Prevent player from going beyond the right side of the screen if (self.x > game.width - playerGraphics.width) { self.x = game.width - playerGraphics.width; } // Prevent player from going beyond the left side of the screen if (self.x < 0) { self.x = 0; } self.y += self.velocityY; // Prevent player from going above the top of the screen if (self.y < 0) { self.y = 0; self.velocityY = 0; } self.velocityY += 0.5; // Gravity // Check for ground and set game over if player is at the bottom of the screen if (self.y > game.height - playerGraphics.height) { // Flash screen grey for 1 second (1000ms) to show game over LK.effects.flashScreen(0x808080, 1000); LK.showGameOver(); } }; }); // Define the Platform class var Platform = Container.expand(function () { var self = Container.call(this); self.shakeEffect = function () { var shakeIntensity = 0.2; var shakeDuration = 5; var shakeCount = 0; var originalRotation = self.rotation; var shake = function shake() { if (shakeCount < shakeDuration) { self.rotation = originalRotation + Math.random() * shakeIntensity - shakeIntensity / 2; shakeCount++; LK.setTimeout(shake, 33); } else { self.rotation = originalRotation; } }; shake(); }; var platformGraphics = self.createAsset('platform', 'Platform', 0.5, 1); self.speed = (Math.random() * 3 + 1) * 2; // Random speed between 2 and 8, doubled from original self.rockingAngle = 0; // Starting angle for rocking motion self.rockingSpeed = Math.random() * 0.1 + 0.05; // Random rocking speed between 0.05 and 0.15 self.update = function () { self.y += self.speed; // Move platform down at its own speed self.rockingAngle += self.rockingSpeed; // Update rocking angle self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle }; self.setInitialPosition = function (x, y) { self.x = x; self.y = y; }; }); // Define the MovingPlatform class var MovingPlatform = Container.expand(function () { var self = Container.call(this); var movingPlatformGraphics = self.createAsset('moving_platform', 'Moving Platform', 0.5, 1); self.speed = (Math.random() * 2 + 1) * 2; // Random speed between 2 and 6 self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction self.setInitialPosition = function (x, y) { self.x = x; self.y = y; }; self.update = function () { self.x += self.direction; self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set self.rockingAngle += self.rockingSpeed; // Update rocking angle self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle // Change direction if it hits the edges of the screen if (self.x > game.width - movingPlatformGraphics.width || self.x < 0) { self.direction *= -1; } }; }); // Define the FastMovingPlatform class var FastMovingPlatform = Container.expand(function () { var self = Container.call(this); var fastMovingPlatformGraphics = self.createAsset('fast_moving_platform', 'Fast Moving Platform', 0.5, 1); self.speed = (Math.random() * 2 + 3) * 2; // Random speed between 6 and 10 self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction self.setInitialPosition = function (x, y) { self.x = x; self.y = y; }; self.update = function () { self.x += self.direction * self.speed; self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set self.rockingAngle += self.rockingSpeed; // Update rocking angle self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle // Change direction if it hits the edges of the screen if (self.x > game.width - fastMovingPlatformGraphics.width || self.x < 0) { self.direction *= -1; } }; }); // Define the BouncingPlatform class var BouncingPlatform = Container.expand(function () { var self = Container.call(this); var bouncingPlatformGraphics = self.createAsset('bouncing_platform', 'Bouncing Platform', 0.5, 1); self.speed = (Math.random() * 2 + 4) * 2; // Random speed between 8 and 12 self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction self.bounceHeight = Math.random() * 100 + 50; // Random bounce height between 50 and 150 self.bounceSpeed = Math.random() * 0.5 + 0.5; // Random bounce speed between 0.5 and 1 self.setInitialPosition = function (x, y) { self.x = x; self.y = y; self.originalY = y; }; self.update = function () { self.x += self.direction * self.speed; self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set self.rockingAngle += self.rockingSpeed; // Update rocking angle self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle // Bounce up and down over time self.y = self.originalY + Math.sin(Date.now() * self.bounceSpeed) * self.bounceHeight; // Change direction if it hits the edges of the screen if (self.x > game.width - bouncingPlatformGraphics.width || self.x < 0) { self.direction *= -1; } }; }); // Define the UltraFastMovingPlatform class var UltraFastMovingPlatform = Container.expand(function () { var self = Container.call(this); var ultraFastMovingPlatformGraphics = self.createAsset('ultra_fast_moving_platform', 'Ultra Fast Moving Platform', 0.5, 1); self.speed = (Math.random() * 2 + 5) * 2; // Random speed between 10 and 14 self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction self.setInitialPosition = function (x, y) { self.x = x; self.y = y; }; self.update = function () { self.x += self.direction * self.speed; self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set self.rockingAngle += self.rockingSpeed; // Update rocking angle self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle // Change direction if it hits the edges of the screen if (self.x > game.width - ultraFastMovingPlatformGraphics.width || self.x < 0) { self.direction *= -1; } }; }); /**** * Initialize Game ****/ // Store the start time of the game var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ var startTime = Date.now(); // Initialize the point counter var pointCounterTxt = new Text2('0', { size: 75, fill: "#ffffff" }); pointCounterTxt.anchor.set(1, 0); LK.gui.topRight.addChild(pointCounterTxt); // Attach pointCounterTxt to the top right of the screen. var startTime = Date.now(); // Store the start time of the game var timeCounterTxt = new Text2('0', { size: 75, fill: "#ffffff" }); timeCounterTxt.anchor.set(0, 0); LK.gui.topLeft.addChild(timeCounterTxt); // Attach timeCounterTxt to the top left of the screen. // Initialize important asset arrays var platforms = []; var player; // Create the player player = game.addChild(new Player()); player.x = game.width / 2; player.y = game.height / 2; // Create initial platforms var initialPlatformY = game.height - 300; for (var i = 0; i < 7; i++) { var platform; var platformType = Math.random(); if (platformType < 0.25) { platform = new MovingPlatform(); } else if (platformType < 0.5) { platform = new Platform(); } else if (platformType < 0.65) { platform = new FastMovingPlatform(); } else if (platformType < 0.85) { platform = new BouncingPlatform(); } else { platform = new UltraFastMovingPlatform(); } var randomX = Math.random() * (game.width - platform.width) + platform.width / 2; platform.setInitialPosition(randomX, initialPlatformY - i * 300); platforms.push(platform); game.addChild(platform); } // Event listener for touch events on the game area game.on('down', function (obj) { var touchPosition = obj.event.getLocalPosition(game); if (touchPosition.x < game.width / 2) { player.velocityX = -10; } else { player.velocityX = 10; } player.jump(); }); game.on('up', function (obj) { player.velocityX = 0; }); // Main game update loop LK.on('tick', function () { player.update(); // Update platforms for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; platform.y += platform.speed; // Move platforms down at their own speed if (platform instanceof MovingPlatform) { platform.update(); // Update moving platforms } // Recycle platforms if (platform.y > game.height) { var randomX = Math.random() * (game.width - platform.width) + platform.width / 2; platform.x = randomX; platform.y = -50; } // Check for collision with player using the player's next position to predict collision var playerNextY = player.y + player.velocityY; if (player.intersects(platform) && player.velocityY > 0 && playerNextY + player.height > platform.y && player.y < platform.y) { player.isOnGround = true; player.velocityY = 0; player.y = platform.y - player.height; platform.shakeEffect(); // Award points if the platform is a FastMovingPlatform or UltraFastMovingPlatform and update the score counter if (platform instanceof FastMovingPlatform || platform instanceof UltraFastMovingPlatform || platform instanceof BouncingPlatform) { var pointsAwarded = platform instanceof UltraFastMovingPlatform ? 50 : 10; LK.setScore(LK.getScore() + pointsAwarded); pointCounterTxt.setText(LK.getScore().toString()); } } } // Update the time counter var currentTime = Date.now(); var elapsedTime = ((currentTime - startTime) / 1000).toFixed(1); // Elapsed time in seconds with one decimal place timeCounterTxt.setText(elapsedTime + 's'); // Check for game over condition if (player.y < -player.height) { // Flash screen grey for 1 second (1000ms) to show game over LK.effects.flashScreen(0x808080, 1000); LK.showGameOver(); } });
/****
* Classes
****/
// Define the Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.createAsset('player', 'Player character', 0.5, 1);
self.velocityY = 0;
self.velocityX = 0;
self.isOnGround = false;
self.jump = function () {
self.velocityY = -15; // Jump force
};
self.update = function () {
self.x += self.velocityX;
// Prevent player from going beyond the right side of the screen
if (self.x > game.width - playerGraphics.width) {
self.x = game.width - playerGraphics.width;
}
// Prevent player from going beyond the left side of the screen
if (self.x < 0) {
self.x = 0;
}
self.y += self.velocityY;
// Prevent player from going above the top of the screen
if (self.y < 0) {
self.y = 0;
self.velocityY = 0;
}
self.velocityY += 0.5; // Gravity
// Check for ground and set game over if player is at the bottom of the screen
if (self.y > game.height - playerGraphics.height) {
// Flash screen grey for 1 second (1000ms) to show game over
LK.effects.flashScreen(0x808080, 1000);
LK.showGameOver();
}
};
});
// Define the Platform class
var Platform = Container.expand(function () {
var self = Container.call(this);
self.shakeEffect = function () {
var shakeIntensity = 0.2;
var shakeDuration = 5;
var shakeCount = 0;
var originalRotation = self.rotation;
var shake = function shake() {
if (shakeCount < shakeDuration) {
self.rotation = originalRotation + Math.random() * shakeIntensity - shakeIntensity / 2;
shakeCount++;
LK.setTimeout(shake, 33);
} else {
self.rotation = originalRotation;
}
};
shake();
};
var platformGraphics = self.createAsset('platform', 'Platform', 0.5, 1);
self.speed = (Math.random() * 3 + 1) * 2; // Random speed between 2 and 8, doubled from original
self.rockingAngle = 0; // Starting angle for rocking motion
self.rockingSpeed = Math.random() * 0.1 + 0.05; // Random rocking speed between 0.05 and 0.15
self.update = function () {
self.y += self.speed; // Move platform down at its own speed
self.rockingAngle += self.rockingSpeed; // Update rocking angle
self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle
};
self.setInitialPosition = function (x, y) {
self.x = x;
self.y = y;
};
});
// Define the MovingPlatform class
var MovingPlatform = Container.expand(function () {
var self = Container.call(this);
var movingPlatformGraphics = self.createAsset('moving_platform', 'Moving Platform', 0.5, 1);
self.speed = (Math.random() * 2 + 1) * 2; // Random speed between 2 and 6
self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction
self.setInitialPosition = function (x, y) {
self.x = x;
self.y = y;
};
self.update = function () {
self.x += self.direction;
self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set
self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set
self.rockingAngle += self.rockingSpeed; // Update rocking angle
self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle
// Change direction if it hits the edges of the screen
if (self.x > game.width - movingPlatformGraphics.width || self.x < 0) {
self.direction *= -1;
}
};
});
// Define the FastMovingPlatform class
var FastMovingPlatform = Container.expand(function () {
var self = Container.call(this);
var fastMovingPlatformGraphics = self.createAsset('fast_moving_platform', 'Fast Moving Platform', 0.5, 1);
self.speed = (Math.random() * 2 + 3) * 2; // Random speed between 6 and 10
self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction
self.setInitialPosition = function (x, y) {
self.x = x;
self.y = y;
};
self.update = function () {
self.x += self.direction * self.speed;
self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set
self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set
self.rockingAngle += self.rockingSpeed; // Update rocking angle
self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle
// Change direction if it hits the edges of the screen
if (self.x > game.width - fastMovingPlatformGraphics.width || self.x < 0) {
self.direction *= -1;
}
};
});
// Define the BouncingPlatform class
var BouncingPlatform = Container.expand(function () {
var self = Container.call(this);
var bouncingPlatformGraphics = self.createAsset('bouncing_platform', 'Bouncing Platform', 0.5, 1);
self.speed = (Math.random() * 2 + 4) * 2; // Random speed between 8 and 12
self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction
self.bounceHeight = Math.random() * 100 + 50; // Random bounce height between 50 and 150
self.bounceSpeed = Math.random() * 0.5 + 0.5; // Random bounce speed between 0.5 and 1
self.setInitialPosition = function (x, y) {
self.x = x;
self.y = y;
self.originalY = y;
};
self.update = function () {
self.x += self.direction * self.speed;
self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set
self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set
self.rockingAngle += self.rockingSpeed; // Update rocking angle
self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle
// Bounce up and down over time
self.y = self.originalY + Math.sin(Date.now() * self.bounceSpeed) * self.bounceHeight;
// Change direction if it hits the edges of the screen
if (self.x > game.width - bouncingPlatformGraphics.width || self.x < 0) {
self.direction *= -1;
}
};
});
// Define the UltraFastMovingPlatform class
var UltraFastMovingPlatform = Container.expand(function () {
var self = Container.call(this);
var ultraFastMovingPlatformGraphics = self.createAsset('ultra_fast_moving_platform', 'Ultra Fast Moving Platform', 0.5, 1);
self.speed = (Math.random() * 2 + 5) * 2; // Random speed between 10 and 14
self.direction = Math.random() > 0.5 ? 1 : -1; // Randomly choose initial direction
self.setInitialPosition = function (x, y) {
self.x = x;
self.y = y;
};
self.update = function () {
self.x += self.direction * self.speed;
self.rockingAngle = self.rockingAngle || 0; // Initialize rocking angle if not set
self.rockingSpeed = self.rockingSpeed || Math.random() * 0.1 + 0.05; // Initialize rocking speed if not set
self.rockingAngle += self.rockingSpeed; // Update rocking angle
self.rotation = Math.sin(self.rockingAngle) * 0.1; // Apply rocking motion based on angle
// Change direction if it hits the edges of the screen
if (self.x > game.width - ultraFastMovingPlatformGraphics.width || self.x < 0) {
self.direction *= -1;
}
};
});
/****
* Initialize Game
****/
// Store the start time of the game
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
var startTime = Date.now();
// Initialize the point counter
var pointCounterTxt = new Text2('0', {
size: 75,
fill: "#ffffff"
});
pointCounterTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(pointCounterTxt); // Attach pointCounterTxt to the top right of the screen.
var startTime = Date.now(); // Store the start time of the game
var timeCounterTxt = new Text2('0', {
size: 75,
fill: "#ffffff"
});
timeCounterTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(timeCounterTxt); // Attach timeCounterTxt to the top left of the screen.
// Initialize important asset arrays
var platforms = [];
var player;
// Create the player
player = game.addChild(new Player());
player.x = game.width / 2;
player.y = game.height / 2;
// Create initial platforms
var initialPlatformY = game.height - 300;
for (var i = 0; i < 7; i++) {
var platform;
var platformType = Math.random();
if (platformType < 0.25) {
platform = new MovingPlatform();
} else if (platformType < 0.5) {
platform = new Platform();
} else if (platformType < 0.65) {
platform = new FastMovingPlatform();
} else if (platformType < 0.85) {
platform = new BouncingPlatform();
} else {
platform = new UltraFastMovingPlatform();
}
var randomX = Math.random() * (game.width - platform.width) + platform.width / 2;
platform.setInitialPosition(randomX, initialPlatformY - i * 300);
platforms.push(platform);
game.addChild(platform);
}
// Event listener for touch events on the game area
game.on('down', function (obj) {
var touchPosition = obj.event.getLocalPosition(game);
if (touchPosition.x < game.width / 2) {
player.velocityX = -10;
} else {
player.velocityX = 10;
}
player.jump();
});
game.on('up', function (obj) {
player.velocityX = 0;
});
// Main game update loop
LK.on('tick', function () {
player.update();
// Update platforms
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
platform.y += platform.speed; // Move platforms down at their own speed
if (platform instanceof MovingPlatform) {
platform.update(); // Update moving platforms
}
// Recycle platforms
if (platform.y > game.height) {
var randomX = Math.random() * (game.width - platform.width) + platform.width / 2;
platform.x = randomX;
platform.y = -50;
}
// Check for collision with player using the player's next position to predict collision
var playerNextY = player.y + player.velocityY;
if (player.intersects(platform) && player.velocityY > 0 && playerNextY + player.height > platform.y && player.y < platform.y) {
player.isOnGround = true;
player.velocityY = 0;
player.y = platform.y - player.height;
platform.shakeEffect();
// Award points if the platform is a FastMovingPlatform or UltraFastMovingPlatform and update the score counter
if (platform instanceof FastMovingPlatform || platform instanceof UltraFastMovingPlatform || platform instanceof BouncingPlatform) {
var pointsAwarded = platform instanceof UltraFastMovingPlatform ? 50 : 10;
LK.setScore(LK.getScore() + pointsAwarded);
pointCounterTxt.setText(LK.getScore().toString());
}
}
}
// Update the time counter
var currentTime = Date.now();
var elapsedTime = ((currentTime - startTime) / 1000).toFixed(1); // Elapsed time in seconds with one decimal place
timeCounterTxt.setText(elapsedTime + 's');
// Check for game over condition
if (player.y < -player.height) {
// Flash screen grey for 1 second (1000ms) to show game over
LK.effects.flashScreen(0x808080, 1000);
LK.showGameOver();
}
});
small black umbrella. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
white umbrella. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
erase
water drop with anime style eyes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.