User prompt
vurulan roket sayısını gösteren sayacı çok az daha aşağı al
User prompt
vurduğum roket sayısını gösteren sayaçı birazcık aşağı al
User prompt
"health" vurulumayan her roket için sadece 1 değer azalsın
User prompt
"health" göstergesini biraz sola al
User prompt
"health" ekrana sığmıyor daha küçük yap
User prompt
sayacın yanına yeni bir can göstergesi oluştur bu can göstergesi kahramanın vuramadığı her roket için 1 azalsın ve toplam can sayısı 5 olsun
User prompt
kahraman ekrana dokunulunca yukarı ve aşağı hareket etmesin , sağa ve sola hareket etsin
User prompt
kahraman ekrana tıklandığında ışınlanmasın!
User prompt
kahramanın sağ ve sol konumu hariç bir yere ışınlanmasını engelle
User prompt
hassasiyeti biraz azalt
User prompt
kahramanın sağa ve sola olan hareketinin hassasiyetini daha da artır
User prompt
kahramanın sağa ve sola olsan hareketinin hassasiyetini artır
User prompt
kahraman sağa ve sola hareket etsin!
User prompt
kahraman ekranda herhangi bir yere dokununca oraya ışınlanmamalı
User prompt
mermi frekansını biraz azalt
User prompt
mermi hızını azalt
User prompt
ekrandaki sayaç sadece ekranda gözüken düşmanı vurunca artsın
User prompt
mermi çıkma frekansını azalt
User prompt
sadece sağa ve sola hareket edebilsin
User prompt
kahraman sabit kalsın
User prompt
kahraman yukarı çıkmasın
User prompt
yeni bir arkaplan asseti oluştur ve tüm ekranı kaplasın
Initial prompt
Gun Game
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; self.shoot = function () { var bullet = new HeroBullet(); bullet.x = self.x; bullet.y = self.y - heroGraphics.height / 2; game.addChild(bullet); heroBullets.push(bullet); }; }); // HeroBullet class var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('heroBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.update = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var background = game.attachAsset('background', { anchorX: 0.0, anchorY: 0.0 }); // Initialize variables var hero; var enemies = []; var heroBullets = []; var score = 0; var health = 5; // Initialize hero's health to 5 var scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create hero hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 200; // Create health text field var healthTxt = new Text2('Health: 5', { size: 150, fill: 0xFFFFFF }); healthTxt.anchor.set(0.5, 0); LK.gui.topRight.addChild(healthTxt); // Handle game events game.down = function (x, y, obj) { hero.x = x; }; game.move = function (x, y, obj) { hero.x = x; }; game.update = function () { // Update hero bullets for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].update(); for (var j = enemies.length - 1; j >= 0; j--) { if (heroBullets[i].intersects(enemies[j]) && enemies[j].y > 0) { enemies[j].destroy(); heroBullets[i].destroy(); enemies.splice(j, 1); heroBullets.splice(i, 1); score++; scoreTxt.setText(score); break; } } } // Update enemies for (var k = enemies.length - 1; k >= 0; k--) { enemies[k].update(); if (enemies[k].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Decrease hero's health when an enemy passes by if (enemies[k].y > 2732) { health--; healthTxt.setText('Health: ' + health); // End the game if the hero's health reaches 0 if (health <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } } // Spawn enemies if (LK.ticks % 60 == 0) { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -50; game.addChild(enemy); enemies.push(enemy); } // Hero shooting if (LK.ticks % 60 == 0) { hero.shoot(); } };
===================================================================
--- original.js
+++ change.js
@@ -68,8 +68,9 @@
var hero;
var enemies = [];
var heroBullets = [];
var score = 0;
+var health = 5; // Initialize hero's health to 5
var scoreTxt = new Text2('0', {
size: 150,
fill: 0xFFFFFF
});
@@ -78,8 +79,15 @@
// Create hero
hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 200;
+// Create health text field
+var healthTxt = new Text2('Health: 5', {
+ size: 150,
+ fill: 0xFFFFFF
+});
+healthTxt.anchor.set(0.5, 0);
+LK.gui.topRight.addChild(healthTxt);
// Handle game events
game.down = function (x, y, obj) {
hero.x = x;
};
@@ -108,8 +116,18 @@
if (enemies[k].intersects(hero)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
+ // Decrease hero's health when an enemy passes by
+ if (enemies[k].y > 2732) {
+ health--;
+ healthTxt.setText('Health: ' + health);
+ // End the game if the hero's health reaches 0
+ if (health <= 0) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ }
}
// Spawn enemies
if (LK.ticks % 60 == 0) {
var enemy = new Enemy();
F16 2 boyut çapraz değil düz. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
ışın kılıcı ucu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2 boyut kanlı bir arkaplan. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2 boyut roket. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.