User prompt
Put the word jump on the left side of the screen and put the word shoot on the right side of the screen
User prompt
Size the enemy and the obstacle up, but keep the collision the way that it is
User prompt
Make it so if the player jumps over the target and doesn’t shoot it, they lose
User prompt
When the player jumps move the crosshair up a little and then move it back to the bottom
User prompt
When the player jumps keep the crosshair at the bottom of the screen
User prompt
Move the crosshair up by 50
User prompt
Move the crosshair to the bottom of the screen
User prompt
Move the crosshair down a little bit
User prompt
Size down the crosshair by 500
User prompt
Size up the crosshair by 1000
User prompt
Make the crosshair not transparent
User prompt
Size up the crosshair by 100
User prompt
Size up the crosshair
User prompt
Make it so wherever you click on the right side of the screen, it shoots the bullet, and wherever you clicked on the left side of the screen, it jumps
User prompt
Put a blue button on the left side of the screen and a green button on the right side of the screen and make them small towards the bottom
Code edit (1 edits merged)
Please save this source code
User prompt
Forward Assault: First Person Rush
Initial prompt
Make a first person game with two buttons, one to jump and one to shoot enemies that are coming forward towards you
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Bullet: moves from player to horizon
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGfx = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.z = 0; // 0 = at player, 1 = at horizon
self.speed = 0.045;
self.alive = true;
self.type = 'bullet';
self.update = function () {
if (!self.alive) return;
self.z += self.speed;
var horizonY = 700;
var playerY = 2000;
var centerX = 1024;
self.x = centerX;
self.y = horizonY + (playerY - horizonY) * (1 - self.z);
var minScale = 0.18,
maxScale = 0.7;
var scale = minScale + (maxScale - minScale) * (1 - self.z);
self.scaleX = self.scaleY = scale;
bulletGfx.alpha = Math.min(1, 0.3 + 0.7 * (1 - self.z));
};
self.destroyBullet = function () {
self.alive = false;
self.visible = false;
self.destroy();
};
return self;
});
// Enemy approaches from horizon to player
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGfx = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.z = 0; // 0 = at player, 1 = at horizon
self.speed = 0.008 + Math.random() * 0.004; // z per tick
self.alive = true;
self.type = 'enemy';
// For collision, we use .z and .x
self.update = function () {
if (!self.alive) return;
self.z -= self.speed;
// Perspective: as z decreases, enemy appears larger and closer to center
var horizonY = 700;
var playerY = 2000;
var centerX = 1024;
// Lerp position
self.x = centerX;
self.y = horizonY + (playerY - horizonY) * (1 - self.z);
// Lerp scale
var minScale = 0.25,
maxScale = 1.2;
var scale = minScale + (maxScale - minScale) * (1 - self.z);
self.scaleX = self.scaleY = scale;
// Fade in as it approaches
enemyGfx.alpha = Math.min(1, 0.3 + 0.7 * (1 - self.z));
};
self.destroyEnemy = function () {
self.alive = false;
self.visible = false;
self.destroy();
};
return self;
});
// Jump effect: quick effect at player
var JumpEffect = Container.expand(function () {
var self = Container.call(this);
var jumpGfx = self.attachAsset('jumpEffect', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 1024;
self.y = 2000;
self.scaleX = 1.1;
self.scaleY = 1.1;
jumpGfx.alpha = 0.7;
tween(self, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 220,
easing: tween.cubicOut,
onFinish: function onFinish() {
self.destroy();
}
});
return self;
});
// Muzzle flash: quick effect at player
var MuzzleFlash = Container.expand(function () {
var self = Container.call(this);
var muzzleGfx = self.attachAsset('muzzle', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 1024;
self.y = 1850;
self.scaleX = 1.2;
self.scaleY = 1.2;
muzzleGfx.alpha = 0.8;
// Fade out quickly
tween(self, {
scaleX: 2,
scaleY: 2,
alpha: 0
}, {
duration: 180,
easing: tween.cubicOut,
onFinish: function onFinish() {
self.destroy();
}
});
return self;
});
// Obstacle approaches from horizon to player
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obsGfx = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.z = 0;
self.speed = 0.009 + Math.random() * 0.003;
self.alive = true;
self.type = 'obstacle';
// Random horizontal offset
self.offsetX = (Math.random() - 0.5) * 600;
self.update = function () {
if (!self.alive) return;
self.z -= self.speed;
var horizonY = 700;
var playerY = 2000;
var centerX = 1024;
self.x = centerX + self.offsetX * (1 - self.z);
self.y = horizonY + (playerY - horizonY) * (1 - self.z);
var minScale = 0.18,
maxScale = 1.1;
var scale = minScale + (maxScale - minScale) * (1 - self.z);
self.scaleX = self.scaleY = scale;
obsGfx.alpha = Math.min(1, 0.3 + 0.7 * (1 - self.z));
};
self.destroyObstacle = function () {
self.alive = false;
self.visible = false;
self.destroy();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x181c22
});
/****
* Game Code
****/
// Enemies: green box, Obstacles: gray box, Bullet: yellow ellipse, Muzzle flash: orange ellipse, Jump effect: blue ellipse, Horizon: thin white box
// Play background music
LK.playMusic('bgmusic');
// Horizon line
var horizonLine = LK.getAsset('horizon', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 700
});
game.addChild(horizonLine);
// Crosshair (for visual feedback)
var crosshair = LK.getAsset('crosshair', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1400,
scaleX: 1,
scaleY: 1
});
crosshair.alpha = 0.18;
game.addChild(crosshair);
// Score text
var scoreTxt = new Text2('0', {
size: 120,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Two on-screen buttons: Blue (left), Green (right), small and at the bottom
var btnJump = new Container();
var btnJumpBg = LK.getAsset('jumpEffect', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
scaleX: 1.1,
scaleY: 1.1,
color: 0x2196F3 // blue
});
btnJumpBg.alpha = 0.85;
btnJump.addChild(btnJumpBg);
btnJump.x = 180;
btnJump.y = 2630;
btnJump.width = btnJumpBg.width * btnJumpBg.scaleX;
btnJump.height = btnJumpBg.height * btnJumpBg.scaleY;
LK.gui.bottom.addChild(btnJump);
var btnShoot = new Container();
var btnShootBg = LK.getAsset('muzzle', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
scaleX: 1.1,
scaleY: 1.1,
color: 0x43A047 // green
});
btnShootBg.alpha = 0.85;
btnShoot.addChild(btnShootBg);
btnShoot.x = 2048 - 180;
btnShoot.y = 2630;
btnShoot.width = btnShootBg.width * btnShootBg.scaleX;
btnShoot.height = btnShootBg.height * btnShootBg.scaleY;
LK.gui.bottom.addChild(btnShoot);
// Button handlers (re-attach)
btnJump.down = function (x, y, obj) {
if (isJumping || gameOver) return;
isJumping = true;
jumpTicks = 0;
game.addChild(new JumpEffect());
LK.getSound('jump').play();
};
btnShoot.down = function (x, y, obj) {
if (gameOver) return;
shootBullet();
};
// Game state
var enemies = [];
var obstacles = [];
var bullets = [];
var isJumping = false;
var jumpTicks = 0;
var jumpDuration = 38; // ~0.6s
var spawnTick = 0;
var score = 0;
var gameOver = false;
// Helper: reset game state
function resetGame() {
for (var i = enemies.length - 1; i >= 0; i--) {
enemies[i].destroyEnemy();
}
for (var i = obstacles.length - 1; i >= 0; i--) {
obstacles[i].destroyObstacle();
}
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].destroyBullet();
}
enemies = [];
obstacles = [];
bullets = [];
isJumping = false;
jumpTicks = 0;
spawnTick = 0;
score = 0;
gameOver = false;
scoreTxt.setText('0');
}
// Button handlers
btnJump.down = function (x, y, obj) {
if (isJumping || gameOver) return;
isJumping = true;
jumpTicks = 0;
game.addChild(new JumpEffect());
LK.getSound('jump').play();
};
btnShoot.down = function (x, y, obj) {
if (gameOver) return;
shootBullet();
};
// Also allow whole right/left screen tap for controls
game.down = function (x, y, obj) {
if (gameOver) return;
if (x < 1024 && y > 2000) {
// Left bottom: jump
btnJump.down(x, y, obj);
} else if (x >= 1024 && y > 2000) {
// Right bottom: shoot
btnShoot.down(x, y, obj);
}
};
// Shoot bullet
function shootBullet() {
var b = new Bullet();
b.z = 0;
bullets.push(b);
game.addChild(b);
game.addChild(new MuzzleFlash());
LK.getSound('shoot').play();
}
// Spawn enemy or obstacle
function spawnEntity() {
// 60% enemy, 40% obstacle
if (Math.random() < 0.6) {
var e = new Enemy();
e.z = 1;
enemies.push(e);
game.addChild(e);
} else {
var o = new Obstacle();
o.z = 1;
obstacles.push(o);
game.addChild(o);
}
}
// Main update loop
game.update = function () {
if (gameOver) return;
// Handle jump
if (isJumping) {
jumpTicks++;
// Animate crosshair up
crosshair.y = 1400 - 180 * Math.sin(Math.PI * jumpTicks / jumpDuration);
if (jumpTicks >= jumpDuration) {
isJumping = false;
jumpTicks = 0;
crosshair.y = 1400;
}
}
// Spawn logic: every 60-90 ticks
spawnTick++;
if (spawnTick > 60 + Math.random() * 30) {
spawnEntity();
spawnTick = 0;
}
// Update enemies
for (var i = enemies.length - 1; i >= 0; i--) {
var e = enemies[i];
e.update();
if (!e.alive) {
enemies.splice(i, 1);
continue;
}
// If enemy reaches player (z <= 0)
if (e.z <= 0.04) {
// If jumping, dodge (score++)
if (isJumping) {
LK.getSound('dodge').play();
score++;
scoreTxt.setText(score + '');
e.destroyEnemy();
enemies.splice(i, 1);
continue;
}
// Not jumping: game over
LK.getSound('hit').play();
LK.effects.flashScreen(0xff0000, 900);
gameOver = true;
LK.showGameOver();
return;
}
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var o = obstacles[i];
o.update();
if (!o.alive) {
obstacles.splice(i, 1);
continue;
}
// If obstacle reaches player (z <= 0.04)
if (o.z <= 0.04) {
if (isJumping) {
// Jumped over: score++
LK.getSound('dodge').play();
score++;
scoreTxt.setText(score + '');
o.destroyObstacle();
obstacles.splice(i, 1);
continue;
}
// Not jumping: game over
LK.getSound('hit').play();
LK.effects.flashScreen(0xff0000, 900);
gameOver = true;
LK.showGameOver();
return;
}
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var b = bullets[i];
b.update();
if (!b.alive) {
bullets.splice(i, 1);
continue;
}
// If bullet reaches horizon, remove
if (b.z >= 1) {
b.destroyBullet();
bullets.splice(i, 1);
continue;
}
// Check collision with enemies (z diff < 0.08, x diff < 120)
for (var j = enemies.length - 1; j >= 0; j--) {
var e = enemies[j];
if (!e.alive) continue;
if (Math.abs(b.z - e.z) < 0.08 && Math.abs(b.x - e.x) < 120) {
// Hit!
LK.effects.flashObject(e, 0xffff00, 200);
e.destroyEnemy();
enemies.splice(j, 1);
b.destroyBullet();
bullets.splice(i, 1);
score++;
scoreTxt.setText(score + '');
break;
}
}
}
};
// Reset game state on game over
LK.on('gameover', function () {
resetGame();
});
// Reset game state on win (not used, but for completeness)
LK.on('youwin', function () {
resetGame();
}); ===================================================================
--- original.js
+++ change.js
@@ -199,45 +199,55 @@
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
-// Two on-screen buttons: Jump (left), Shoot (right)
-var btnJump = new Text2('JUMP', {
- size: 110,
- fill: 0x00BFFF
-});
-btnJump.anchor.set(0.5, 0.5);
-btnJump.x = 350;
-btnJump.y = 2500;
-btnJump.bg = LK.getAsset('jumpEffect', {
+// Two on-screen buttons: Blue (left), Green (right), small and at the bottom
+var btnJump = new Container();
+var btnJumpBg = LK.getAsset('jumpEffect', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
- scaleX: 2.2,
- scaleY: 2.2
+ scaleX: 1.1,
+ scaleY: 1.1,
+ color: 0x2196F3 // blue
});
-btnJump.bg.alpha = 0.18;
-btnJump.addChild(btnJump.bg);
+btnJumpBg.alpha = 0.85;
+btnJump.addChild(btnJumpBg);
+btnJump.x = 180;
+btnJump.y = 2630;
+btnJump.width = btnJumpBg.width * btnJumpBg.scaleX;
+btnJump.height = btnJumpBg.height * btnJumpBg.scaleY;
LK.gui.bottom.addChild(btnJump);
-var btnShoot = new Text2('SHOOT', {
- size: 110,
- fill: 0xFFB300
-});
-btnShoot.anchor.set(0.5, 0.5);
-btnShoot.x = 2048 - 350;
-btnShoot.y = 2500;
-btnShoot.bg = LK.getAsset('muzzle', {
+var btnShoot = new Container();
+var btnShootBg = LK.getAsset('muzzle', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0,
- scaleX: 2.2,
- scaleY: 2.2
+ scaleX: 1.1,
+ scaleY: 1.1,
+ color: 0x43A047 // green
});
-btnShoot.bg.alpha = 0.18;
-btnShoot.addChild(btnShoot.bg);
+btnShootBg.alpha = 0.85;
+btnShoot.addChild(btnShootBg);
+btnShoot.x = 2048 - 180;
+btnShoot.y = 2630;
+btnShoot.width = btnShootBg.width * btnShootBg.scaleX;
+btnShoot.height = btnShootBg.height * btnShootBg.scaleY;
LK.gui.bottom.addChild(btnShoot);
+// Button handlers (re-attach)
+btnJump.down = function (x, y, obj) {
+ if (isJumping || gameOver) return;
+ isJumping = true;
+ jumpTicks = 0;
+ game.addChild(new JumpEffect());
+ LK.getSound('jump').play();
+};
+btnShoot.down = function (x, y, obj) {
+ if (gameOver) return;
+ shootBullet();
+};
// Game state
var enemies = [];
var obstacles = [];
var bullets = [];
Make a pile of rocks with a grass patch in front of it and dirt scattered. In-Game asset. 2d. High contrast. No shadows
Bullet. In-Game asset. 2d. High contrast. No shadows
Bullet target. In-Game asset. 2d. High contrast. No shadows
A shotgun with a first person view of somebody holding it. In-Game asset. 2d. High contrast. No shadows