Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: LK.effects.particleExplosion is not a function' in this line: 'LK.effects.particleExplosion(bee.x, bee.y, '#FFD700', 100, 1);' Line Number: 111
User prompt
show a particleexplosion when bee lands on a flower
Code edit (7 edits merged)
Please save this source code
User prompt
flowers should spawn between 300 and 1748 x
User prompt
if a flower moves off screen, destroy it and spawn a new flower above top of screen
Code edit (1 edits merged)
Please save this source code
User prompt
make flowers move slowly towards bottom of screen after bee lands on first one
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: backgroundGraphics.alpha.set is not a function' in this line: 'backgroundGraphics.alpha.set(0.7);' Line Number: 65
Code edit (10 edits merged)
Please save this source code
User prompt
stretch background to fill entire stage area
User prompt
show the background graphics under eveything
User prompt
make a background graphics element below everything else
Code edit (1 edits merged)
Please save this source code
Code edit (14 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: flower is not defined' in this line: 'ang = flower.rotatino * (180 / Math.PI);' Line Number: 22
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Math.RadToDeg is not a function' in this line: 'var ang = Math.RadToDeg(self.rotation);' Line Number: 21
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Math.RadToDeg is not a function' in this line: 'var ang = Math.RadToDeg(self.rotation);' Line Number: 23
Code edit (1 edits merged)
Please save this source code
User prompt
it should look like bee is stuck on side of flower
var MAX_ROTATION_SPEED = 0.01; var maxV = 4; var Bee = Container.expand(function () { var self = Container.call(this); self.canJump = true; self.beeJumping = false; self.onFlower = false; self.currentFlower = null; var beeGraphics = self.createAsset('bee', 'Bee character', .5, .5); beeGraphics.scale.set(2); self.speed = 5; self.collectNectar = function () {}; self.update = function () { if (self.beeJumping) { self.x += self.speed * Math.cos(self.rotation - Math.PI / 2); self.y += self.speed * Math.sin(self.rotation - Math.PI / 2); } if (self.onFlower && self.currentFlower) { var currentFlower = self.currentFlower; var orbitRadius = currentFlower.height / 1.5; self.rotation += self.rotationStep; self.rotation = currentFlower.rotation; var ang = self.rotation * (180 / Math.PI); ang = self.rotation; self.x += maxV * Math.sin(ang); self.y += maxV * -Math.cos(ang); self.x = currentFlower.x + orbitRadius * Math.sin(ang); self.y = currentFlower.y + orbitRadius * -Math.cos(ang); } if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) { LK.showGameOver(); } }; Object.defineProperty(self, 'height', { get: function () { return beeGraphics.height; } }); }); var Flower = Container.expand(function () { var self = Container.call(this); var flowerType = Math.floor(Math.random() * 8) + 1; var flowerGraphics = self.createAsset('flower' + flowerType, 'Flower Type ' + flowerType, .5, .5); var randomScale = Math.random() * 2 + 2; flowerGraphics.scale.set(randomScale); self.addChild(flowerGraphics); for (var i = 1; i <= 8; i++) { LK.getAsset('flower' + i, 'Flower Type ' + i, .5, .5); } self.canCollide = true; self.rotationStep = (Math.random() < 0.5 ? -1 : 1) * MAX_ROTATION_SPEED; self.produceNectar = function () {}; self.update = function () { self.rotation += self.rotationStep; }; }); var Nectar = Container.expand(function () { var self = Container.call(this); var nectarGraphics = self.createAsset('nectar', 'Nectar', .5, .5); }); var Background = Container.expand(function () { var self = Container.call(this); var backgroundGraphics = self.createAsset('background', 'Background', 0, 0); self.addChild(backgroundGraphics); }); var Game = Container.expand(function () { var self = Container.call(this); var bee = self.addChild(new Bee()); var flowers = [self.addChild(new Flower()), self.addChild(new Flower()), self.addChild(new Flower())]; flowers[0].y = 400; flowers[1].y = 1100; flowers[2].y = 1800; flowers[0].x = 904; flowers[1].x = 1200; flowers[2].x = 1024; flowers.forEach(function (flower, index) { flower.y += flower.height / 2; }); var nectars = []; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); LK.gui.topCenter.addChild(scoreTxt); var isGameOver = false; bee.x = 1024; bee.y = 2732 - bee.height - 100; LK.on('tick', function () { bee.update(); flowers.forEach(function (flower) { if (flower.canCollide == true) { if (bee.intersects(flower)) { if (!bee.onFlower) { bee.x = flower.x; bee.y = flower.y - flower.height / 1.5; } bee.rotationStep = flower.rotationStep; bee.currentFlower = flower; bee.beeJumping = false; bee.onFlower = true; flower.canCollide = false; bee.canJump = true; } } }); if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } for (var i = 0; i < flowers.length; i++) { flowers[i].produceNectar(); flowers[i].update(); } for (var j = 0; j < nectars.length; j++) { if (bee.intersects(nectars[j])) { bee.collectNectar(); nectars[j].destroy(); nectars.splice(j, 1); } } }); stage.on('down', function (obj) { if (bee.canJump) { bee.beeJumping = true; bee.canJump = false; bee.onFlower = false; bee.currentFlower = null; } }); });
===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
var MAX_ROTATION_SPEED = 0.01;
var maxV = 4;
var Bee = Container.expand(function () {
var self = Container.call(this);
+ self.canJump = true;
self.beeJumping = false;
self.onFlower = false;
self.currentFlower = null;
var beeGraphics = self.createAsset('bee', 'Bee character', .5, .5);
@@ -19,9 +20,9 @@
var orbitRadius = currentFlower.height / 1.5;
self.rotation += self.rotationStep;
self.rotation = currentFlower.rotation;
var ang = self.rotation * (180 / Math.PI);
- ang = self.rotation * Math.PI / 2;
+ ang = self.rotation;
self.x += maxV * Math.sin(ang);
self.y += maxV * -Math.cos(ang);
self.x = currentFlower.x + orbitRadius * Math.sin(ang);
self.y = currentFlower.y + orbitRadius * -Math.cos(ang);
@@ -45,8 +46,9 @@
self.addChild(flowerGraphics);
for (var i = 1; i <= 8; i++) {
LK.getAsset('flower' + i, 'Flower Type ' + i, .5, .5);
}
+ self.canCollide = true;
self.rotationStep = (Math.random() < 0.5 ? -1 : 1) * MAX_ROTATION_SPEED;
self.produceNectar = function () {};
self.update = function () {
self.rotation += self.rotationStep;
@@ -55,8 +57,13 @@
var Nectar = Container.expand(function () {
var self = Container.call(this);
var nectarGraphics = self.createAsset('nectar', 'Nectar', .5, .5);
});
+var Background = Container.expand(function () {
+ var self = Container.call(this);
+ var backgroundGraphics = self.createAsset('background', 'Background', 0, 0);
+ self.addChild(backgroundGraphics);
+});
var Game = Container.expand(function () {
var self = Container.call(this);
var bee = self.addChild(new Bee());
var flowers = [self.addChild(new Flower()), self.addChild(new Flower()), self.addChild(new Flower())];
@@ -80,17 +87,21 @@
bee.y = 2732 - bee.height - 100;
LK.on('tick', function () {
bee.update();
flowers.forEach(function (flower) {
- if (bee.intersects(flower)) {
- if (!bee.onFlower) {
- bee.x = flower.x;
- bee.y = flower.y - flower.height / 1.5;
+ if (flower.canCollide == true) {
+ if (bee.intersects(flower)) {
+ if (!bee.onFlower) {
+ bee.x = flower.x;
+ bee.y = flower.y - flower.height / 1.5;
+ }
+ bee.rotationStep = flower.rotationStep;
+ bee.currentFlower = flower;
+ bee.beeJumping = false;
+ bee.onFlower = true;
+ flower.canCollide = false;
+ bee.canJump = true;
}
- bee.rotationStep = flower.rotationStep;
- bee.currentFlower = flower;
- bee.beeJumping = false;
- bee.onFlower = true;
}
});
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
@@ -108,7 +119,12 @@
}
}
});
stage.on('down', function (obj) {
- bee.beeJumping = true;
+ if (bee.canJump) {
+ bee.beeJumping = true;
+ bee.canJump = false;
+ bee.onFlower = false;
+ bee.currentFlower = null;
+ }
});
});
A large red round flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A large blue round flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round yellow flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round purple and red flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round green and yellow flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round orange and white flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round cyan and blue flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A round magenta and green flower. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little bee. Top down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a lush meadow full of tiny flowers. top-down view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
yellow pointy star twinkle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.