User prompt
replace the street lights in the game with the Streetlamp file in the files
User prompt
Scort text and score counter make a unified
User prompt
Make the score count more animated and red ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
replace the Score text in the game with the Score file in the files
User prompt
Do not show score and wave texts in the main menu, only show them when you are in the game
User prompt
make more hd
User prompt
replace STREET BATTLE text in main menu with streetbattle file in files
User prompt
replace the play button image with the play button image in the files
User prompt
play button a has like a gun
User prompt
add a main menu
User prompt
make street lamps on the road side
User prompt
Put street lights only on the side of the road
User prompt
add street lamps
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'setText')' in or related to this line: 'waveTxt.setText('Wave: ' + currentWave);' Line Number: 224
User prompt
add wave logic
User prompt
distribute cars randomly and to distant points
User prompt
distribute cars randomly
User prompt
distribute cars randomly
User prompt
add a burning cars
User prompt
make a a barrier with yellow stripes
User prompt
make background a street
User prompt
make background a *dead end*
Code edit (1 edits merged)
Please save this source code
User prompt
Gangsters vs Police: Street Showdown
User prompt
Gangasters Vs Polices
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BurningCar = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('burningCar', {
anchorX: 0.5,
anchorY: 0.5
});
return self;
});
var Gangster = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('gangster', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.shootTimer = 0;
self.shootInterval = 90 + Math.random() * 60;
self.targetX = player.x;
self.targetY = player.y;
self.update = function () {
// Move toward player
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
// Shooting logic
self.shootTimer++;
if (self.shootTimer >= self.shootInterval) {
self.shootTimer = 0;
var bullet = new GangsterBullet();
bullet.x = self.x;
bullet.y = self.y;
bullet.lastY = bullet.y;
bullet.lastIntersecting = false;
gangsterBullets.push(bullet);
game.addChild(bullet);
LK.getSound('enemyShoot').play();
}
};
return self;
});
var GangsterBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('gangsterBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 8;
self.update = function () {
self.y += self.speed;
};
return self;
});
var Player = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('policeOfficer', {
anchorX: 0.5,
anchorY: 0.5
});
self.isAlive = true;
return self;
});
var PoliceBullet = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('policeBullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -15;
self.update = function () {
self.y += self.speed;
};
return self;
});
var StreetLamp = Container.expand(function () {
var self = Container.call(this);
// Create lamp post (vertical pole)
var post = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 1,
scaleX: 0.15,
scaleY: 4,
x: 0,
y: 0
});
post.tint = 0x4a4a4a;
self.addChild(post);
// Create lamp head (top part)
var lampHead = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.4,
x: 0,
y: -300
});
lampHead.tint = 0x2c2c2c;
self.addChild(lampHead);
// Create light glow effect
var glow = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.2,
scaleY: 0.3,
x: 0,
y: -280
});
glow.tint = 0xfff4a3;
glow.alpha = 0.4;
self.addChild(glow);
return self;
});
var YellowBarrier = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 0.5
});
// Add black stripes
for (var i = 0; i < 5; i++) {
var stripe = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.1,
scaleY: 1,
x: -80 + i * 40,
y: 0
});
stripe.tint = 0x000000;
self.addChild(stripe);
}
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2c3e50
});
/****
* Game Code
****/
// Add street background
var background = game.addChild(LK.getAsset('streetBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 200;
var policeBullets = [];
var gangsterBullets = [];
var gangsters = [];
var barriers = [];
var burningCars = [];
var streetLamps = [];
var waveTimer = 0;
var spawnTimer = 0;
var difficulty = 1;
var dragNode = null;
var currentWave = 1;
var gangstersToSpawn = 3;
var gangstersSpawned = 0;
var waveInProgress = false;
var waveCompleted = false;
var waveCompletionTimer = 0;
var gameState = 'menu'; // 'menu', 'playing', 'paused'
var menuContainer = null;
var titleText = null;
var playButton = null;
var instructionsText = null;
// Create barriers
for (var i = 0; i < 4; i++) {
var barrier = new YellowBarrier();
barrier.x = 400 + i * 400;
barrier.y = 1500;
barriers.push(barrier);
game.addChild(barrier);
}
// Create street lamps positioned on the road sides
var lampPositions = [];
// Left side of the road
for (var i = 0; i < 8; i++) {
lampPositions.push({
x: 200,
y: 300 + i * 300
});
}
// Right side of the road
for (var i = 0; i < 8; i++) {
lampPositions.push({
x: 1848,
y: 300 + i * 300
});
}
for (var i = 0; i < lampPositions.length; i++) {
var lamp = new StreetLamp();
lamp.x = lampPositions[i].x;
lamp.y = lampPositions[i].y;
streetLamps.push(lamp);
game.addChild(lamp);
}
// Create burning cars with distant random distribution
var carPositions = [];
for (var i = 0; i < 5; i++) {
var burningCar = new BurningCar();
var validPosition = false;
var attempts = 0;
// Keep trying until we find a position that's far enough from other cars
while (!validPosition && attempts < 50) {
burningCar.x = 200 + Math.random() * 1648; // Random X position across street width
burningCar.y = 400 + Math.random() * 1000; // Random Y position in middle area
// Ensure cars don't spawn too close to barriers (around y=1500)
if (burningCar.y > 1350 && burningCar.y < 1650) {
burningCar.y = burningCar.y < 1500 ? 1250 : 1750;
}
// Check distance from other cars (minimum 400 pixels apart)
validPosition = true;
for (var j = 0; j < carPositions.length; j++) {
var dx = burningCar.x - carPositions[j].x;
var dy = burningCar.y - carPositions[j].y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 400) {
validPosition = false;
break;
}
}
attempts++;
}
// Store position for distance checking
carPositions.push({
x: burningCar.x,
y: burningCar.y
});
burningCars.push(burningCar);
game.addChild(burningCar);
}
// Score display
var scoreTxt = new Text2('Score: 0', {
size: 100,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Wave display
var waveTxt = new Text2('Wave: 1', {
size: 80,
fill: 0xFFD700
});
waveTxt.anchor.set(0.5, 0);
waveTxt.y = 120;
LK.gui.top.addChild(waveTxt);
// Create main menu
createMainMenu();
function createMainMenu() {
// Create menu container
menuContainer = new Container();
game.addChild(menuContainer);
// Create semi-transparent background overlay
var overlay = LK.getAsset('yellowBarrier', {
anchorX: 0,
anchorY: 0,
scaleX: 8,
scaleY: 26,
x: 0,
y: 0
});
overlay.tint = 0x000000;
overlay.alpha = 0.7;
menuContainer.addChild(overlay);
// Create title text
titleText = new Text2('STREET BATTLE', {
size: 150,
fill: 0xFFD700
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 800;
menuContainer.addChild(titleText);
// Create gun-shaped play button
playButton = new Container();
playButton.x = 2048 / 2;
playButton.y = 1200;
menuContainer.addChild(playButton);
// Gun barrel (horizontal rectangle)
var gunBarrel = LK.getAsset('yellowBarrier', {
anchorX: 0,
anchorY: 0.5,
scaleX: 2,
scaleY: 0.3,
x: -100,
y: 0
});
gunBarrel.tint = 0x333333;
playButton.addChild(gunBarrel);
// Gun handle (vertical rectangle)
var gunHandle = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 0,
scaleX: 0.8,
scaleY: 1.5,
x: -60,
y: 0
});
gunHandle.tint = 0x444444;
playButton.addChild(gunHandle);
// Gun trigger guard (small rectangle)
var triggerGuard = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.4,
scaleY: 0.4,
x: -40,
y: 30
});
triggerGuard.tint = 0x222222;
playButton.addChild(triggerGuard);
// Gun sight (small rectangle on top)
var gunSight = LK.getAsset('yellowBarrier', {
anchorX: 0.5,
anchorY: 1,
scaleX: 0.2,
scaleY: 0.3,
x: 50,
y: -15
});
gunSight.tint = 0x555555;
playButton.addChild(gunSight);
// Create play button text
var playButtonText = new Text2('PLAY', {
size: 80,
fill: 0xFFFFFF
});
playButtonText.anchor.set(0.5, 0.5);
playButtonText.x = 0;
playButtonText.y = -80;
playButton.addChild(playButtonText);
// Create instructions text
instructionsText = new Text2('Drag to move and shoot\nDefeat all gangsters to advance waves', {
size: 60,
fill: 0xFFFFFF
});
instructionsText.anchor.set(0.5, 0.5);
instructionsText.x = 2048 / 2;
instructionsText.y = 1500;
menuContainer.addChild(instructionsText);
// Add click handler for play button
playButton.down = function (x, y, obj) {
startGame();
};
}
function startGame() {
// Remove menu
if (menuContainer) {
menuContainer.destroy();
menuContainer = null;
}
// Set game state to playing
gameState = 'playing';
// Initialize wave system
startWave();
}
function startWave() {
waveInProgress = true;
waveCompleted = false;
waveCompletionTimer = 0;
gangstersSpawned = 0;
gangstersToSpawn = 2 + currentWave * 2; // More gangsters each wave
difficulty = Math.floor(currentWave / 2) + 1; // Difficulty increases every 2 waves
waveTxt.setText('Wave: ' + currentWave);
}
function spawnGangster() {
var gangster = new Gangster();
// Random spawn position from top and sides
var spawnSide = Math.random();
if (spawnSide < 0.5) {
// Spawn from top
gangster.x = Math.random() * 1800 + 124;
gangster.y = 100;
} else if (spawnSide < 0.75) {
// Spawn from left
gangster.x = 100;
gangster.y = Math.random() * 1000 + 200;
} else {
// Spawn from right
gangster.x = 1948;
gangster.y = Math.random() * 1000 + 200;
}
gangster.targetX = player.x;
gangster.targetY = player.y;
gangster.lastIntersecting = false;
gangsters.push(gangster);
game.addChild(gangster);
gangstersSpawned++;
}
function handleMove(x, y, obj) {
if (dragNode && dragNode.isAlive) {
dragNode.x = Math.max(50, Math.min(1998, x));
dragNode.y = Math.max(200, Math.min(2732 - 100, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
if (gameState === 'playing' && player.isAlive) {
// Set drag node to player
dragNode = player;
handleMove(x, y, obj);
// Shoot bullet
var bullet = new PoliceBullet();
bullet.x = player.x;
bullet.y = player.y - 40;
bullet.lastY = bullet.y;
bullet.lastIntersecting = false;
policeBullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
game.update = function () {
if (gameState !== 'playing' || !player.isAlive) return;
// Wave logic
if (waveInProgress) {
// Spawn gangsters for current wave
spawnTimer++;
var spawnRate = Math.max(120 - difficulty * 10, 30);
if (spawnTimer >= spawnRate && gangstersSpawned < gangstersToSpawn) {
spawnTimer = 0;
spawnGangster();
}
// Check if wave is completed (all gangsters spawned and defeated)
if (gangstersSpawned >= gangstersToSpawn && gangsters.length === 0) {
waveInProgress = false;
waveCompleted = true;
waveCompletionTimer = 0;
}
} else if (waveCompleted) {
// Wave completion pause
waveCompletionTimer++;
if (waveCompletionTimer >= 180) {
// 3 second pause
currentWave++;
startWave();
}
}
// Update police bullets
for (var i = policeBullets.length - 1; i >= 0; i--) {
var bullet = policeBullets[i];
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Remove bullets that go off screen
if (bullet.lastY >= 0 && bullet.y < 0) {
bullet.destroy();
policeBullets.splice(i, 1);
continue;
}
// Check collision with barriers
var hitBarrier = false;
for (var k = barriers.length - 1; k >= 0; k--) {
var barrier = barriers[k];
if (bullet.intersects(barrier)) {
// Remove bullet
bullet.destroy();
policeBullets.splice(i, 1);
hitBarrier = true;
break;
}
}
// Check collision with burning cars
if (!hitBarrier) {
for (var k = burningCars.length - 1; k >= 0; k--) {
var burningCar = burningCars[k];
if (bullet.intersects(burningCar)) {
// Remove bullet
bullet.destroy();
policeBullets.splice(i, 1);
hitBarrier = true;
break;
}
}
}
if (!hitBarrier) {
// Check collision with gangsters
var hitGangster = false;
for (var j = gangsters.length - 1; j >= 0; j--) {
var gangster = gangsters[j];
if (bullet.intersects(gangster)) {
// Hit gangster
LK.setScore(LK.getScore() + 10);
scoreTxt.setText('Score: ' + LK.getScore());
LK.getSound('hit').play();
// Remove gangster
gangster.destroy();
gangsters.splice(j, 1);
// Remove bullet
bullet.destroy();
policeBullets.splice(i, 1);
hitGangster = true;
break;
}
}
}
if (!hitGangster) {
bullet.lastY = bullet.y;
}
}
// Update gangster bullets
for (var i = gangsterBullets.length - 1; i >= 0; i--) {
var bullet = gangsterBullets[i];
if (bullet.lastY === undefined) bullet.lastY = bullet.y;
// Remove bullets that go off screen
if (bullet.lastY <= 2732 && bullet.y > 2732) {
bullet.destroy();
gangsterBullets.splice(i, 1);
continue;
}
// Check collision with barriers
var hitBarrier = false;
for (var k = barriers.length - 1; k >= 0; k--) {
var barrier = barriers[k];
if (bullet.intersects(barrier)) {
// Remove bullet
bullet.destroy();
gangsterBullets.splice(i, 1);
hitBarrier = true;
break;
}
}
// Check collision with burning cars
if (!hitBarrier) {
for (var k = burningCars.length - 1; k >= 0; k--) {
var burningCar = burningCars[k];
if (bullet.intersects(burningCar)) {
// Remove bullet
bullet.destroy();
gangsterBullets.splice(i, 1);
hitBarrier = true;
break;
}
}
}
if (!hitBarrier) {
// Check collision with player
if (bullet.intersects(player) && player.isAlive) {
player.isAlive = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
}
bullet.lastY = bullet.y;
}
// Update gangsters
for (var i = gangsters.length - 1; i >= 0; i--) {
var gangster = gangsters[i];
// Check if gangster reached player
if (gangster.intersects(player) && player.isAlive) {
player.isAlive = false;
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
return;
}
// Update gangster target occasionally
if (LK.ticks % 30 === 0) {
gangster.targetX = player.x;
gangster.targetY = player.y;
}
// Increase gangster speed with difficulty
gangster.speed = 2 + difficulty * 0.5;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -291,28 +291,66 @@
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 800;
menuContainer.addChild(titleText);
- // Create play button
- playButton = LK.getAsset('yellowBarrier', {
- anchorX: 0.5,
+ // Create gun-shaped play button
+ playButton = new Container();
+ playButton.x = 2048 / 2;
+ playButton.y = 1200;
+ menuContainer.addChild(playButton);
+ // Gun barrel (horizontal rectangle)
+ var gunBarrel = LK.getAsset('yellowBarrier', {
+ anchorX: 0,
anchorY: 0.5,
scaleX: 2,
- scaleY: 1,
- x: 2048 / 2,
- y: 1200
+ scaleY: 0.3,
+ x: -100,
+ y: 0
});
- playButton.tint = 0x00AA00;
- menuContainer.addChild(playButton);
+ gunBarrel.tint = 0x333333;
+ playButton.addChild(gunBarrel);
+ // Gun handle (vertical rectangle)
+ var gunHandle = LK.getAsset('yellowBarrier', {
+ anchorX: 0.5,
+ anchorY: 0,
+ scaleX: 0.8,
+ scaleY: 1.5,
+ x: -60,
+ y: 0
+ });
+ gunHandle.tint = 0x444444;
+ playButton.addChild(gunHandle);
+ // Gun trigger guard (small rectangle)
+ var triggerGuard = LK.getAsset('yellowBarrier', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.4,
+ scaleY: 0.4,
+ x: -40,
+ y: 30
+ });
+ triggerGuard.tint = 0x222222;
+ playButton.addChild(triggerGuard);
+ // Gun sight (small rectangle on top)
+ var gunSight = LK.getAsset('yellowBarrier', {
+ anchorX: 0.5,
+ anchorY: 1,
+ scaleX: 0.2,
+ scaleY: 0.3,
+ x: 50,
+ y: -15
+ });
+ gunSight.tint = 0x555555;
+ playButton.addChild(gunSight);
// Create play button text
var playButtonText = new Text2('PLAY', {
- size: 100,
+ size: 80,
fill: 0xFFFFFF
});
playButtonText.anchor.set(0.5, 0.5);
- playButtonText.x = 2048 / 2;
- playButtonText.y = 1200;
- menuContainer.addChild(playButtonText);
+ playButtonText.x = 0;
+ playButtonText.y = -80;
+ playButton.addChild(playButtonText);
// Create instructions text
instructionsText = new Text2('Drag to move and shoot\nDefeat all gangsters to advance waves', {
size: 60,
fill: 0xFFFFFF
This is a score text . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
2d pixel art style orange bullet. In-Game asset. 2d. High contrast. No shadows
2d pixel art style blue bullet. In-Game asset. 2d. High contrast. No shadows
a black barricade with yellow lines on it but pixel art style . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
A wrecked grey car with broken windows and smoke coming from the hood but pixel art style . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
this is a tree but pixel art style. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
This is a play button. No background. Writing the Play But pixel art style Transparent background. Blank background. No shadows. 2d. In-Game asset. flat make it more animation style
this is the street wars article in the main menu but pixel art style . No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Draw a Man He Have Baclava mask wearin brown shirt and blue pants He Using Gun with 2 hands in 2D Pixel Art Style and Do It from an Above Perspective.In-Game asset. 2d. High contrast. No shadows
road with yellow lines Let there be a large land area on both sides of the road but pixel art style . Bacground is green. No shadows. 2d. In-Game asset. flat