User prompt
Make the game more intriguing
User prompt
Make the cop faster
User prompt
When a new cop spawns make it play the Sound Spawn
User prompt
Make the background grey
User prompt
Make it play CashCollect when collected cash
User prompt
I want it so you can hold the player to move it
Initial prompt
Cash Thief
/****
* Classes
****/
var Cash = Container.expand(function () {
var self = Container.call(this);
var cashGraphics = self.attachAsset('cash', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Cash logic if needed
};
});
// Guard class
var Guard = Container.expand(function () {
var self = Container.call(this);
var guardGraphics = self.attachAsset('guard', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Guard movement logic will be handled in the game update loop
};
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerUpGraphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// PowerUp logic if needed
};
});
//<Assets used in the game will automatically appear here>
// Thief class
var Thief = Container.expand(function () {
var self = Container.call(this);
var thiefGraphics = self.attachAsset('thief', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Thief movement logic will be handled in the game update loop
};
});
// Trap class
var Trap = Container.expand(function () {
var self = Container.call(this);
var trapGraphics = self.attachAsset('trap', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Trap logic if needed
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x808080 //Init game with grey background
});
/****
* Game Code
****/
function spawnPowerUp() {
var powerUp = new PowerUp();
powerUp.x = Math.random() * 2048;
powerUp.y = Math.random() * 2732;
powerUps.push(powerUp);
game.addChild(powerUp);
}
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
var thief = game.addChild(new Thief());
thief.x = 1024;
thief.y = 1366;
var cashItems = [];
var traps = [];
var guards = [];
var powerUps = [];
var score = 0;
var scoreMultiplier = 1;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
function spawnCash() {
var cash = new Cash();
cash.x = Math.random() * 2048;
cash.y = Math.random() * 2732;
cashItems.push(cash);
game.addChild(cash);
}
function spawnTrap() {
var trap = new Trap();
trap.x = Math.random() * 2048;
trap.y = Math.random() * 2732;
traps.push(trap);
game.addChild(trap);
}
function spawnGuard() {
var guard = new Guard();
guard.x = Math.random() * 2048;
guard.y = Math.random() * 2732;
guards.push(guard);
game.addChild(guard);
}
var dragNode = null;
game.down = function (x, y, obj) {
dragNode = thief;
thief.x = x;
thief.y = y;
};
game.update = function () {
for (var i = cashItems.length - 1; i >= 0; i--) {
if (thief.intersects(cashItems[i])) {
score += 10 * scoreMultiplier;
LK.setScore(score);
scoreTxt.setText(score);
cashItems[i].destroy();
cashItems.splice(i, 1);
LK.getSound('CashCollect').play();
}
}
for (var i = traps.length - 1; i >= 0; i--) {
if (thief.intersects(traps[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
for (var i = guards.length - 1; i >= 0; i--) {
if (thief.intersects(guards[i])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
}
if (LK.ticks % 120 == 0) {
spawnCash();
}
if (LK.ticks % 300 == 0) {
spawnTrap();
}
if (LK.ticks % 600 == 0) {
spawnGuard();
LK.getSound('Spawn').play();
}
if (LK.ticks % 900 == 0) {
spawnPowerUp();
}
for (var i = powerUps.length - 1; i >= 0; i--) {
if (thief.intersects(powerUps[i])) {
scoreMultiplier = 2;
LK.getSound('PowerUpCollect').play();
powerUps[i].destroy();
powerUps.splice(i, 1);
LK.setTimeout(function () {
scoreMultiplier = 1;
}, 10000);
}
}
guards.forEach(function (guard) {
if (thief.x > guard.x) {
guard.x += guard.speed;
} else {
guard.x -= guard.speed;
}
if (thief.y > guard.y) {
guard.y += guard.speed;
} else {
guard.y -= guard.speed;
}
});
}; ===================================================================
--- original.js
+++ change.js
@@ -22,8 +22,18 @@
self.update = function () {
// Guard movement logic will be handled in the game update loop
};
});
+var PowerUp = Container.expand(function () {
+ var self = Container.call(this);
+ var powerUpGraphics = self.attachAsset('powerUp', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // PowerUp logic if needed
+ };
+});
//<Assets used in the game will automatically appear here>
// Thief class
var Thief = Container.expand(function () {
var self = Container.call(this);
@@ -57,8 +67,15 @@
/****
* Game Code
****/
+function spawnPowerUp() {
+ var powerUp = new PowerUp();
+ powerUp.x = Math.random() * 2048;
+ powerUp.y = Math.random() * 2732;
+ powerUps.push(powerUp);
+ game.addChild(powerUp);
+}
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
@@ -72,9 +89,11 @@
thief.y = 1366;
var cashItems = [];
var traps = [];
var guards = [];
+var powerUps = [];
var score = 0;
+var scoreMultiplier = 1;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
@@ -109,9 +128,9 @@
};
game.update = function () {
for (var i = cashItems.length - 1; i >= 0; i--) {
if (thief.intersects(cashItems[i])) {
- score += 10;
+ score += 10 * scoreMultiplier;
LK.setScore(score);
scoreTxt.setText(score);
cashItems[i].destroy();
cashItems.splice(i, 1);
@@ -139,8 +158,22 @@
if (LK.ticks % 600 == 0) {
spawnGuard();
LK.getSound('Spawn').play();
}
+ if (LK.ticks % 900 == 0) {
+ spawnPowerUp();
+ }
+ for (var i = powerUps.length - 1; i >= 0; i--) {
+ if (thief.intersects(powerUps[i])) {
+ scoreMultiplier = 2;
+ LK.getSound('PowerUpCollect').play();
+ powerUps[i].destroy();
+ powerUps.splice(i, 1);
+ LK.setTimeout(function () {
+ scoreMultiplier = 1;
+ }, 10000);
+ }
+ }
guards.forEach(function (guard) {
if (thief.x > guard.x) {
guard.x += guard.speed;
} else {
A security guard. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A stack of money. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A thief with a mask and steal bag. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A trap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Powerup about cash. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.