User prompt
if in negetives end game
User prompt
If red flower hits player reduce 5 points
User prompt
every 20 points and a little more red flowers
User prompt
Spawn red flowers closer to flowers
User prompt
Reduce the amount of red flowers that fall
User prompt
if red flowers hit ground do not end game
User prompt
spawn red flowers with the regular ones
User prompt
Every time you get 20 flowers speed the fall time by a little
Initial prompt
Flower Pot
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Flower class representing the falling flowers var Flower = Container.expand(function () { var self = Container.call(this); var flowerGraphics = self.attachAsset('flower', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; // Speed at which the flower falls self.update = function () { self.y += self.speed; }; }); // Pot class representing the player's pot var Pot = Container.expand(function () { var self = Container.call(this); var potGraphics = self.attachAsset('pot', { anchorX: 0.5, anchorY: 0.5 }); self.down = function (x, y, obj) { var game_position = game.toLocal(obj.global); self.x = game_position.x; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background to represent the sky }); /**** * Game Code ****/ var flowers = []; var pot = game.addChild(new Pot()); pot.x = 2048 / 2; pot.y = 2500; // Position the pot near the bottom of the screen var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); game.update = function () { for (var i = flowers.length - 1; i >= 0; i--) { var flower = flowers[i]; if (flower.y > 2732) { // Flower hit the ground LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } if (flower.intersects(pot)) { // Flower caught by the pot score += 1; scoreTxt.setText('Score: ' + score); flower.destroy(); flowers.splice(i, 1); // Increase the speed of the falling flowers every time the score reaches a multiple of 20 if (score % 20 == 0) { Flower.prototype.speed += 0.5; } continue; } } if (LK.ticks % 60 == 0) { // Create a new flower every second var newFlower = new Flower(); newFlower.x = Math.random() * 2048; newFlower.y = 0; flowers.push(newFlower); game.addChild(newFlower); } }; game.down = function (x, y, obj) { pot.down(x, y, obj); };
===================================================================
--- original.js
+++ change.js
@@ -1,81 +1,85 @@
-/****
+/****
* Classes
-****/
+****/
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Flower class representing the falling flowers
var Flower = Container.expand(function () {
- var self = Container.call(this);
- var flowerGraphics = self.attachAsset('flower', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5; // Speed at which the flower falls
- self.update = function () {
- self.y += self.speed;
- };
+ var self = Container.call(this);
+ var flowerGraphics = self.attachAsset('flower', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5; // Speed at which the flower falls
+ self.update = function () {
+ self.y += self.speed;
+ };
});
// Pot class representing the player's pot
var Pot = Container.expand(function () {
- var self = Container.call(this);
- var potGraphics = self.attachAsset('pot', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.down = function (x, y, obj) {
- var game_position = game.toLocal(obj.global);
- self.x = game_position.x;
- };
+ var self = Container.call(this);
+ var potGraphics = self.attachAsset('pot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.down = function (x, y, obj) {
+ var game_position = game.toLocal(obj.global);
+ self.x = game_position.x;
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x87CEEB // Light blue background to represent the sky
+ backgroundColor: 0x87CEEB // Light blue background to represent the sky
});
-/****
+/****
* Game Code
-****/
+****/
var flowers = [];
var pot = game.addChild(new Pot());
pot.x = 2048 / 2;
pot.y = 2500; // Position the pot near the bottom of the screen
var score = 0;
var scoreTxt = new Text2('Score: 0', {
- size: 100,
- fill: 0xFFFFFF
+ size: 100,
+ fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
game.update = function () {
- for (var i = flowers.length - 1; i >= 0; i--) {
- var flower = flowers[i];
- if (flower.y > 2732) {
- // Flower hit the ground
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- return;
- }
- if (flower.intersects(pot)) {
- // Flower caught by the pot
- score += 1;
- scoreTxt.setText('Score: ' + score);
- flower.destroy();
- flowers.splice(i, 1);
- continue;
- }
- }
- if (LK.ticks % 60 == 0) {
- // Create a new flower every second
- var newFlower = new Flower();
- newFlower.x = Math.random() * 2048;
- newFlower.y = 0;
- flowers.push(newFlower);
- game.addChild(newFlower);
- }
+ for (var i = flowers.length - 1; i >= 0; i--) {
+ var flower = flowers[i];
+ if (flower.y > 2732) {
+ // Flower hit the ground
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ return;
+ }
+ if (flower.intersects(pot)) {
+ // Flower caught by the pot
+ score += 1;
+ scoreTxt.setText('Score: ' + score);
+ flower.destroy();
+ flowers.splice(i, 1);
+ // Increase the speed of the falling flowers every time the score reaches a multiple of 20
+ if (score % 20 == 0) {
+ Flower.prototype.speed += 0.5;
+ }
+ continue;
+ }
+ }
+ if (LK.ticks % 60 == 0) {
+ // Create a new flower every second
+ var newFlower = new Flower();
+ newFlower.x = Math.random() * 2048;
+ newFlower.y = 0;
+ flowers.push(newFlower);
+ game.addChild(newFlower);
+ }
};
game.down = function (x, y, obj) {
- pot.down(x, y, obj);
+ pot.down(x, y, obj);
};
\ No newline at end of file