User prompt
Fix Bug: 'undefined is not an object (evaluating 'Enemy.expand')' in this line: 'var FastEnemy = Enemy.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'self.speed = (5 + Math.random() * 10) * 2')' in this line: 'self.speed = (5 + Math.random() * 10) * 2;' Line Number: 17
User prompt
Fix Bug: 'undefined is not an object (evaluating 'Enemy.expand')' in this line: 'var FastEnemy = Enemy.expand(function () {' Line Number: 1
User prompt
Fix Bug: 'TypeError: undefined is not an object (evaluating 'Enemy.expand')' in this line: 'var FastEnemy = Enemy.expand(function () {' Line Number: 1
User prompt
Make 30 percent of monsters 2x as fast
User prompt
Have monster icon flash white when hit by hero bullet
var FastEnemy = Enemy.expand(function () { var self = Enemy.call(this) || this; self.speed = (5 + Math.random() * 10) * 2; }); var HeroHealthItem = Container.expand(function () { var self = Container.call(this); var healthItemGraphics = self.createAsset('heroHealthItem', 'Hero Health Item Graphics', .5, .5); self.speed = -5; self.move = function () { self.y += self.speed; if (self.y < 0) { self.destroy(); } }; }); var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet Graphics', .5, .5); self.speed = 10; self.move = function () { self.x += self.speed; if (self.x > 2048) { self.destroy(); } }; }); var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('enemyBullet', 'Enemy Bullet Graphics', .5, .5); self.speed = -10; self.move = function () { self.x += self.speed; }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5); self.hitPoints = 5; self.hitPointIcons = []; self.takeDamage = function () { self.hitPoints--; if (self.hitPoints >= 0) { self.hitPointIcons[self.hitPoints].destroy(); self.hitPointIcons.splice(self.hitPoints, 1); } if (self.hitPoints <= 0) { LK.showGameOver(); } }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy Graphics', .5, .5); self.speed = 5 + Math.random() * 10; self.direction = 1; self.hitPoints = 3; self.move = function () { self.x -= self.speed; self.y += self.direction * 5; if (self.y > 2732 - self.height || self.y < self.height) { self.direction *= -1; } }; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Game Background', 0, 0); background.width = 2048; background.height = 2732; background.alpha = 0.5; var dragNode = null; var shootingInterval; stage.on('down', function (obj) { dragNode = hero; shootingInterval = LK.setInterval(function () { var bullet = new HeroBullet(); bullet.x = hero.x; bullet.y = hero.y; heroBullets.push(bullet); self.addChild(bullet); }, 200); }); stage.on('up', function (obj) { dragNode = null; LK.clearInterval(shootingInterval); }); stage.on('move', function (obj) { if (dragNode) { var pos = obj.event.getLocalPosition(self); dragNode.x = pos.x; dragNode.y = pos.y; } }); stage.on('up', function (obj) { dragNode = null; }); var heroBullets = []; var enemyBullets = []; var enemies = []; var hero = self.addChild(new Hero()); hero.x = hero.width; hero.y = 2732 / 2; var hitPointIcons = []; for (var i = 0; i < hero.hitPoints; i++) { var hitPointIcon = LK.getAsset('hpIcon', 'HP Icon', 0, 0); hitPointIcon.x = i * hitPointIcon.width; hitPointIcon.y = 0; hero.hitPointIcons.push(hitPointIcon); LK.gui.topLeft.addChild(hitPointIcon); } var score = 0; var scoreText = new Text2(score.toString(), { size: 150, fill: '#ffffff' }); scoreText.anchor.set(1, 0); LK.gui.topRight.addChild(scoreText); LK.on('tick', function () { for (var i = 0; i < heroBullets.length; i++) { heroBullets[i].move(); if (heroBullets[i].x > 2048) { heroBullets[i].destroy(); heroBullets.splice(i, 1); } for (var j = 0; j < enemies.length; j++) { if (heroBullets[i] && heroBullets[i].intersects(enemies[j])) { enemies[j].hitPoints--; heroBullets[i].destroy(); heroBullets.splice(i, 1); if (enemies[j].hitPoints <= 0) { var blast = self.createAsset('blast', 'Blast Graphics', .5, .5); blast.x = enemies[j].x; blast.y = enemies[j].y; self.addChild(blast); LK.setTimeout(function () { blast.destroy(); }, 500); enemies[j].destroy(); enemies.splice(j, 1); score++; scoreText.setText(score.toString()); } break; } } } for (var i = 0; i < enemyBullets.length; i++) { enemyBullets[i].move(); if (enemyBullets[i].x < 0) { enemyBullets[i].destroy(); enemyBullets.splice(i, 1); } } for (var i = 0; i < enemies.length; i++) { enemies[i].move(); if (enemies[i].x + enemies[i].width < 0) { enemies[i].destroy(); enemies.splice(i, 1); } if (hero.intersects(enemies[i])) { hero.takeDamage(); enemies[i].destroy(); enemies.splice(i, 1); } } if (LK.ticks % 72 == 0) { var enemy; if (Math.random() < 0.3) { enemy = new FastEnemy(); } else { enemy = new Enemy(); } enemy.x = 2048; enemy.y = Math.random() * (2732 - 2 * enemy.height); enemies.push(enemy); self.addChild(enemy); } if (LK.ticks % 1200 == 0) { var healthItem = new HeroHealthItem(); healthItem.x = Math.random() * (2048 - healthItem.width); healthItem.y = 2732; self.addChild(healthItem); } for (var i = 0; i < self.children.length; i++) { if (self.children[i] instanceof HeroHealthItem) { self.children[i].move(); if (hero.intersects(self.children[i])) { if (hero.hitPoints < 5) { hero.hitPoints++; var hitPointIcon = LK.getAsset('hpIcon', 'HP Icon', 0, 0); hitPointIcon.x = (hero.hitPoints - 1) * hitPointIcon.width; hitPointIcon.y = 0; hero.hitPointIcons.push(hitPointIcon); LK.gui.topLeft.addChild(hitPointIcon); } self.children[i].destroy(); } } } }); });
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,6 @@
var FastEnemy = Enemy.expand(function () {
- var self = Enemy.call(this);
+ var self = Enemy.call(this) || this;
self.speed = (5 + Math.random() * 10) * 2;
});
var HeroHealthItem = Container.expand(function () {
var self = Container.call(this);
Opossum in aviator cap, flying bi plane. Realistic Opossum , screaming opossum, ugly art style, meme, mouth open, side view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Lovecraftian monster, eyeballs, tentacles, floating Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Opossum head, icon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon overflowing trash can, game asset, floating Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Side view bullet blast, fireball, game asset Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Retro cityscape, pixel art 1930s, sky view, aerial view Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Gray red blob explosion, tentacles, eye balls, squelch Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.