User prompt
move the messages to the top of the screen where the score is. hide the score until after the messages are gone.
User prompt
Show these three messages one after the other at the start of the game for 2.5 seconds each, "Catch the flies!" "Avoid the bees!" "Keep moving!"
User prompt
At the start of the game add text to the screen for 3 seconds that says, "Catch the flies, avoid the bees!"
User prompt
make the spider 3x bigger
User prompt
move the score left by 30 and make it yellow
User prompt
move the spider up by 30
User prompt
move the spider up by 30
User prompt
make the score centered
User prompt
move the score to the top layer at the center of the screen
User prompt
I can't see it
User prompt
move the score display to the top middle
User prompt
move the score right by 300
User prompt
move the score right by 800
User prompt
move the score display left by 1600
User prompt
slow the spider down a little
User prompt
Okay, so spider should start offscreen at the left and while the plant is on the ground slowly move to the right
User prompt
don't reset the spider x position after a delay
User prompt
don't randomize the spider y position
User prompt
the spider should never change y position
User prompt
the spider x position shouldn't update when the player is in the air
User prompt
The spider should never move on the y axis
User prompt
When the spider starts moving, it should move slowly to the right.
User prompt
The spider should start moving if the player hasn't jumped in 3 seconds.
User prompt
the spider never moves
User prompt
if the player sits for longer than 3 seconds, start moving the spider slowly towards the plant. When the player jumps stop the spider.
var Spider = Container.expand(function () { var self = Container.call(this); var spiderGraphics = self.createAsset('spider', 'Spider Graphics', .5, .5); spiderGraphics.scale.x = 2; spiderGraphics.scale.y = 2; self.x = -spiderGraphics.width; self.y = 2732 - spiderGraphics.height - 200; self.xSpeed = 1; }); var EmptyHeart = Container.expand(function () { var self = Container.call(this); var emptyHeartGraphics = self.createAsset('empty_heart', 'Empty Heart Graphics', .5, .5); }); var RightBee = Container.expand(function () { var self = Container.call(this); var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5); beeGraphics.scale.x = 1.2; beeGraphics.scale.y = 1.2; self.spawnBee = function () { self.x = 2048 + 100; self.y = Math.random() * (2732 / 2); self.xSpeed = -(Math.random() * 7 + 3); }; self.spawnBee(); self.move = function () { self.x += self.xSpeed; if (self.x < -50) { self.y = Math.random() * (2732 / 2); self.xSpeed = -(Math.random() * 7 + 3); self.x = 2048 + 100; } }; }); var LeftBee = Container.expand(function () { var self = Container.call(this); var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5); beeGraphics.scale.x = -1.2; beeGraphics.scale.y = 1.2; self.spawnBee = function () { self.x = -100; self.y = Math.random() * (2732 / 2); self.xSpeed = Math.random() * 7 + 3; }; self.spawnBee(); self.move = function () { self.x += self.xSpeed; if (self.x > 2048 + 50) { self.y = Math.random() * (2732 / 2); self.xSpeed = Math.random() * 7 + 3; self.x = -100; } }; }); var Bee = Container.expand(function () { var self = Container.call(this); var beeGraphics = self.createAsset('bee', 'Bee Graphics', .5, .5); beeGraphics.scale.x = 1.8; beeGraphics.scale.y = 1.2; self.spawnBee(); }); 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.parent.spiderMoveTimer = 0; self.parent.spiderIsMoving = false; LK.clearInterval(self.parent.spiderMoveInterval); self.fliesCaughtInJump = 0; if (x > 2048 / 2) { self.scale.x = -1; } else { self.scale.x = 1; } self.moveTowards = function () { if (time <= 30) { self.x = startX + (endX - startX) * (time / 30); self.y = startY - (startY - endY) * (time / 30); time++; } else if (time <= 90) { self.x = endX - (endX - startX) * ((time - 30) / 60); self.y = endY + (startY - endY) * ((time - 30) / 60); time++; } else { self.isMoving = false; self.moveTowards = null; self.parent.targetScore += self.fliesCaughtInJump * 100 + self.parent.bonusScore; self.fliesCaughtInJump = 0; self.parent.bonusScore = 0; self.parent.spiderMoveInterval = LK.setInterval(function () { if (!self.isMoving && !self.parent.spiderIsMoving) { self.parent.spiderIsMoving = true; self.parent.children[1].x = Math.random() * (2048 - self.parent.children[1].width); } }, 3000); } }; }; var plantGraphics = self.createAsset('plant', 'Plant Graphics', .5, .5); self.catchFly = function (fly) { if (self.intersects(fly)) { fly.destroy(); self.fliesCaughtInJump = (self.fliesCaughtInJump || 0) + 1; if (fly.y < 2732 / 3) { self.parent.bonusScore += 150; } return true; } return false; }; self.hitByBee = function (bee) { if (self.intersects(bee) && !self.hit) { self.hit = true; LK.effects.flashObject(self, 0xff0000, 1000); self.x = 2048 / 2; self.y = 2732 - self.height - 100; self.parent.loseHeart(); if (self.isMoving) { self.isMoving = false; self.moveTowards = null; } LK.setTimeout(function () { self.hit = false; }, 1000); return true; } return false; }; }); var Game = Container.expand(function () { var self = Container.call(this); self.spiderMoveTimer = 0; self.spiderIsMoving = false; self.scoreTxt = new Text2('0', { size: 120, fill: "#ffff00", align: 'right' }); LK.gui.topRight.addChild(self.scoreTxt); self.scoreTxt.anchor.set(1, 0); self.scoreTxt.x = LK.gui.topRight.width - self.scoreTxt.width - 20; self.scoreTxt.y = 20; self.targetScore = 0; self.bonusScore = 0; self.targetScore = 0; self.currentScore = 0; self.updateScore = function (fliesCaught) { if (!plant.isMoving) { self.targetScore += fliesCaught * (fliesCaught > 1 ? 150 : 100); } }; LK.on('tick', function () { if (!plant.isMoving && self.currentScore < self.targetScore) { self.currentScore += 5; if (self.currentScore > self.targetScore) { self.currentScore = self.targetScore; } self.scoreTxt.setText(self.currentScore); } }); stage.on('down', function (obj) { if (!plant.isMoving && !plant.hit) { 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 spider = self.addChild(new Spider()); var flies = []; var plant = self.addChild(new Plant()); plant.x = 2048 / 2; plant.y = 2732 - plant.height - 100; self.incrementScoreAmount = 100; var hearts = []; self.loseHeart = function () { if (hearts.length > 0) { var lostHeart = hearts.pop(); var emptyHeart = new EmptyHeart(); emptyHeart.x = lostHeart.x; emptyHeart.y = lostHeart.y; LK.effects.flashObject(emptyHeart, 0xff0000, 1000); LK.gui.topLeft.addChild(emptyHeart); lostHeart.destroy(); } if (hearts.length === 0) { isGameOver = true; } }; for (var i = 0; i < 3; i++) { var heart = new Heart(); heart.x = 600 + i * (heart.width + 10); heart.y = 1840; LK.gui.topLeft.addChild(heart); hearts.push(heart); } var isGameOver = false; var flySpawnTimer = 0; var bees = []; var leftBee = new LeftBee(); bees.push(leftBee); self.addChild(leftBee); var rightBee = new RightBee(); bees.push(rightBee); self.addChild(rightBee); 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(); } bees.forEach(function (bee) { bee.move(); if (plant.hitByBee(bee)) {} }); if (!plant.isMoving) { spider.x += spider.xSpeed; if (spider.x > 2048) { spider.x = -spider.width; } } if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -2,10 +2,11 @@
var self = Container.call(this);
var spiderGraphics = self.createAsset('spider', 'Spider Graphics', .5, .5);
spiderGraphics.scale.x = 2;
spiderGraphics.scale.y = 2;
- self.x = 100;
+ self.x = -spiderGraphics.width;
self.y = 2732 - spiderGraphics.height - 200;
+ self.xSpeed = 1;
});
var EmptyHeart = Container.expand(function () {
var self = Container.call(this);
var emptyHeartGraphics = self.createAsset('empty_heart', 'Empty Heart Graphics', .5, .5);
@@ -269,13 +270,12 @@
bees.forEach(function (bee) {
bee.move();
if (plant.hitByBee(bee)) {}
});
- if (self.spiderIsMoving) {
+ if (!plant.isMoving) {
spider.x += spider.xSpeed;
- if (spider.x > 2048 - spider.width) {
- self.spiderIsMoving = false;
- spider.xSpeed = 0;
+ if (spider.x > 2048) {
+ spider.x = -spider.width;
}
}
if (isGameOver) {
LK.effects.flashScreen(0xff0000, 1000);
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.