User prompt
the bees never get fully onto the screen
User prompt
Just copy the fly movement function so it works with the bees
User prompt
the bees are stuck at the edge of the screen
User prompt
the bees should move exactly like the flies except a bit slower
User prompt
The bees should move towards the middle of the screen and then return to the side they spawned from
User prompt
The bees should appear from offscreen to the left or right
User prompt
Make the bees faster
User prompt
make the move like the flies
User prompt
make the bees 50% bigger
User prompt
Add two bees on the screen\
User prompt
Fix Bug: 'TypeError: LK.audio.play is not a function' in this line: 'LK.audio.play('launchSound');' Line Number: 43
User prompt
When the plant launches it should make a sound
User prompt
Make the score increment by 5 when counting up
User prompt
On each jump the target score earned should be flies * 100
User prompt
If I collect 3 flies in a jump the target score should increase by 300. If I only catch one it should only increase by 100
User prompt
If the player collects another fly the target score should increase
User prompt
Make sure to adjust the target score when the player collects multiple flies in one jump
User prompt
When the player earns points the score should start incrementing until it reaches their total score.
User prompt
make the score increment by 1 at a time so it doesn't add the score all at once
User prompt
move the black text to a lower layer
User prompt
add a black version of the score below it offset by 5 x and 5 y pixels
User prompt
make the score yellow
User prompt
When the flies are lower they should be 20% bigger
User prompt
move the hearts down by 100 pixels
User prompt
only spawn the flies up to 3/4 of the screen\
var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.createAsset('heart', 'Heart Graphics', .5, .5); }); var Fly = Container.expand(function () { var self = Container.call(this); var flyGraphics = self.createAsset('fly', 'Fly Graphics', .5, .5); self.spawnFly = function () { var direction = Math.random() < 0.5 ? -1 : 1; self.xSpeed = direction * (Math.random() * 10 + 5); self.x = direction > 0 ? -50 : 2048 + 50; self.y = Math.random() * (2732 * 3 / 4 - self.height - LK.gui.topRight.height); var scale = 1 + self.y / (2732 * 3 / 4) * 0.2; self.scale.x = self.scale.y = scale; }; self.spawnFly(); self.move = function () { if (self.xSpeed > 0 && self.x > 2048 / 2 && !self.changedDirection || self.xSpeed < 0 && self.x < 2048 / 2 && !self.changedDirection) { self.xSpeed *= -1; self.changedDirection = true; } if (self.xSpeed > 0) { flyGraphics.scale.x = 1; } else if (self.xSpeed < 0) { flyGraphics.scale.x = -1; } self.x += self.xSpeed; if (self.x > 2048 + 50 || self.x < -50) { self.spawnFly(); } }; }); var Plant = Container.expand(function () { var self = Container.call(this); self.isMoving = false; self.launchAt = function (x, y) { var startX = self.x; var startY = self.y; var endX = x; var endY = y; var time = 0; self.isMoving = true; self.moveTowards = function () { if (time <= 60) { self.x = startX + (endX - startX) * (time / 60); self.y = startY - (startY - endY) * (time / 60); time++; } else if (time <= 120) { self.x = endX - (endX - startX) * ((time - 60) / 60); self.y = endY + (startY - endY) * ((time - 60) / 60); time++; } else { self.isMoving = false; self.moveTowards = null; } }; }; var plantGraphics = self.createAsset('plant', 'Plant Graphics', .5, .5); self.catchFly = function (fly) { if (self.intersects(fly)) { fly.destroy(); self.parent.incrementScore(100); return true; } return false; }; }); var Game = Container.expand(function () { var self = Container.call(this); self.incrementScore = function (points) { LK.gui.topRight.score += points; self.scoreTxt.setText(LK.gui.topRight.score); self.scoreShadowTxt.setText(LK.gui.topRight.score); }; stage.on('down', function (obj) { if (!plant.isMoving) { var pos = obj.event.getLocalPosition(self); plant.launchAt(pos.x, pos.y); } }); var background = self.createAsset('background', 'Background Graphics', 0, 0); background.width = 2048; background.height = 2732; self.addChildAt(background, 0); var flies = []; var plant = self.addChild(new Plant()); plant.x = 2048 / 2; plant.y = 2732 - plant.height; self.scoreTxt = new Text2('0', { size: 120, fill: "#ffff00" }); self.scoreShadowTxt = new Text2('0', { size: 120, fill: "#000000" }); self.scoreTxt.anchor.set(.5, 0); self.scoreShadowTxt.anchor.set(.5, 0); LK.gui.topRight.addChild(self.scoreShadowTxt); LK.gui.topRight.addChild(self.scoreTxt); self.scoreTxt.x -= 240; self.scoreShadowTxt.x = self.scoreTxt.x + 5; self.scoreShadowTxt.y = self.scoreTxt.y + 5; LK.gui.topRight.score = 0; var hearts = []; for (var i = 0; i < 3; i++) { var heart = new Heart(); heart.x = (i + 1) * (heart.width + 10) + 10; heart.y = 120; LK.gui.topLeft.addChild(heart); hearts.push(heart); } var isGameOver = false; var flySpawnTimer = 0; LK.on('tick', function () { for (var a = flies.length - 1; a >= 0; a--) { if (flies[a]) { flies[a].move(); if (flies[a].x > 2048 + 50) { flies[a].destroy(); flies.splice(a, 1); } } } flySpawnTimer++; if (flySpawnTimer >= 120 && flies.length < 5) { var newFly = new Fly(); flies.push(newFly); self.addChild(newFly); flySpawnTimer = 0; } for (var a = flies.length - 1; a >= 0; a--) { if (plant.catchFly(flies[a])) { flies.splice(a, 1); } } if (plant.moveTowards) { plant.moveTowards(); } if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -67,21 +67,11 @@
});
var Game = Container.expand(function () {
var self = Container.call(this);
self.incrementScore = function (points) {
- var currentScore = LK.gui.topRight.score;
- var targetScore = currentScore + points;
- var increment = function () {
- if (currentScore < targetScore) {
- currentScore++;
- self.scoreTxt.setText(currentScore);
- self.scoreShadowTxt.setText(currentScore);
- LK.setTimeout(increment, 10);
- } else {
- LK.gui.topRight.score = currentScore;
- }
- };
- increment();
+ LK.gui.topRight.score += points;
+ self.scoreTxt.setText(LK.gui.topRight.score);
+ self.scoreShadowTxt.setText(LK.gui.topRight.score);
};
stage.on('down', function (obj) {
if (!plant.isMoving) {
var pos = obj.event.getLocalPosition(self);
Simple side view of a pixel art fly on a sky blue background Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Head of a carnivorous plant, mouth open at top, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art heart green Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a jungle with light streaming in from above, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a pixel art bee, cute, side view, flying, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a dark green box surrounded by vines, pixel art Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a blackened cracked heart, pixel art, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute orange-yellow spider, side view, pixel art, fangs, no shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.