User prompt
düşman askerleri olsun hareket etsinler . ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
silah dürbünj özelliğini kaldır.
User prompt
zoom özelliğini kaldır.
User prompt
oyun ekranını göster.
Code edit (1 edits merged)
Please save this source code
User prompt
Sniper Elite: Precision Strike
Initial prompt
keskin nişancı oyunu olsun .Düşman askerlerini vursun .ekranda zom özelliği olsun.Dürbün olsun.
/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 1.0
});
// Movement properties
self.speed = 1 + Math.random() * 2;
self.direction = (Math.random() - 0.5) * 2;
self.changeDirectionTimer = 0;
self.lastX = 0;
self.lastY = 0;
self.update = function () {
// Store last position for collision detection
self.lastX = self.x;
self.lastY = self.y;
// Change direction randomly
self.changeDirectionTimer++;
if (self.changeDirectionTimer > 180) {
// Change direction every 3 seconds
self.direction = (Math.random() - 0.5) * 2;
self.changeDirectionTimer = 0;
}
// Move horizontally
self.x += self.direction * self.speed;
// Keep within battlefield bounds
if (self.x < 200) {
self.x = 200;
self.direction = Math.abs(self.direction);
}
if (self.x > 3800) {
self.x = 3800;
self.direction = -Math.abs(self.direction);
}
};
return self;
});
var HitMarker = Container.expand(function () {
var self = Container.call(this);
var markerGraphics = self.attachAsset('hitMarker', {
anchorX: 0.5,
anchorY: 0.5
});
self.timer = 0;
self.lifetime = 60; // 1 second at 60fps
self.update = function () {
self.timer++;
// Fade out over time
markerGraphics.alpha = 1 - self.timer / self.lifetime;
if (self.timer >= self.lifetime) {
self.destroy();
}
};
return self;
});
// Game variables
var Scope = Container.expand(function () {
var self = Container.call(this);
// Create scope background
var scopeGraphics = self.attachAsset('scope', {
anchorX: 0.5,
anchorY: 0.5
});
// Create crosshair lines
var crosshairV = self.attachAsset('crosshair', {
anchorX: 0.5,
anchorY: 0.5
});
var crosshairH = self.attachAsset('crosshair', {
anchorX: 0.5,
anchorY: 0.5,
rotation: Math.PI / 2
});
// Zoom properties
self.zoomLevel = 1.0;
self.minZoom = 0.5;
self.maxZoom = 3.0;
self.setZoom = function (zoom) {
self.zoomLevel = Math.max(self.minZoom, Math.min(self.maxZoom, zoom));
self.scaleX = self.zoomLevel;
self.scaleY = self.zoomLevel;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game variables
var enemies = [];
var hitMarkers = [];
var scope;
var battlefield;
var cameraX = 0;
var cameraY = 0;
var targetCameraX = 0;
var targetCameraY = 0;
var score = 0;
// Create battlefield background
battlefield = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048,
y: 2048
}));
// Create scope overlay
scope = LK.gui.center.addChild(new Scope());
scope.x = 0;
scope.y = 0;
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
scoreTxt.y = 100;
// Create zoom indicator
var zoomTxt = new Text2('Zoom: 1.0x', {
size: 40,
fill: 0xFFFFFF
});
zoomTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(zoomTxt);
zoomTxt.x = -20;
zoomTxt.y = 100;
// Spawn initial enemies
for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
enemy.x = 500 + Math.random() * 3000;
enemy.y = 1800 + Math.random() * 400;
enemies.push(enemy);
battlefield.addChild(enemy);
}
// Touch controls
game.down = function (x, y, obj) {
// Convert screen coordinates to battlefield coordinates
var battlefieldPos = battlefield.toLocal({
x: x - game.x,
y: y - game.y
});
// Check for enemy hits
var hit = false;
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
var distance = Math.sqrt(Math.pow(battlefieldPos.x - enemy.x, 2) + Math.pow(battlefieldPos.y - enemy.y, 2));
// Hit detection with some tolerance
if (distance < 60) {
// Create hit marker
var hitMarker = new HitMarker();
hitMarker.x = enemy.x;
hitMarker.y = enemy.y;
hitMarkers.push(hitMarker);
battlefield.addChild(hitMarker);
// Remove enemy
enemy.destroy();
enemies.splice(i, 1);
// Update score
score += 10;
LK.setScore(score);
scoreTxt.setText('Score: ' + score);
// Play hit sound
LK.getSound('hit').play();
hit = true;
break;
}
}
if (!hit) {
// Play miss sound
LK.getSound('shoot').play();
}
// Spawn new enemy if less than 5
if (enemies.length < 5) {
var newEnemy = new Enemy();
newEnemy.x = 500 + Math.random() * 3000;
newEnemy.y = 1800 + Math.random() * 400;
enemies.push(newEnemy);
battlefield.addChild(newEnemy);
}
};
// Camera movement with touch
game.move = function (x, y, obj) {
// Update target camera position based on touch
targetCameraX = -(x - 1024) * 2;
targetCameraY = -(y - 1366) * 1.5;
// Clamp camera bounds
targetCameraX = Math.max(-1500, Math.min(1500, targetCameraX));
targetCameraY = Math.max(-800, Math.min(800, targetCameraY));
};
// Game update loop
game.update = function () {
// Smooth camera movement
cameraX += (targetCameraX - cameraX) * 0.1;
cameraY += (targetCameraY - cameraY) * 0.1;
// Apply camera position to battlefield
battlefield.x = 2048 + cameraX;
battlefield.y = 2048 + cameraY;
// Zoom controls (pinch simulation with time-based zoom)
if (LK.ticks % 300 < 150) {
scope.setZoom(1.0 + Math.sin(LK.ticks * 0.01) * 0.5);
}
// Update zoom display
zoomTxt.setText('Zoom: ' + scope.zoomLevel.toFixed(1) + 'x');
// Clean up destroyed hit markers
for (var i = hitMarkers.length - 1; i >= 0; i--) {
var marker = hitMarkers[i];
if (marker.timer >= marker.lifetime) {
hitMarkers.splice(i, 1);
}
}
// Win condition
if (score >= 100) {
LK.showYouWin();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,265 +1,225 @@
/****
-* Plugins
-****/
-var tween = LK.import("@upit/tween.v1");
-
-/****
* Classes
****/
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 1.0
});
- self.speed = Math.random() * 2 + 1;
- self.direction = Math.random() < 0.5 ? -1 : 1;
- self.moveRange = 200 + Math.random() * 300;
- self.startX = 0;
- self.health = 1;
- self.isAlive = true;
- self.initialize = function (startX, startY) {
- self.x = startX;
- self.y = startY;
- self.startX = startX;
+ // Movement properties
+ self.speed = 1 + Math.random() * 2;
+ self.direction = (Math.random() - 0.5) * 2;
+ self.changeDirectionTimer = 0;
+ self.lastX = 0;
+ self.lastY = 0;
+ self.update = function () {
+ // Store last position for collision detection
+ self.lastX = self.x;
+ self.lastY = self.y;
+ // Change direction randomly
+ self.changeDirectionTimer++;
+ if (self.changeDirectionTimer > 180) {
+ // Change direction every 3 seconds
+ self.direction = (Math.random() - 0.5) * 2;
+ self.changeDirectionTimer = 0;
+ }
+ // Move horizontally
+ self.x += self.direction * self.speed;
+ // Keep within battlefield bounds
+ if (self.x < 200) {
+ self.x = 200;
+ self.direction = Math.abs(self.direction);
+ }
+ if (self.x > 3800) {
+ self.x = 3800;
+ self.direction = -Math.abs(self.direction);
+ }
};
+ return self;
+});
+var HitMarker = Container.expand(function () {
+ var self = Container.call(this);
+ var markerGraphics = self.attachAsset('hitMarker', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.timer = 0;
+ self.lifetime = 60; // 1 second at 60fps
self.update = function () {
- if (!self.isAlive) return;
- self.x += self.speed * self.direction;
- if (Math.abs(self.x - self.startX) > self.moveRange) {
- self.direction *= -1;
+ self.timer++;
+ // Fade out over time
+ markerGraphics.alpha = 1 - self.timer / self.lifetime;
+ if (self.timer >= self.lifetime) {
+ self.destroy();
}
};
- self.hit = function () {
- if (!self.isAlive) return;
- self.isAlive = false;
- self.health = 0;
- var hitMarker = LK.getAsset('hitMarker', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- hitMarker.x = self.x;
- hitMarker.y = self.y - 60;
- gameContainer.addChild(hitMarker);
- tween(hitMarker, {
- alpha: 0,
- scaleX: 2,
- scaleY: 2
- }, {
- duration: 500,
- onFinish: function onFinish() {
- hitMarker.destroy();
- }
- });
- tween(enemyGraphics, {
- alpha: 0
- }, {
- duration: 300,
- onFinish: function onFinish() {
- self.destroy();
- }
- });
- LK.getSound('hit').play();
- LK.setScore(LK.getScore() + 10);
- updateScore();
- };
return self;
});
-var SniperScope = Container.expand(function () {
+// Game variables
+var Scope = Container.expand(function () {
var self = Container.call(this);
- self.zoomLevel = 1;
- self.maxZoom = 3;
- self.minZoom = 0.5;
- var scopeBackground = self.attachAsset('scope', {
+ // Create scope background
+ var scopeGraphics = self.attachAsset('scope', {
anchorX: 0.5,
anchorY: 0.5
});
- scopeBackground.alpha = 0.8;
+ // Create crosshair lines
var crosshairV = self.attachAsset('crosshair', {
anchorX: 0.5,
anchorY: 0.5
});
var crosshairH = self.attachAsset('crosshair', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ rotation: Math.PI / 2
});
- crosshairH.rotation = Math.PI / 2;
- self.x = 2048 / 2;
- self.y = 2732 / 2;
- self.updateZoom = function (delta) {
- self.zoomLevel += delta;
- self.zoomLevel = Math.max(self.minZoom, Math.min(self.maxZoom, self.zoomLevel));
- gameContainer.scaleX = self.zoomLevel;
- gameContainer.scaleY = self.zoomLevel;
- gameContainer.x = 2048 / 2 - gameContainer.scaleX * (2048 / 2);
- gameContainer.y = 2732 / 2 - gameContainer.scaleY * (2732 / 2);
+ // Zoom properties
+ self.zoomLevel = 1.0;
+ self.minZoom = 0.5;
+ self.maxZoom = 3.0;
+ self.setZoom = function (zoom) {
+ self.zoomLevel = Math.max(self.minZoom, Math.min(self.maxZoom, zoom));
+ self.scaleX = self.zoomLevel;
+ self.scaleY = self.zoomLevel;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x87CEEB
+ backgroundColor: 0x000000
});
/****
* Game Code
****/
-var gameContainer = new Container();
+// Game variables
var enemies = [];
+var hitMarkers = [];
var scope;
-var scoreTxt;
-var zoomTxt;
-var crosshairX = 2048 / 2;
-var crosshairY = 2732 / 2;
-var enemySpawnTimer = 0;
-var enemySpawnInterval = 180;
-// Initialize background
-var background = LK.getAsset('background', {
+var battlefield;
+var cameraX = 0;
+var cameraY = 0;
+var targetCameraX = 0;
+var targetCameraY = 0;
+var score = 0;
+// Create battlefield background
+battlefield = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
- anchorY: 0.5
-});
-background.x = 2048 / 2;
-background.y = 2732 / 2;
-gameContainer.addChild(background);
-game.addChild(gameContainer);
-// Initialize scope
-scope = new SniperScope();
-game.addChild(scope);
-// Initialize UI
-scoreTxt = new Text2('Score: 0', {
+ anchorY: 0.5,
+ x: 2048,
+ y: 2048
+}));
+// Create scope overlay
+scope = LK.gui.center.addChild(new Scope());
+scope.x = 0;
+scope.y = 0;
+// Create score display
+var scoreTxt = new Text2('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
-scoreTxt.anchor.set(0, 0);
-scoreTxt.x = 120;
-scoreTxt.y = 120;
-LK.gui.topLeft.addChild(scoreTxt);
-zoomTxt = new Text2('Zoom: 1.0x', {
- size: 50,
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+scoreTxt.y = 100;
+// Create zoom indicator
+var zoomTxt = new Text2('Zoom: 1.0x', {
+ size: 40,
fill: 0xFFFFFF
});
zoomTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(zoomTxt);
-var instructionTxt = new Text2('Tap to shoot • Pinch to zoom', {
- size: 40,
- fill: 0xFFFFFF
-});
-instructionTxt.anchor.set(0.5, 1);
-LK.gui.bottom.addChild(instructionTxt);
-function updateScore() {
- scoreTxt.setText('Score: ' + LK.getScore());
- if (LK.getScore() >= 100) {
- LK.showYouWin();
- }
-}
-function updateZoom() {
- zoomTxt.setText('Zoom: ' + scope.zoomLevel.toFixed(1) + 'x');
-}
-function spawnEnemy() {
+zoomTxt.x = -20;
+zoomTxt.y = 100;
+// Spawn initial enemies
+for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
- var spawnX = Math.random() * 3000 + 500;
- var spawnY = 2000 + Math.random() * 800;
- enemy.initialize(spawnX, spawnY);
+ enemy.x = 500 + Math.random() * 3000;
+ enemy.y = 1800 + Math.random() * 400;
enemies.push(enemy);
- gameContainer.addChild(enemy);
+ battlefield.addChild(enemy);
}
-function shoot(x, y) {
- LK.getSound('shoot').play();
- var worldPos = gameContainer.toLocal({
- x: x,
- y: y
+// Touch controls
+game.down = function (x, y, obj) {
+ // Convert screen coordinates to battlefield coordinates
+ var battlefieldPos = battlefield.toLocal({
+ x: x - game.x,
+ y: y - game.y
});
+ // Check for enemy hits
var hit = false;
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
- if (enemy.isAlive && enemy.intersects({
- x: worldPos.x,
- y: worldPos.y,
- width: 10,
- height: 10
- })) {
- enemy.hit();
+ var distance = Math.sqrt(Math.pow(battlefieldPos.x - enemy.x, 2) + Math.pow(battlefieldPos.y - enemy.y, 2));
+ // Hit detection with some tolerance
+ if (distance < 60) {
+ // Create hit marker
+ var hitMarker = new HitMarker();
+ hitMarker.x = enemy.x;
+ hitMarker.y = enemy.y;
+ hitMarkers.push(hitMarker);
+ battlefield.addChild(hitMarker);
+ // Remove enemy
+ enemy.destroy();
enemies.splice(i, 1);
+ // Update score
+ score += 10;
+ LK.setScore(score);
+ scoreTxt.setText('Score: ' + score);
+ // Play hit sound
+ LK.getSound('hit').play();
hit = true;
break;
}
}
if (!hit) {
- // Miss effect
- scope.alpha = 0.7;
- tween(scope, {
- alpha: 1
- }, {
- duration: 200
- });
+ // Play miss sound
+ LK.getSound('shoot').play();
}
-}
-var lastTouchDistance = 0;
-var touchStartTime = 0;
-game.down = function (x, y, obj) {
- touchStartTime = Date.now();
- crosshairX = x;
- crosshairY = y;
-};
-game.up = function (x, y, obj) {
- var touchDuration = Date.now() - touchStartTime;
- if (touchDuration < 300) {
- shoot(x, y);
+ // Spawn new enemy if less than 5
+ if (enemies.length < 5) {
+ var newEnemy = new Enemy();
+ newEnemy.x = 500 + Math.random() * 3000;
+ newEnemy.y = 1800 + Math.random() * 400;
+ enemies.push(newEnemy);
+ battlefield.addChild(newEnemy);
}
};
+// Camera movement with touch
game.move = function (x, y, obj) {
- crosshairX = x;
- crosshairY = y;
- // Simple zoom with vertical movement
- var centerY = 2732 / 2;
- var deltaY = (y - centerY) / 1000;
- var zoomDelta = -deltaY * 0.1;
- if (Math.abs(zoomDelta) > 0.01) {
- scope.updateZoom(zoomDelta);
- updateZoom();
- }
+ // Update target camera position based on touch
+ targetCameraX = -(x - 1024) * 2;
+ targetCameraY = -(y - 1366) * 1.5;
+ // Clamp camera bounds
+ targetCameraX = Math.max(-1500, Math.min(1500, targetCameraX));
+ targetCameraY = Math.max(-800, Math.min(800, targetCameraY));
};
+// Game update loop
game.update = function () {
- // Spawn enemies
- enemySpawnTimer++;
- if (enemySpawnTimer >= enemySpawnInterval) {
- spawnEnemy();
- enemySpawnTimer = 0;
- enemySpawnInterval = Math.max(60, enemySpawnInterval - 2);
+ // Smooth camera movement
+ cameraX += (targetCameraX - cameraX) * 0.1;
+ cameraY += (targetCameraY - cameraY) * 0.1;
+ // Apply camera position to battlefield
+ battlefield.x = 2048 + cameraX;
+ battlefield.y = 2048 + cameraY;
+ // Zoom controls (pinch simulation with time-based zoom)
+ if (LK.ticks % 300 < 150) {
+ scope.setZoom(1.0 + Math.sin(LK.ticks * 0.01) * 0.5);
}
- // Update enemies
- for (var i = enemies.length - 1; i >= 0; i--) {
- var enemy = enemies[i];
- if (enemy.isAlive) {
- // Check if enemy is too far off screen
- var screenPos = game.toLocal(gameContainer.toGlobal({
- x: enemy.x,
- y: enemy.y
- }));
- if (screenPos.x < -200 || screenPos.x > 2248 || screenPos.y < -200 || screenPos.y > 2932) {
- enemy.destroy();
- enemies.splice(i, 1);
- }
+ // Update zoom display
+ zoomTxt.setText('Zoom: ' + scope.zoomLevel.toFixed(1) + 'x');
+ // Clean up destroyed hit markers
+ for (var i = hitMarkers.length - 1; i >= 0; i--) {
+ var marker = hitMarkers[i];
+ if (marker.timer >= marker.lifetime) {
+ hitMarkers.splice(i, 1);
}
}
- // Clean up destroyed enemies
- for (var i = enemies.length - 1; i >= 0; i--) {
- if (!enemies[i].isAlive && enemies[i].alpha <= 0) {
- enemies.splice(i, 1);
- }
+ // Win condition
+ if (score >= 100) {
+ LK.showYouWin();
}
- // Update scope position based on crosshair
- scope.x = crosshairX;
- scope.y = crosshairY;
- // Game over condition - too many enemies
- var aliveEnemies = 0;
- for (var i = 0; i < enemies.length; i++) {
- if (enemies[i].isAlive) aliveEnemies++;
- }
- if (aliveEnemies > 15) {
- LK.showGameOver();
- }
};
\ No newline at end of file
hareketli silah. In-Game asset. 2d. High contrast. No shadows
duman. In-Game asset. 2d. High contrast. No shadows
zombie. In-Game asset. 2d. High contrast. No shadows
dinazor. In-Game asset. 2d. High contrast. No shadows
kuş bakışı silahlı kule.. In-Game asset. 2d. High contrast. No shadows
dairesel mevzi.. In-Game asset. 2d. High contrast. No shadows
roket namlusu kuş bakışı ,üstten görünüm.. In-Game asset. 2d. High contrast. No shadows
patlama efekti alev duman. In-Game asset. 2d. High contrast. No shadows