User prompt
blocks which are caught are placed beneath the hero
User prompt
blocks are placed right beneath the hero
User prompt
Pieces should stick on top of the character
User prompt
Make pieces stick to character upon collision
User prompt
Pieces should pile up on top of hero character
User prompt
Pieces should stack on top of the hero character on collision
User prompt
pieces should fall automatically
User prompt
make the interval 1second
User prompt
Make the pieces spawn in a random location at a 0.5s interval
User prompt
Make it so that the mouse movement moves the hero character
User prompt
Fix Bug: 'ReferenceError: hero is not defined' in this line: 'if (self.y >= hero.y) {' Line Number: 10
User prompt
make the pieces fall on top of the hero character
User prompt
Create a physics based game where the hero character has to catch falling blocks and balance them so they don't fall
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'enemies[b].move();' Line Number: 47
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'move')' in this line: 'pizzas[a].move();' Line Number: 40
Initial prompt
Stacker
var Block = Container.expand(function () { var self = Container.call(this); var blockGraphics = self.createAsset('block', 'Block Graphics', .5, .5); self.speed = 5; self.falling = false; self.move = function (hero) { if (!self.falling) { self.y += self.speed; self.rotation += 0.1; if (hero.intersects(self)) { self.falling = true; hero.balance(self); } } else { self.y = hero.y + hero.height; self.x = hero.x; } }; }); var Pizza = Container.expand(function () { var self = Container.call(this); var pizzaGraphics = self.createAsset('pizza', 'Pizza Graphics', .5, .5); self.speed = 5; self.move = function () {}; self.destroy = function () {}; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero Graphics', .5, .5); self.speed = 5; self.move = function (dx, dy) { self.x += dx * self.speed; self.y += dy * self.speed; }; self.balance = function (block) { block.y = self.y + self.height; block.x = self.x; block.speed = 0; self.addChild(block); block.falling = false; }; }); var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy Graphics', .5, .5); self.speed = 3; self.move = function () {}; self.destroy = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); LK.stageContainer.setBackgroundColor(0x000000); var hero = self.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 / 2; var blocks = []; var spawnBlocks = function () { var block = new Block(); block.x = Math.random() * 2048; block.y = 0; self.addChild(block); blocks.push(block); }; LK.setInterval(spawnBlocks, 1000); stage.on('move', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); hero.x = pos.x; hero.y = pos.y; }); LK.on('tick', function () { hero.move(); for (var a = blocks.length - 1; a >= 0; a--) { blocks[a].move(hero); if (blocks[a].y < -50) { blocks[a].destroy(); blocks.splice(a, 1); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -11,9 +11,9 @@
self.falling = true;
hero.balance(self);
}
} else {
- self.y = hero.y - self.height;
+ self.y = hero.y + hero.height;
self.x = hero.x;
}
};
});
@@ -32,9 +32,9 @@
self.x += dx * self.speed;
self.y += dy * self.speed;
};
self.balance = function (block) {
- block.y = self.y - block.height;
+ block.y = self.y + self.height;
block.x = self.x;
block.speed = 0;
self.addChild(block);
block.falling = false;
@@ -55,10 +55,10 @@
hero.y = 2732 / 2;
var blocks = [];
var spawnBlocks = function () {
var block = new Block();
- block.x = hero.x;
- block.y = hero.y + hero.height;
+ block.x = Math.random() * 2048;
+ block.y = 0;
self.addChild(block);
blocks.push(block);
};
LK.setInterval(spawnBlocks, 1000);