User prompt
Add a 4px margin to bubbels
User prompt
Spawn bubbels when game start
User prompt
Use a 2D array for bubbels
User prompt
Create a 9x9 grid of bubbles
User prompt
Remove the code that spawns bubbles in tick
User prompt
Remove the hero class
User prompt
Remove the enemy class
User prompt
Fix Bug: 'TypeError: hero.update is not a function. (In 'hero.update()', 'hero.update' is undefined)' in this line: 'hero.update();' Line Number: 36
Initial prompt
Click remove
var Bubble = Container.expand(function () { var self = Container.call(this); var bubbleGraphics = self.createAsset('bubble', 'Bubble Graphics', .5, .5); self.move = function () {}; self.pop = function () {}; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5); self.shoot = function () {}; self.update = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); var bubbles = []; var hero = self.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - hero.height; var spawnBubble = function () { var newBubble = new Bubble(); bubbles.push(newBubble); self.addChild(newBubble); }; LK.on('tick', function () { hero.update(); for (var i = 0; i < bubbles.length; i++) { bubbles[i].move(); } if (LK.ticks % 60 == 0) { spawnBubble(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -9,43 +9,25 @@
var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5);
self.shoot = function () {};
self.update = function () {};
});
-var Enemy = Container.expand(function () {
- var self = Container.call(this);
- var enemyGraphics = self.createAsset('enemy', 'Enemy Graphics', .5, .5);
- self.move = function () {};
- self.attack = function () {};
-});
var Game = Container.expand(function () {
var self = Container.call(this);
var bubbles = [];
- var enemies = [];
var hero = self.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - hero.height;
var spawnBubble = function () {
var newBubble = new Bubble();
bubbles.push(newBubble);
self.addChild(newBubble);
};
- var spawnEnemy = function () {
- var newEnemy = new Enemy();
- enemies.push(newEnemy);
- self.addChild(newEnemy);
- };
LK.on('tick', function () {
hero.update();
for (var i = 0; i < bubbles.length; i++) {
bubbles[i].move();
}
- for (var i = 0; i < enemies.length; i++) {
- enemies[i].move();
- }
if (LK.ticks % 60 == 0) {
spawnBubble();
}
- if (LK.ticks % 300 == 0) {
- spawnEnemy();
- }
});
});