User prompt
The flies should never spawn above the score and hearts
User prompt
move the life hearts down by about 60 pixels
User prompt
shrink the score text by about 20% and move it 50 pixels left
User prompt
The player shouldn't be able to tap while the plant is moving
User prompt
move the score to the left by 100 pixels
User prompt
When a fly has a positive x movement speed the sprite should be normal, when it is moving negative x it should be flipped
User prompt
add a background graphic
User prompt
Flies should only appear in the top half of the screen
User prompt
When a fly is caught by the plant, make sure it is removed so it can't be caught again
User prompt
The plant should return from the endpoint of where the player tapped
User prompt
Allow the plant to move on the x axis based on where the player taps
User prompt
When the player taps the screen the plant should jump up to where they tapped then fall back down to where they started
User prompt
Fix Bug: 'ReferenceError: Can't find variable: scoreTxt' in this line: 'scoreTxt.setText(LK.gui.topRight.score);' Line Number: 54
User prompt
When the plant collides with a fly destroy the fly and add 100 to the score
User prompt
Make a function that spawns a new fly from either the right or the left edge of the screen
User prompt
Fix Bug: 'ReferenceError: Can't find variable: flies' in this line: 'flies.push(newFly);' Line Number: 62
User prompt
When a fly is destroyed spawn a new one
User prompt
When the plant collides with a fly destroy the fly and add 100 to the score
User prompt
Move the hearts down by 60 pixels
User prompt
Move the score to the left by 60 pixels
User prompt
Move the score to the left by 30 pixels
User prompt
Move the score to the top right and hearts to the top left
User prompt
The hearts should be 10 pixels from the top right
User prompt
Move the hearts to the top right
User prompt
Add three hearts at the top of the screen to represent the player’s life
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 / 2 - self.height); }; 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.launchAt = function (x, y) { var startX = self.x; var startY = self.y; var endX = x; var endY = y; var time = 0; 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.moveTowards = null; } }; }; var plantGraphics = self.createAsset('plant', 'Plant Graphics', .5, .5); self.catchFly = function (fly) { if (self.intersects(fly)) { fly.destroy(); LK.gui.topRight.score += 100; self.parent.scoreTxt.setText(LK.gui.topRight.score); return true; } return false; }; }); var Game = Container.expand(function () { var self = Container.call(this); stage.on('down', function (obj) { 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: 150, fill: "#ffffff" }); self.scoreTxt.anchor.set(.5, 0); LK.gui.topRight.addChild(self.scoreTxt); self.scoreTxt.x -= 90; 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 = 60; 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
@@ -14,11 +14,15 @@
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;
- flyGraphics.scale.x *= -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();
}
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.