User prompt
make a text that shows me how many raindrops i got
User prompt
make the player move faster side to side
User prompt
add automatic side to side movement to the player
User prompt
make the player move automatically side to side
User prompt
make so you can move the umbrella to the sides and up and down
User prompt
make the umbrella moving up, down and side to side
User prompt
make the umbrella movable
User prompt
move the umbrella a little higher
Initial prompt
raining wet
/**** * Classes ****/ var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Player update logic will be handled in the game tick }; // Initialize player speed and direction self.speed = 10; self.direction = 1; }); var Umbrella = Container.expand(function () { var self = Container.call(this); var umbrellaGraphics = self.attachAsset('umbrella', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Umbrella update logic will be handled in the game tick }; }); var Raindrop = Container.expand(function () { var self = Container.call(this); var raindropGraphics = self.attachAsset('raindrop', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.move = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Light blue background to represent the sky }); /**** * Game Code ****/ game.on('up', function (obj) { dragNode = null; }); game.on('move', function (obj) { if (dragNode) { var currentPos = obj.event.getLocalPosition(game); dragNode.x = currentPos.x; dragNode.y = currentPos.y; } }); var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 - 150; // Initialize the raindrops caught counter text var raindropsCaughtText = new Text2('0', { size: 150, fill: "#ffffff" }); raindropsCaughtText.anchor.set(0.5, 0); LK.gui.top.addChild(raindropsCaughtText); var umbrella = game.addChild(new Umbrella()); umbrella.x = player.x; umbrella.y = player.y - 100; var raindrops = []; var dragNode = null; game.on('down', function (obj) { dragNode = umbrella; var touchPos = obj.event.getLocalPosition(game); dragNode.initialTouch = { x: touchPos.x, y: touchPos.y }; dragNode.initialPos = { x: dragNode.x, y: dragNode.y }; }); LK.on('tick', function () { // Toggle player direction when reaching the edges of the screen if (player.x <= 0 || player.x >= 2048) { player.direction *= -1; } // Move player side to side automatically player.x += player.speed * player.direction; // Create raindrops if (LK.ticks % 10 === 0) { var raindrop = new Raindrop(); raindrop.x = Math.random() * 2048; raindrop.y = -10; raindrops.push(raindrop); game.addChild(raindrop); } // Update raindrops for (var i = raindrops.length - 1; i >= 0; i--) { raindrops[i].move(); if (raindrops[i].y > 2732) { raindrops[i].destroy(); raindrops.splice(i, 1); } else if (raindrops[i].intersects(umbrella)) { // Increment the raindrops caught counter LK.setScore(LK.getScore() + 1); // Update the raindrops caught counter text raindropsCaughtText.setText(LK.getScore().toString()); raindrops[i].destroy(); raindrops.splice(i, 1); } else if (raindrops[i].intersects(player)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); break; } } });
===================================================================
--- original.js
+++ change.js
@@ -58,8 +58,15 @@
});
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 - 150;
+// Initialize the raindrops caught counter text
+var raindropsCaughtText = new Text2('0', {
+ size: 150,
+ fill: "#ffffff"
+});
+raindropsCaughtText.anchor.set(0.5, 0);
+LK.gui.top.addChild(raindropsCaughtText);
var umbrella = game.addChild(new Umbrella());
umbrella.x = player.x;
umbrella.y = player.y - 100;
var raindrops = [];
@@ -97,8 +104,12 @@
if (raindrops[i].y > 2732) {
raindrops[i].destroy();
raindrops.splice(i, 1);
} else if (raindrops[i].intersects(umbrella)) {
+ // Increment the raindrops caught counter
+ LK.setScore(LK.getScore() + 1);
+ // Update the raindrops caught counter text
+ raindropsCaughtText.setText(LK.getScore().toString());
raindrops[i].destroy();
raindrops.splice(i, 1);
} else if (raindrops[i].intersects(player)) {
LK.effects.flashScreen(0xff0000, 1000);
rainbow colored umbrella. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
raindrop. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cartoon full body person. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.