User prompt
Engellere çarpınca oyunu kaybedelim
User prompt
Arka plan sanki havada bulutlardaymışız gibi olsun
User prompt
Arka plan su deseni ve mavi olsun
Code edit (1 edits merged)
Please save this source code
User prompt
Hatayı düzeltirmsin ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var highScore = storage.get('highScore') || 0;' Line Number: 107 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage.getItem is not a function' in or related to this line: 'var highScore = storage.getItem('highScore') || 0;' Line Number: 107
User prompt
Please fix the bug: 'storage.get is not a function' in or related to this line: 'var highScore = storage.get('highScore') || 0;' Line Number: 107
User prompt
Yaptığımız en yüksek skor normal skorun altında yazsın
User prompt
Skor attıkça düşmanlar daha güçlensin ve daha fazla gelsin
User prompt
Her 20 düşman öldürdüğümüzde 1 kerelik süper güç elde edelim
Code edit (1 edits merged)
Please save this source code
User prompt
Taktik Savaşçı: Mobil Arena
Initial prompt
Bir savaş oyunu yapacağız. Bu oyun mobil kontrollere sahip olacak. Karakerimiz, düşmanlarla savaşacak taktiksel savaş için engeller olacak. Her 10 düşman öldürdüğümüzde silahımız güçlenecek.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Bullet class var Bullet = Container.expand(function () { var self = Container.call(this); var bulletAsset = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.radius = bulletAsset.width / 2; self.speed = -18; self.update = function () { self.y += self.speed; }; return self; }); // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyAsset = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.radius = enemyAsset.width / 2; self.speed = 3 + Math.random() * 2; // Speed increases with waves self.update = function () { self.y += self.speed; }; return self; }); // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroAsset = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.radius = heroAsset.width / 2; self.weaponLevel = 1; // 1: single, 2: double, 3: triple, etc. // For touch drag self.down = function (x, y, obj) {}; self.up = function (x, y, obj) {}; self.move = function (x, y, obj) {}; return self; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obsAsset = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.radius = obsAsset.width / 2; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // --- Game Variables --- // --- Asset Initialization --- var hero; var enemies = []; var bullets = []; var obstacles = []; var dragNode = null; var lastScore = 0; var kills = 0; var wave = 1; var spawnTimer = 0; var weaponLevel = 1; var scoreTxt; // --- UI --- scoreTxt = new Text2('0', { size: 120, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // --- Place Obstacles --- function placeObstacles() { // Clear old for (var i = 0; i < obstacles.length; i++) { obstacles[i].destroy(); } obstacles = []; // Place 3 obstacles in the arena, not blocking the hero spawn var obsY = [900, 1500, 2100]; for (var i = 0; i < 3; i++) { var obs = new Obstacle(); obs.x = 2048 / 2 + (i - 1) * 500; obs.y = obsY[i]; obstacles.push(obs); game.addChild(obs); } } // --- Spawn Hero --- function spawnHero() { hero = new Hero(); hero.x = 2048 / 2; hero.y = 2732 - 300; game.addChild(hero); weaponLevel = 1; hero.weaponLevel = 1; } // --- Spawn Enemy --- function spawnEnemy() { var enemy = new Enemy(); enemy.x = 300 + Math.random() * (2048 - 600); enemy.y = -120; enemies.push(enemy); game.addChild(enemy); } // --- Fire Bullets --- function fireBullets() { var bulletCount = weaponLevel; var spread = 60; // px between bullets var baseX = hero.x - (bulletCount - 1) * spread / 2; for (var i = 0; i < bulletCount; i++) { var bullet = new Bullet(); bullet.x = baseX + i * spread; bullet.y = hero.y - hero.radius - 20; bullets.push(bullet); game.addChild(bullet); } } // --- Touch Controls --- function handleMove(x, y, obj) { if (dragNode) { // Clamp hero inside arena var minX = hero.radius + 20; var maxX = 2048 - hero.radius - 20; var minY = hero.radius + 200; var maxY = 2732 - hero.radius - 20; dragNode.x = Math.max(minX, Math.min(maxX, x)); dragNode.y = Math.max(minY, Math.min(maxY, y)); } } game.move = handleMove; game.down = function (x, y, obj) { // Only drag if touch is on hero var dx = x - hero.x; var dy = y - hero.y; if (dx * dx + dy * dy < hero.radius * hero.radius * 1.2) { dragNode = hero; handleMove(x, y, obj); } }; game.up = function (x, y, obj) { dragNode = null; }; // --- Game Update --- game.update = function () { // --- Bullets --- for (var i = bullets.length - 1; i >= 0; i--) { var b = bullets[i]; b.update(); // Remove offscreen if (b.y < -50) { b.destroy(); bullets.splice(i, 1); continue; } // Collide with obstacles var hitObs = false; for (var j = 0; j < obstacles.length; j++) { if (b.intersects(obstacles[j])) { b.destroy(); bullets.splice(i, 1); hitObs = true; break; } } if (hitObs) continue; // Collide with enemies for (var j = enemies.length - 1; j >= 0; j--) { if (b.intersects(enemies[j])) { // Destroy both b.destroy(); bullets.splice(i, 1); enemies[j].destroy(); enemies.splice(j, 1); kills++; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Weapon upgrade if (kills % 10 === 0) { weaponLevel++; hero.weaponLevel = weaponLevel; LK.effects.flashObject(hero, 0x00ff00, 600); } break; } } } // --- Enemies --- for (var i = enemies.length - 1; i >= 0; i--) { var e = enemies[i]; e.update(); // Collide with obstacles var hitObs = false; for (var j = 0; j < obstacles.length; j++) { if (e.intersects(obstacles[j])) { // Bounce down a bit and change x direction e.y -= 30; e.x += (Math.random() - 0.5) * 200; hitObs = true; break; } } if (hitObs) continue; // Collide with hero if (e.intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Remove offscreen if (e.y > 2732 + 100) { e.destroy(); enemies.splice(i, 1); } } // --- Enemy Spawning --- spawnTimer++; var spawnInterval = Math.max(30, 90 - wave * 5); // Faster with waves if (spawnTimer >= spawnInterval) { spawnEnemy(); spawnTimer = 0; } // Increase wave every 15 kills wave = 1 + Math.floor(kills / 15); // --- Fire Bullets (auto fire) --- if (LK.ticks % 18 === 0) { fireBullets(); } }; // --- Game Start --- placeObstacles(); spawnHero(); LK.setScore(0); scoreTxt.setText(0); kills = 0; wave = 1; weaponLevel = 1; enemies = []; bullets = []; spawnTimer = 0;
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,261 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Bullet class
+var Bullet = Container.expand(function () {
+ var self = Container.call(this);
+ var bulletAsset = self.attachAsset('bullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.radius = bulletAsset.width / 2;
+ self.speed = -18;
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+// Enemy class
+var Enemy = Container.expand(function () {
+ var self = Container.call(this);
+ var enemyAsset = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.radius = enemyAsset.width / 2;
+ self.speed = 3 + Math.random() * 2; // Speed increases with waves
+ self.update = function () {
+ self.y += self.speed;
+ };
+ return self;
+});
+// Hero class
+var Hero = Container.expand(function () {
+ var self = Container.call(this);
+ var heroAsset = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.radius = heroAsset.width / 2;
+ self.weaponLevel = 1; // 1: single, 2: double, 3: triple, etc.
+ // For touch drag
+ self.down = function (x, y, obj) {};
+ self.up = function (x, y, obj) {};
+ self.move = function (x, y, obj) {};
+ return self;
+});
+// Obstacle class
+var Obstacle = Container.expand(function () {
+ var self = Container.call(this);
+ var obsAsset = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.radius = obsAsset.width / 2;
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x181818
+});
+
+/****
+* Game Code
+****/
+// --- Game Variables ---
+// --- Asset Initialization ---
+var hero;
+var enemies = [];
+var bullets = [];
+var obstacles = [];
+var dragNode = null;
+var lastScore = 0;
+var kills = 0;
+var wave = 1;
+var spawnTimer = 0;
+var weaponLevel = 1;
+var scoreTxt;
+// --- UI ---
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: 0xFFFFFF
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// --- Place Obstacles ---
+function placeObstacles() {
+ // Clear old
+ for (var i = 0; i < obstacles.length; i++) {
+ obstacles[i].destroy();
+ }
+ obstacles = [];
+ // Place 3 obstacles in the arena, not blocking the hero spawn
+ var obsY = [900, 1500, 2100];
+ for (var i = 0; i < 3; i++) {
+ var obs = new Obstacle();
+ obs.x = 2048 / 2 + (i - 1) * 500;
+ obs.y = obsY[i];
+ obstacles.push(obs);
+ game.addChild(obs);
+ }
+}
+// --- Spawn Hero ---
+function spawnHero() {
+ hero = new Hero();
+ hero.x = 2048 / 2;
+ hero.y = 2732 - 300;
+ game.addChild(hero);
+ weaponLevel = 1;
+ hero.weaponLevel = 1;
+}
+// --- Spawn Enemy ---
+function spawnEnemy() {
+ var enemy = new Enemy();
+ enemy.x = 300 + Math.random() * (2048 - 600);
+ enemy.y = -120;
+ enemies.push(enemy);
+ game.addChild(enemy);
+}
+// --- Fire Bullets ---
+function fireBullets() {
+ var bulletCount = weaponLevel;
+ var spread = 60; // px between bullets
+ var baseX = hero.x - (bulletCount - 1) * spread / 2;
+ for (var i = 0; i < bulletCount; i++) {
+ var bullet = new Bullet();
+ bullet.x = baseX + i * spread;
+ bullet.y = hero.y - hero.radius - 20;
+ bullets.push(bullet);
+ game.addChild(bullet);
+ }
+}
+// --- Touch Controls ---
+function handleMove(x, y, obj) {
+ if (dragNode) {
+ // Clamp hero inside arena
+ var minX = hero.radius + 20;
+ var maxX = 2048 - hero.radius - 20;
+ var minY = hero.radius + 200;
+ var maxY = 2732 - hero.radius - 20;
+ dragNode.x = Math.max(minX, Math.min(maxX, x));
+ dragNode.y = Math.max(minY, Math.min(maxY, y));
+ }
+}
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ // Only drag if touch is on hero
+ var dx = x - hero.x;
+ var dy = y - hero.y;
+ if (dx * dx + dy * dy < hero.radius * hero.radius * 1.2) {
+ dragNode = hero;
+ handleMove(x, y, obj);
+ }
+};
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// --- Game Update ---
+game.update = function () {
+ // --- Bullets ---
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ var b = bullets[i];
+ b.update();
+ // Remove offscreen
+ if (b.y < -50) {
+ b.destroy();
+ bullets.splice(i, 1);
+ continue;
+ }
+ // Collide with obstacles
+ var hitObs = false;
+ for (var j = 0; j < obstacles.length; j++) {
+ if (b.intersects(obstacles[j])) {
+ b.destroy();
+ bullets.splice(i, 1);
+ hitObs = true;
+ break;
+ }
+ }
+ if (hitObs) continue;
+ // Collide with enemies
+ for (var j = enemies.length - 1; j >= 0; j--) {
+ if (b.intersects(enemies[j])) {
+ // Destroy both
+ b.destroy();
+ bullets.splice(i, 1);
+ enemies[j].destroy();
+ enemies.splice(j, 1);
+ kills++;
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ // Weapon upgrade
+ if (kills % 10 === 0) {
+ weaponLevel++;
+ hero.weaponLevel = weaponLevel;
+ LK.effects.flashObject(hero, 0x00ff00, 600);
+ }
+ break;
+ }
+ }
+ }
+ // --- Enemies ---
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var e = enemies[i];
+ e.update();
+ // Collide with obstacles
+ var hitObs = false;
+ for (var j = 0; j < obstacles.length; j++) {
+ if (e.intersects(obstacles[j])) {
+ // Bounce down a bit and change x direction
+ e.y -= 30;
+ e.x += (Math.random() - 0.5) * 200;
+ hitObs = true;
+ break;
+ }
+ }
+ if (hitObs) continue;
+ // Collide with hero
+ if (e.intersects(hero)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ // Remove offscreen
+ if (e.y > 2732 + 100) {
+ e.destroy();
+ enemies.splice(i, 1);
+ }
+ }
+ // --- Enemy Spawning ---
+ spawnTimer++;
+ var spawnInterval = Math.max(30, 90 - wave * 5); // Faster with waves
+ if (spawnTimer >= spawnInterval) {
+ spawnEnemy();
+ spawnTimer = 0;
+ }
+ // Increase wave every 15 kills
+ wave = 1 + Math.floor(kills / 15);
+ // --- Fire Bullets (auto fire) ---
+ if (LK.ticks % 18 === 0) {
+ fireBullets();
+ }
+};
+// --- Game Start ---
+placeObstacles();
+spawnHero();
+LK.setScore(0);
+scoreTxt.setText(0);
+kills = 0;
+wave = 1;
+weaponLevel = 1;
+enemies = [];
+bullets = [];
+spawnTimer = 0;
\ No newline at end of file
Gerçek mermiye benzeyen mermi yap. In-Game asset. 2d. High contrast. No shadows
Düşman angry birdse benzesin. In-Game asset. 2d. High contrast. No shadows
Yeşil angry birds olsun. In-Game asset. 2d. High contrast. No shadows
Bulut deseni olsun ve parlak beyaz olsun. In-Game asset. 2d. High contrast. No shadows