User prompt
Make a difficulty bar at the bottom left of the screen which has three levels of difficulty which is: easy & medium & hard
User prompt
Make the boss a bit bigger ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
And make the character a bit faster too
User prompt
Make the enemies a bit faster too
User prompt
Make the character jump higher a bit and at level 10 make a red boss stick figure with white triangles on the head for its horns and make a boss bar at the top of the screen at level 10 and make at level 10 to throw at the boss and damage them ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the enemies once they look in the direction where you are they run at you but when you get far away or on a moving platform they stop and just get back to roaming ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Give the character some animated legs and some arms and a circle head and make some red stick figures for the enemies ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make some background clouds
Code edit (1 edits merged)
Please save this source code
User prompt
Stick Figure Obstacle Rush
Initial prompt
A game about playing obstacle courses and THERES 10 levels and you play as a stick figure
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var FinishFlag = Container.expand(function (x, y) {
var self = Container.call(this);
var graphics = self.attachAsset('finishFlag', {
anchorX: 0.5,
anchorY: 1.0
});
self.x = x;
self.y = y;
return self;
});
var Obstacle = Container.expand(function (type, x, y) {
var self = Container.call(this);
self.obstacleType = type;
if (type === 'spike') {
var graphics = self.attachAsset('spike', {
anchorX: 0.5,
anchorY: 1.0
});
} else if (type === 'movingPlatform') {
var graphics = self.attachAsset('movingPlatform', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = 1;
self.speed = 2;
self.startX = x;
self.range = 200;
}
self.x = x;
self.y = y;
self.update = function () {
if (self.obstacleType === 'movingPlatform') {
self.x += self.direction * self.speed;
if (self.x > self.startX + self.range || self.x < self.startX - self.range) {
self.direction *= -1;
}
}
};
return self;
});
var StickFigure = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('stickFigure', {
anchorX: 0.5,
anchorY: 1.0
});
self.velocityY = 0;
self.velocityX = 0;
self.isGrounded = false;
self.jumpPower = -25;
self.gravity = 1.2;
self.speed = 8;
self.update = function () {
// Apply gravity
self.velocityY += self.gravity;
// Apply velocity
self.x += self.velocityX;
self.y += self.velocityY;
// Reduce horizontal velocity (friction)
self.velocityX *= 0.85;
// Ground collision
if (self.y >= groundY) {
self.y = groundY;
self.velocityY = 0;
self.isGrounded = true;
}
};
self.jump = function () {
if (self.isGrounded) {
self.velocityY = self.jumpPower;
self.isGrounded = false;
LK.getSound('jump').play();
}
};
self.moveLeft = function () {
self.velocityX = -self.speed;
};
self.moveRight = function () {
self.velocityX = self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var currentLevel = 1;
var maxLevels = 10;
var groundY = 2500;
var player;
var obstacles = [];
var finishFlag;
var isGameActive = true;
var lives = 3;
// UI Elements
var levelText = new Text2('Level 1', {
size: 80,
fill: 0x000000
});
levelText.anchor.set(0.5, 0);
LK.gui.top.addChild(levelText);
var livesText = new Text2('Lives: 3', {
size: 60,
fill: 0xFF0000
});
livesText.anchor.set(1, 0);
LK.gui.topRight.addChild(livesText);
// Create ground platforms
function createGround() {
for (var i = 0; i < 15; i++) {
var groundPiece = LK.getAsset('ground', {
anchorX: 0,
anchorY: 1.0
});
groundPiece.x = i * 300;
groundPiece.y = groundY;
game.addChild(groundPiece);
}
}
// Level configurations
var levelConfigs = [
// Level 1 - Simple spikes
{
obstacles: [{
type: 'spike',
x: 600,
y: groundY
}, {
type: 'spike',
x: 1200,
y: groundY
}],
finish: 1800
},
// Level 2 - More spikes
{
obstacles: [{
type: 'spike',
x: 500,
y: groundY
}, {
type: 'spike',
x: 800,
y: groundY
}, {
type: 'spike',
x: 1100,
y: groundY
}],
finish: 1600
},
// Level 3 - Moving platform
{
obstacles: [{
type: 'movingPlatform',
x: 700,
y: groundY - 200
}, {
type: 'spike',
x: 1400,
y: groundY
}],
finish: 1800
},
// Level 4 - Multiple moving platforms
{
obstacles: [{
type: 'movingPlatform',
x: 500,
y: groundY - 150
}, {
type: 'movingPlatform',
x: 1000,
y: groundY - 250
}],
finish: 1600
},
// Level 5 - Mixed obstacles
{
obstacles: [{
type: 'spike',
x: 400,
y: groundY
}, {
type: 'movingPlatform',
x: 700,
y: groundY - 180
}, {
type: 'spike',
x: 1200,
y: groundY
}],
finish: 1800
},
// Level 6 - Dense spikes
{
obstacles: [{
type: 'spike',
x: 400,
y: groundY
}, {
type: 'spike',
x: 500,
y: groundY
}, {
type: 'spike',
x: 700,
y: groundY
}, {
type: 'spike',
x: 800,
y: groundY
}],
finish: 1200
},
// Level 7 - Fast moving platforms
{
obstacles: [{
type: 'movingPlatform',
x: 500,
y: groundY - 200
}, {
type: 'movingPlatform',
x: 900,
y: groundY - 150
}, {
type: 'spike',
x: 1300,
y: groundY
}],
finish: 1600
},
// Level 8 - High platforms
{
obstacles: [{
type: 'movingPlatform',
x: 400,
y: groundY - 300
}, {
type: 'movingPlatform',
x: 800,
y: groundY - 400
}, {
type: 'spike',
x: 1200,
y: groundY
}],
finish: 1500
},
// Level 9 - Complex pattern
{
obstacles: [{
type: 'spike',
x: 350,
y: groundY
}, {
type: 'movingPlatform',
x: 600,
y: groundY - 250
}, {
type: 'spike',
x: 900,
y: groundY
}, {
type: 'movingPlatform',
x: 1200,
y: groundY - 180
}],
finish: 1600
},
// Level 10 - Final challenge
{
obstacles: [{
type: 'spike',
x: 300,
y: groundY
}, {
type: 'spike',
x: 400,
y: groundY
}, {
type: 'movingPlatform',
x: 650,
y: groundY - 300
}, {
type: 'movingPlatform',
x: 1000,
y: groundY - 200
}, {
type: 'spike',
x: 1300,
y: groundY
}, {
type: 'spike',
x: 1400,
y: groundY
}],
finish: 1800
}];
function initializeLevel(level) {
// Clear existing obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].destroy();
obstacles.splice(i, 1);
}
if (finishFlag) {
finishFlag.destroy();
}
// Create new obstacles based on level config
var config = levelConfigs[level - 1];
for (var j = 0; j < config.obstacles.length; j++) {
var obstacleConfig = config.obstacles[j];
var obstacle = new Obstacle(obstacleConfig.type, obstacleConfig.x, obstacleConfig.y);
if (obstacleConfig.type === 'movingPlatform' && level >= 7) {
obstacle.speed = 3; // Faster platforms in later levels
}
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Create finish flag
finishFlag = new FinishFlag(config.finish, groundY);
game.addChild(finishFlag);
// Reset player position
player.x = 200;
player.y = groundY;
player.velocityX = 0;
player.velocityY = 0;
player.isGrounded = true;
// Update UI
levelText.setText('Level ' + level);
livesText.setText('Lives: ' + lives);
isGameActive = true;
}
function resetLevel() {
lives--;
livesText.setText('Lives: ' + lives);
if (lives <= 0) {
LK.showGameOver();
return;
}
// Flash screen red
LK.effects.flashScreen(0xff0000, 500);
// Reset player position after a short delay
LK.setTimeout(function () {
player.x = 200;
player.y = groundY;
player.velocityX = 0;
player.velocityY = 0;
player.isGrounded = true;
isGameActive = true;
}, 500);
}
function completeLevel() {
LK.getSound('levelComplete').play();
LK.effects.flashScreen(0x00ff00, 800);
if (currentLevel >= maxLevels) {
// Game completed
LK.setTimeout(function () {
LK.showYouWin();
}, 800);
} else {
currentLevel++;
LK.setTimeout(function () {
initializeLevel(currentLevel);
}, 800);
}
}
// Initialize game
createGround();
player = new StickFigure();
game.addChild(player);
initializeLevel(currentLevel);
// Game controls
game.down = function (x, y, obj) {
if (isGameActive) {
player.jump();
}
};
var dragStartX = 0;
var isDragging = false;
game.move = function (x, y, obj) {
if (isGameActive && isDragging) {
var deltaX = x - dragStartX;
if (deltaX < -50) {
player.moveLeft();
} else if (deltaX > 50) {
player.moveRight();
}
} else if (isGameActive) {
dragStartX = x;
isDragging = true;
}
};
game.up = function (x, y, obj) {
isDragging = false;
};
// Game update loop
game.update = function () {
if (!isGameActive) return;
// Check obstacle collisions
for (var i = 0; i < obstacles.length; i++) {
var obstacle = obstacles[i];
if (obstacle.obstacleType === 'spike') {
if (player.intersects(obstacle)) {
LK.getSound('death').play();
isGameActive = false;
resetLevel();
return;
}
} else if (obstacle.obstacleType === 'movingPlatform') {
// Simple platform collision - if player is above platform
if (player.intersects(obstacle) && player.velocityY >= 0 && player.y - 60 <= obstacle.y - 15) {
player.y = obstacle.y - 15;
player.velocityY = 0;
player.isGrounded = true;
}
}
}
// Check finish flag collision
if (finishFlag && player.intersects(finishFlag)) {
isGameActive = false;
completeLevel();
}
// Keep player on screen
if (player.x < 0) {
player.x = 0;
player.velocityX = 0;
}
if (player.x > 2048) {
player.x = 2048;
player.velocityX = 0;
}
// Check if player fell off screen
if (player.y > groundY + 200) {
LK.getSound('death').play();
isGameActive = false;
resetLevel();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,454 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var FinishFlag = Container.expand(function (x, y) {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('finishFlag', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.x = x;
+ self.y = y;
+ return self;
+});
+var Obstacle = Container.expand(function (type, x, y) {
+ var self = Container.call(this);
+ self.obstacleType = type;
+ if (type === 'spike') {
+ var graphics = self.attachAsset('spike', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ } else if (type === 'movingPlatform') {
+ var graphics = self.attachAsset('movingPlatform', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.direction = 1;
+ self.speed = 2;
+ self.startX = x;
+ self.range = 200;
+ }
+ self.x = x;
+ self.y = y;
+ self.update = function () {
+ if (self.obstacleType === 'movingPlatform') {
+ self.x += self.direction * self.speed;
+ if (self.x > self.startX + self.range || self.x < self.startX - self.range) {
+ self.direction *= -1;
+ }
+ }
+ };
+ return self;
+});
+var StickFigure = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('stickFigure', {
+ anchorX: 0.5,
+ anchorY: 1.0
+ });
+ self.velocityY = 0;
+ self.velocityX = 0;
+ self.isGrounded = false;
+ self.jumpPower = -25;
+ self.gravity = 1.2;
+ self.speed = 8;
+ self.update = function () {
+ // Apply gravity
+ self.velocityY += self.gravity;
+ // Apply velocity
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ // Reduce horizontal velocity (friction)
+ self.velocityX *= 0.85;
+ // Ground collision
+ if (self.y >= groundY) {
+ self.y = groundY;
+ self.velocityY = 0;
+ self.isGrounded = true;
+ }
+ };
+ self.jump = function () {
+ if (self.isGrounded) {
+ self.velocityY = self.jumpPower;
+ self.isGrounded = false;
+ LK.getSound('jump').play();
+ }
+ };
+ self.moveLeft = function () {
+ self.velocityX = -self.speed;
+ };
+ self.moveRight = function () {
+ self.velocityX = self.speed;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var currentLevel = 1;
+var maxLevels = 10;
+var groundY = 2500;
+var player;
+var obstacles = [];
+var finishFlag;
+var isGameActive = true;
+var lives = 3;
+// UI Elements
+var levelText = new Text2('Level 1', {
+ size: 80,
+ fill: 0x000000
+});
+levelText.anchor.set(0.5, 0);
+LK.gui.top.addChild(levelText);
+var livesText = new Text2('Lives: 3', {
+ size: 60,
+ fill: 0xFF0000
+});
+livesText.anchor.set(1, 0);
+LK.gui.topRight.addChild(livesText);
+// Create ground platforms
+function createGround() {
+ for (var i = 0; i < 15; i++) {
+ var groundPiece = LK.getAsset('ground', {
+ anchorX: 0,
+ anchorY: 1.0
+ });
+ groundPiece.x = i * 300;
+ groundPiece.y = groundY;
+ game.addChild(groundPiece);
+ }
+}
+// Level configurations
+var levelConfigs = [
+// Level 1 - Simple spikes
+{
+ obstacles: [{
+ type: 'spike',
+ x: 600,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 1200,
+ y: groundY
+ }],
+ finish: 1800
+},
+// Level 2 - More spikes
+{
+ obstacles: [{
+ type: 'spike',
+ x: 500,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 800,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 1100,
+ y: groundY
+ }],
+ finish: 1600
+},
+// Level 3 - Moving platform
+{
+ obstacles: [{
+ type: 'movingPlatform',
+ x: 700,
+ y: groundY - 200
+ }, {
+ type: 'spike',
+ x: 1400,
+ y: groundY
+ }],
+ finish: 1800
+},
+// Level 4 - Multiple moving platforms
+{
+ obstacles: [{
+ type: 'movingPlatform',
+ x: 500,
+ y: groundY - 150
+ }, {
+ type: 'movingPlatform',
+ x: 1000,
+ y: groundY - 250
+ }],
+ finish: 1600
+},
+// Level 5 - Mixed obstacles
+{
+ obstacles: [{
+ type: 'spike',
+ x: 400,
+ y: groundY
+ }, {
+ type: 'movingPlatform',
+ x: 700,
+ y: groundY - 180
+ }, {
+ type: 'spike',
+ x: 1200,
+ y: groundY
+ }],
+ finish: 1800
+},
+// Level 6 - Dense spikes
+{
+ obstacles: [{
+ type: 'spike',
+ x: 400,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 500,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 700,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 800,
+ y: groundY
+ }],
+ finish: 1200
+},
+// Level 7 - Fast moving platforms
+{
+ obstacles: [{
+ type: 'movingPlatform',
+ x: 500,
+ y: groundY - 200
+ }, {
+ type: 'movingPlatform',
+ x: 900,
+ y: groundY - 150
+ }, {
+ type: 'spike',
+ x: 1300,
+ y: groundY
+ }],
+ finish: 1600
+},
+// Level 8 - High platforms
+{
+ obstacles: [{
+ type: 'movingPlatform',
+ x: 400,
+ y: groundY - 300
+ }, {
+ type: 'movingPlatform',
+ x: 800,
+ y: groundY - 400
+ }, {
+ type: 'spike',
+ x: 1200,
+ y: groundY
+ }],
+ finish: 1500
+},
+// Level 9 - Complex pattern
+{
+ obstacles: [{
+ type: 'spike',
+ x: 350,
+ y: groundY
+ }, {
+ type: 'movingPlatform',
+ x: 600,
+ y: groundY - 250
+ }, {
+ type: 'spike',
+ x: 900,
+ y: groundY
+ }, {
+ type: 'movingPlatform',
+ x: 1200,
+ y: groundY - 180
+ }],
+ finish: 1600
+},
+// Level 10 - Final challenge
+{
+ obstacles: [{
+ type: 'spike',
+ x: 300,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 400,
+ y: groundY
+ }, {
+ type: 'movingPlatform',
+ x: 650,
+ y: groundY - 300
+ }, {
+ type: 'movingPlatform',
+ x: 1000,
+ y: groundY - 200
+ }, {
+ type: 'spike',
+ x: 1300,
+ y: groundY
+ }, {
+ type: 'spike',
+ x: 1400,
+ y: groundY
+ }],
+ finish: 1800
+}];
+function initializeLevel(level) {
+ // Clear existing obstacles
+ for (var i = obstacles.length - 1; i >= 0; i--) {
+ obstacles[i].destroy();
+ obstacles.splice(i, 1);
+ }
+ if (finishFlag) {
+ finishFlag.destroy();
+ }
+ // Create new obstacles based on level config
+ var config = levelConfigs[level - 1];
+ for (var j = 0; j < config.obstacles.length; j++) {
+ var obstacleConfig = config.obstacles[j];
+ var obstacle = new Obstacle(obstacleConfig.type, obstacleConfig.x, obstacleConfig.y);
+ if (obstacleConfig.type === 'movingPlatform' && level >= 7) {
+ obstacle.speed = 3; // Faster platforms in later levels
+ }
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
+ }
+ // Create finish flag
+ finishFlag = new FinishFlag(config.finish, groundY);
+ game.addChild(finishFlag);
+ // Reset player position
+ player.x = 200;
+ player.y = groundY;
+ player.velocityX = 0;
+ player.velocityY = 0;
+ player.isGrounded = true;
+ // Update UI
+ levelText.setText('Level ' + level);
+ livesText.setText('Lives: ' + lives);
+ isGameActive = true;
+}
+function resetLevel() {
+ lives--;
+ livesText.setText('Lives: ' + lives);
+ if (lives <= 0) {
+ LK.showGameOver();
+ return;
+ }
+ // Flash screen red
+ LK.effects.flashScreen(0xff0000, 500);
+ // Reset player position after a short delay
+ LK.setTimeout(function () {
+ player.x = 200;
+ player.y = groundY;
+ player.velocityX = 0;
+ player.velocityY = 0;
+ player.isGrounded = true;
+ isGameActive = true;
+ }, 500);
+}
+function completeLevel() {
+ LK.getSound('levelComplete').play();
+ LK.effects.flashScreen(0x00ff00, 800);
+ if (currentLevel >= maxLevels) {
+ // Game completed
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 800);
+ } else {
+ currentLevel++;
+ LK.setTimeout(function () {
+ initializeLevel(currentLevel);
+ }, 800);
+ }
+}
+// Initialize game
+createGround();
+player = new StickFigure();
+game.addChild(player);
+initializeLevel(currentLevel);
+// Game controls
+game.down = function (x, y, obj) {
+ if (isGameActive) {
+ player.jump();
+ }
+};
+var dragStartX = 0;
+var isDragging = false;
+game.move = function (x, y, obj) {
+ if (isGameActive && isDragging) {
+ var deltaX = x - dragStartX;
+ if (deltaX < -50) {
+ player.moveLeft();
+ } else if (deltaX > 50) {
+ player.moveRight();
+ }
+ } else if (isGameActive) {
+ dragStartX = x;
+ isDragging = true;
+ }
+};
+game.up = function (x, y, obj) {
+ isDragging = false;
+};
+// Game update loop
+game.update = function () {
+ if (!isGameActive) return;
+ // Check obstacle collisions
+ for (var i = 0; i < obstacles.length; i++) {
+ var obstacle = obstacles[i];
+ if (obstacle.obstacleType === 'spike') {
+ if (player.intersects(obstacle)) {
+ LK.getSound('death').play();
+ isGameActive = false;
+ resetLevel();
+ return;
+ }
+ } else if (obstacle.obstacleType === 'movingPlatform') {
+ // Simple platform collision - if player is above platform
+ if (player.intersects(obstacle) && player.velocityY >= 0 && player.y - 60 <= obstacle.y - 15) {
+ player.y = obstacle.y - 15;
+ player.velocityY = 0;
+ player.isGrounded = true;
+ }
+ }
+ }
+ // Check finish flag collision
+ if (finishFlag && player.intersects(finishFlag)) {
+ isGameActive = false;
+ completeLevel();
+ }
+ // Keep player on screen
+ if (player.x < 0) {
+ player.x = 0;
+ player.velocityX = 0;
+ }
+ if (player.x > 2048) {
+ player.x = 2048;
+ player.velocityX = 0;
+ }
+ // Check if player fell off screen
+ if (player.y > groundY + 200) {
+ LK.getSound('death').play();
+ isGameActive = false;
+ resetLevel();
+ }
+};
\ No newline at end of file