User prompt
Fix Bug: 'ReferenceError: supplyBox is not defined' in or related to this line: 'if (supplyBox && !supplyBox.active && hero.intersects(supplyBox)) {' Line Number: 153
User prompt
Fix Bug: 'ReferenceError: supplyBox is not defined' in or related to this line: 'if (supplyBox && !supplyBox.active && hero.intersects(supplyBox)) {' Line Number: 153
User prompt
加一个补给箱,颜色为红色,英雄碰到补给箱的时候,可以每次发出两颗子弹,持续时间20秒,之后又恢复到一次只能射出一颗子弹。
User prompt
你好
User prompt
敌人受到英雄子弹攻击的时候就会自动毁灭
User prompt
受到子弹的攻击以后,就会自动消失
Initial prompt
Tank World
/**** * Classes ****/ // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Hero update logic }; self.shoot = function () { // Hero shooting logic }; }); // 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 = 2; self.move = function () { self.y += self.speed; }; self.shoot = function () { // Enemy shooting logic }; }); // Bullet class for hero 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.move = function () { self.y += self.speed; }; }); // Bullet class for enemies var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.move = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Define assets for the hero, enemies, and bullets // Initialize hero var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 150; // Initialize arrays for bullets and enemies var heroBullets = []; var enemyBullets = []; var enemies = []; // Game tick event LK.on('tick', function () { // Update hero hero.update(); // Move and check hero bullets for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].move(); for (var k = enemies.length - 1; k >= 0; k--) { if (heroBullets[i] && heroBullets[i].intersects(enemies[k])) { heroBullets[i].destroy(); heroBullets.splice(i, 1); enemies[k].destroy(); enemies.splice(k, 1); break; } } if (heroBullets[i] && heroBullets[i].y < 0) { heroBullets[i].destroy(); heroBullets.splice(i, 1); } } // Move and check enemy bullets for (var j = enemyBullets.length - 1; j >= 0; j--) { enemyBullets[j].move(); if (enemyBullets[j].intersects(hero)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } if (enemyBullets[j] && enemyBullets[j].y > 2732) { enemyBullets[j].destroy(); enemyBullets.splice(j, 1); } } // Move enemies and check for game over for (var k = enemies.length - 1; k >= 0; k--) { enemies[k].move(); if (enemies[k].y > 2732) { LK.showGameOver(); } } // Spawn enemies if (LK.ticks % 120 == 0) { var newEnemy = new Enemy(); newEnemy.x = Math.random() * (2048 - newEnemy.width) + newEnemy.width / 2; newEnemy.y = -newEnemy.height / 2; enemies.push(newEnemy); game.addChild(newEnemy); } }); // Touch event to move hero game.on('down', function (obj) { var pos = obj.event.getLocalPosition(game); hero.x = pos.x; }); // Touch event to shoot game.on('up', function (obj) { var bullet = new HeroBullet(); bullet.x = hero.x; bullet.y = hero.y - hero.height / 2; heroBullets.push(bullet); game.addChild(bullet); });
===================================================================
--- original.js
+++ change.js
@@ -1,73 +1,73 @@
-/****
+/****
* Classes
****/
// Hero class
var Hero = Container.expand(function () {
- var self = Container.call(this);
- var heroGraphics = self.attachAsset('hero', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.update = function () {
- // Hero update logic
- };
- self.shoot = function () {
- // Hero shooting logic
- };
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.update = function () {
+ // Hero update logic
+ };
+ self.shoot = function () {
+ // Hero shooting logic
+ };
});
// 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 = 2;
- self.move = function () {
- self.y += self.speed;
- };
- self.shoot = function () {
- // Enemy shooting logic
- };
+ var self = Container.call(this);
+ var enemyGraphics = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 2;
+ self.move = function () {
+ self.y += self.speed;
+ };
+ self.shoot = function () {
+ // Enemy shooting logic
+ };
});
// Bullet class for hero
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.move = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('heroBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -10;
+ self.move = function () {
+ self.y += self.speed;
+ };
});
// Bullet class for enemies
var EnemyBullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('enemyBullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.move = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var bulletGraphics = self.attachAsset('enemyBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.move = function () {
+ self.y += self.speed;
+ };
});
-/****
+/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 // Init game with black background
+ backgroundColor: 0x000000 // Init game with black background
});
-/****
+/****
* Game Code
****/
-// Initialize hero
// Define assets for the hero, enemies, and bullets
+// Initialize hero
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
// Initialize arrays for bullets and enemies
@@ -75,51 +75,64 @@
var enemyBullets = [];
var enemies = [];
// Game tick event
LK.on('tick', function () {
- // Update hero
- hero.update();
- // Move and check hero bullets
- for (var i = heroBullets.length - 1; i >= 0; i--) {
- heroBullets[i].move();
- if (heroBullets[i].y < 0) {
- heroBullets[i].destroy();
- heroBullets.splice(i, 1);
- }
- }
- // Move and check enemy bullets
- for (var j = enemyBullets.length - 1; j >= 0; j--) {
- enemyBullets[j].move();
- if (enemyBullets[j].y > 2732) {
- enemyBullets[j].destroy();
- enemyBullets.splice(j, 1);
- }
- }
- // Move enemies and check for game over
- for (var k = enemies.length - 1; k >= 0; k--) {
- enemies[k].move();
- if (enemies[k].y > 2732) {
- LK.showGameOver();
- }
- }
- // Spawn enemies
- if (LK.ticks % 120 == 0) {
- var newEnemy = new Enemy();
- newEnemy.x = Math.random() * (2048 - newEnemy.width) + newEnemy.width / 2;
- newEnemy.y = -newEnemy.height / 2;
- enemies.push(newEnemy);
- game.addChild(newEnemy);
- }
+ // Update hero
+ hero.update();
+ // Move and check hero bullets
+ for (var i = heroBullets.length - 1; i >= 0; i--) {
+ heroBullets[i].move();
+ for (var k = enemies.length - 1; k >= 0; k--) {
+ if (heroBullets[i] && heroBullets[i].intersects(enemies[k])) {
+ heroBullets[i].destroy();
+ heroBullets.splice(i, 1);
+ enemies[k].destroy();
+ enemies.splice(k, 1);
+ break;
+ }
+ }
+ if (heroBullets[i] && heroBullets[i].y < 0) {
+ heroBullets[i].destroy();
+ heroBullets.splice(i, 1);
+ }
+ }
+ // Move and check enemy bullets
+ for (var j = enemyBullets.length - 1; j >= 0; j--) {
+ enemyBullets[j].move();
+ if (enemyBullets[j].intersects(hero)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ if (enemyBullets[j] && enemyBullets[j].y > 2732) {
+ enemyBullets[j].destroy();
+ enemyBullets.splice(j, 1);
+ }
+ }
+ // Move enemies and check for game over
+ for (var k = enemies.length - 1; k >= 0; k--) {
+ enemies[k].move();
+ if (enemies[k].y > 2732) {
+ LK.showGameOver();
+ }
+ }
+ // Spawn enemies
+ if (LK.ticks % 120 == 0) {
+ var newEnemy = new Enemy();
+ newEnemy.x = Math.random() * (2048 - newEnemy.width) + newEnemy.width / 2;
+ newEnemy.y = -newEnemy.height / 2;
+ enemies.push(newEnemy);
+ game.addChild(newEnemy);
+ }
});
// Touch event to move hero
game.on('down', function (obj) {
- var pos = obj.event.getLocalPosition(game);
- hero.x = pos.x;
+ var pos = obj.event.getLocalPosition(game);
+ hero.x = pos.x;
});
// Touch event to shoot
game.on('up', function (obj) {
- var bullet = new HeroBullet();
- bullet.x = hero.x;
- bullet.y = hero.y - hero.height / 2;
- heroBullets.push(bullet);
- game.addChild(bullet);
+ var bullet = new HeroBullet();
+ bullet.x = hero.x;
+ bullet.y = hero.y - hero.height / 2;
+ heroBullets.push(bullet);
+ game.addChild(bullet);
});
\ No newline at end of file
射出的是子弹形状. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
一个圆形的,黄铜色,补给包,里面是一堆子弹. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
一个坦克垂直乡下,炮筒垂直向下. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
坦克常用地形,科幻大片级别的. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
沙漠,大片级别的. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
很酷炫的飞机,科幻大片级别的那种. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
很酷炫的导弹,颜色很酷炫,比较明亮,导弹很长,没有火焰,导弹垂直向上,导弹在画面的正中间,科幻大片级别的那种效果,很逼真. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.