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.
/****
* 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;
};
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.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 () {
var self = Container.call(this);
self.zoomLevel = 1;
self.maxZoom = 3;
self.minZoom = 0.5;
var scopeBackground = self.attachAsset('scope', {
anchorX: 0.5,
anchorY: 0.5
});
scopeBackground.alpha = 0.8;
var crosshairV = self.attachAsset('crosshair', {
anchorX: 0.5,
anchorY: 0.5
});
var crosshairH = self.attachAsset('crosshair', {
anchorX: 0.5,
anchorY: 0.5
});
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);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var gameContainer = new Container();
var enemies = [];
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', {
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', {
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,
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() {
var enemy = new Enemy();
var spawnX = Math.random() * 3000 + 500;
var spawnY = 2000 + Math.random() * 800;
enemy.initialize(spawnX, spawnY);
enemies.push(enemy);
gameContainer.addChild(enemy);
}
function shoot(x, y) {
LK.getSound('shoot').play();
var worldPos = gameContainer.toLocal({
x: x,
y: y
});
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();
enemies.splice(i, 1);
hit = true;
break;
}
}
if (!hit) {
// Miss effect
scope.alpha = 0.7;
tween(scope, {
alpha: 1
}, {
duration: 200
});
}
}
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);
}
};
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();
}
};
game.update = function () {
// Spawn enemies
enemySpawnTimer++;
if (enemySpawnTimer >= enemySpawnInterval) {
spawnEnemy();
enemySpawnTimer = 0;
enemySpawnInterval = Math.max(60, enemySpawnInterval - 2);
}
// 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);
}
}
}
// 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);
}
}
// 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();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,265 @@
-/****
+/****
+* 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;
+ };
+ 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.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 () {
+ var self = Container.call(this);
+ self.zoomLevel = 1;
+ self.maxZoom = 3;
+ self.minZoom = 0.5;
+ var scopeBackground = self.attachAsset('scope', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ scopeBackground.alpha = 0.8;
+ var crosshairV = self.attachAsset('crosshair', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var crosshairH = self.attachAsset('crosshair', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ 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);
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+var gameContainer = new Container();
+var enemies = [];
+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', {
+ 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', {
+ 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,
+ 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() {
+ var enemy = new Enemy();
+ var spawnX = Math.random() * 3000 + 500;
+ var spawnY = 2000 + Math.random() * 800;
+ enemy.initialize(spawnX, spawnY);
+ enemies.push(enemy);
+ gameContainer.addChild(enemy);
+}
+function shoot(x, y) {
+ LK.getSound('shoot').play();
+ var worldPos = gameContainer.toLocal({
+ x: x,
+ y: y
+ });
+ 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();
+ enemies.splice(i, 1);
+ hit = true;
+ break;
+ }
+ }
+ if (!hit) {
+ // Miss effect
+ scope.alpha = 0.7;
+ tween(scope, {
+ alpha: 1
+ }, {
+ duration: 200
+ });
+ }
+}
+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);
+ }
+};
+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();
+ }
+};
+game.update = function () {
+ // Spawn enemies
+ enemySpawnTimer++;
+ if (enemySpawnTimer >= enemySpawnInterval) {
+ spawnEnemy();
+ enemySpawnTimer = 0;
+ enemySpawnInterval = Math.max(60, enemySpawnInterval - 2);
+ }
+ // 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);
+ }
+ }
+ }
+ // 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);
+ }
+ }
+ // 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