User prompt
after '2:53' min stop the game and show the final score and win or lose
User prompt
Show the scores of the players in the score background when scorebutton is clicked. βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
User prompt
Add scorebutton beside startbutton in intro from the right side by distance of 100px
User prompt
after time of the game music is finished stop the game and show highscore and the win or lose!
User prompt
Change lines from 50x3000 to be small like 50x500. Don't play gameover if miss any blocks just don't count it so like that if player reach 2000 he win if less then that he lose.
User prompt
The music stop but blocks keep respawning and the game didn't ends to show win with score background (create score background for that)!
User prompt
The game didn't stop when the gamemusic1 finished and the blocks keep respawning! if the music finished and the player score more than 2000 do win screen with the highscore background transparent.
User prompt
when the game music is finished do the final score background and when tap again go to intro to start from there again.
User prompt
can you respawn the blocks with same rhythm of the game music.
Code edit (2 edits merged)
Please save this source code
User prompt
change lines of blocks thickness a bit to 50px
Code edit (2 edits merged)
Please save this source code
User prompt
Add gamebackground to the game when the game is start
Code edit (1 edits merged)
Please save this source code
User prompt
Add introbackground before the game start and startbutton close to the bottom by 100px.
Code edit (1 edits merged)
Please save this source code
User prompt
Add introbackground before the game start and startbutton close to the bottom by 100px.
Code edit (1 edits merged)
Please save this source code
User prompt
change the lines to be from above not bellow the blocks!
User prompt
create a thin line taller continue with the block till it get touched with player then disappears it must be with same color of that block.
User prompt
Add the colors animations assets to the blocks when get touched by the player βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var PlayerCharacter = Container.expand(function () { var self = Container.call(this); var characterGraphics = self.attachAsset('playerCharacter', { anchorX: 0.5, anchorY: 0.5 }); // Set brown transparent color characterGraphics.alpha = 0.7; return self; }); //Storage library which should be used for persistent game data // var storage = LK.import('@upit/storage.v1'); //Library for using the camera (the background becomes the user's camera video feed) and the microphone. It can access face coordinates for interactive play, as well detect microphone volume / voice interactions // var facekit = LK.import('@upit/facekit.v1'); //Classes can only be defined here. You cannot create inline classes in the games code. var TerrainBlock = Container.expand(function (color, speed, noteId) { var self = Container.call(this); self.color = color; self.speed = speed; self.noteId = noteId; var blockGraphics = self.attachAsset('terrainBlock' + self.color, { anchorX: 0.5, anchorY: 0.5 }); // Create vertical line extending from block self.line = new Container(); // Get color hex value from colorMap var lineColor = 0xFFFFFF; // Default white if (color === 'Red') lineColor = 0xFF0000;else if (color === 'Orange') lineColor = 0xFFA500;else if (color === 'Yellow') lineColor = 0xFFFF00;else if (color === 'Green') lineColor = 0x008000;else if (color === 'Blue') lineColor = 0x0000FF;else if (color === 'Indigo') lineColor = 0x4B0082;else if (color === 'Violet') lineColor = 0xEE82EE; // Create thin vertical line shape var lineGraphics = LK.getAsset('line' + self.color, { width: 4, height: 3000, // Very tall to reach top color: lineColor, shape: 'box', anchorX: 0.5, anchorY: 1 }); self.line.addChild(lineGraphics); self.addChild(self.line); self.update = function () { self.y += self.speed; // Keep line positioned at block center extending upward if (self.line) { self.line.x = 0; self.line.y = 0; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //Note game dimensions are 2048x2732 /* Supported Types: 1. Shape: - Simple geometric figures with these properties: * width: (required) pixel width of the shape. * height: (required) pixel height of the shape. * color: (required) color of the shape. * shape: (required) type of shape. Valid options: 'box', 'ellipse'. 2. Image: - Imported images with these properties: * width: (required) pixel resolution width. * height: (required) pixel resolution height. * id: (required) identifier for the image. * flipX: (optional) horizontal flip. Valid values: 0 (no flip), 1 (flip). * flipY: (optional) vertical flip. Valid values: 0 (no flip), 1 (flip). * orientation: (optional) rotation in multiples of 90 degrees, clockwise. Valid values: - 0: No rotation. - 1: Rotate 90 degrees. - 2: Rotate 180 degrees. - 3: Rotate 270 degrees. Note: Width and height remain unchanged upon flipping. 3. Sound: - Sound effects with these properties: * id: (required) identifier for the sound. * volume: (optional) custom volume. Valid values are a float from 0 to 1. 4. Music: - In contract to sound effects, only one music can be played at a time - Music is using the same API to initilize just like sound. - Music loops by default - Music with these config options: * id: (required) identifier for the sound. * volume: (optional) custom volume. Valid values are a float from 0 to 1. * start: (optional) a float from 0 to 1 used for cropping and indicates the start of the cropping * end: (optional) a float from 0 to 1 used for cropping and indicates the end of the cropping */ // Assets are automatically created and loaded either dynamically during gameplay // or via static code analysis based on their usage in the code. // Initialize assets used in this game. Scale them according to what is needed for the game. //We have access to the following plugins. (Note that the variable names used are mandetory for each plugin) //Only include the plugins you need to create the game. //Minimalistic tween library which should be used for animations over time, including tinting / colouring an object, scaling, rotating, or changing any game object property. var terrainBlocks = []; var playerCharacter = null; var scoreTxt = null; var spawnInterval = 1000; // Milliseconds between block spawns var lastSpawnTime = 7; var terrainSpeed = 8; // Mapping colors to hex and sound IDs var colorMap = { 'Red': '#FF0000', 'Orange': '#FFA500', 'Yellow': '#FFFF00', 'Green': '#008000', 'Blue': '#0000FF', 'Indigo': '#4B0082', 'Violet': '#EE82EE' }; // Play background music LK.playMusic('Gamemusic1'); var colorNoteMap = { 'Red': 'noteC', 'Orange': 'noteD', 'Yellow': 'noteE', 'Green': 'noteF', 'Blue': 'noteG', 'Indigo': 'noteA', 'Violet': 'noteB' }; game.setBackgroundColor(0x000000); // Change background color to black scoreTxt = new Text2('0', { size: 150, fill: 0xFFFFFF }); scoreTxt.setText(LK.getScore()); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); playerCharacter = new PlayerCharacter(); // Position player character near the bottom center playerCharacter.x = 2048 / 2; playerCharacter.y = 2732 - playerCharacter.height - 100; // Offset from bottom game.addChild(playerCharacter); // The player character color will be set when the first block spawns. var dragNode = null; // Keep track of the element being dragged // Handle touch down on the game area game.down = function (x, y, obj) { // Check if the touch is on the player character dragNode = playerCharacter; }; // Handle touch move on the game area game.move = function (x, y, obj) { // Move the player character horizontally based on the cursor's x position, // ensuring it stays within the horizontal bounds of the screen. playerCharacter.x = Math.max(playerCharacter.width / 2, Math.min(2048 - playerCharacter.width / 2, x)); }; // Handle touch up on the game area game.up = function (x, y, obj) { dragNode = null; // Stop dragging }; game.update = function () { var currentTime = Date.now(); // Spawn new terrain blocks if (currentTime - lastSpawnTime > spawnInterval) { var colors = Object.keys(colorMap); var randomColor = colors[Math.floor(Math.random() * colors.length)]; var noteId = colorNoteMap[randomColor]; var newBlock = new TerrainBlock(randomColor, terrainSpeed, noteId); // Position block randomly at the top within game width newBlock.x = Math.random() * (2048 - newBlock.width) + newBlock.width / 2; newBlock.y = -newBlock.height; // Start above the screen terrainBlocks.push(newBlock); game.addChild(newBlock); lastSpawnTime = currentTime; // Gradually increase game speed / difficulty // spawnInterval = Math.max(500, spawnInterval - 1); // terrainSpeed = Math.min(15, terrainSpeed + 0.05); } // Update and check collisions for terrain blocks // Update and check collisions for terrain blocks for (var i = terrainBlocks.length - 1; i >= 0; i--) { var block = terrainBlocks[i]; if (block.lastY === undefined) { block.lastY = block.y; } // Check if block is off-screen if (block.lastY < 2732 + block.height && block.y >= 2732 + block.height) { // Missed block - game over LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); break; // Exit loop as game is over } // Check for intersection with player character var currentIntersecting = block.intersects(playerCharacter); if (currentIntersecting) { // Collect any color block LK.setScore(LK.getScore() + 10); scoreTxt.setText(LK.getScore()); // Create animation effect based on block color var animationAsset = null; if (block.color === 'Red') { animationAsset = LK.getAsset('Redanimation1', { anchorX: 0.5, anchorY: 0.5 }); } else if (block.color === 'Orange') { animationAsset = LK.getAsset('Orangeanimation1', { anchorX: 0.5, anchorY: 0.5 }); } else if (block.color === 'Yellow') { animationAsset = LK.getAsset('Yellowanimation1', { anchorX: 0.5, anchorY: 0.5 }); } else if (block.color === 'Green') { animationAsset = LK.getAsset('Greenanimation1', { anchorX: 0.5, anchorY: 0.5 }); } else if (block.color === 'Blue') { animationAsset = LK.getAsset('Blueanimation1', { anchorX: 0.5, anchorY: 0.5 }); } else if (block.color === 'Indigo') { animationAsset = LK.getAsset('Purpleanimation1', { anchorX: 0.5, anchorY: 0.5 }); } else if (block.color === 'Violet') { animationAsset = LK.getAsset('Pinkanimation1', { anchorX: 0.5, anchorY: 0.5 }); } if (animationAsset) { // Position animation at block location animationAsset.x = block.x; animationAsset.y = block.y; game.addChild(animationAsset); // Animate the animation asset tween(animationAsset, { scaleX: 3, scaleY: 3, alpha: 0, rotation: Math.PI * 2 }, { duration: 800, easing: tween.easeOut, onFinish: function onFinish() { animationAsset.destroy(); } }); } // Add visual feedback with scale animation on player tween(playerCharacter, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { tween(playerCharacter, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeIn }); } }); // Flash effect on collected block tween(block, { alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 200, easing: tween.easeOut }); // Also fade out the line if (block.line) { tween(block.line, { alpha: 0 }, { duration: 200, easing: tween.easeOut }); } // Play specific sound based on block color with smooth volume fade var sound = null; if (block.color === 'Red') { sound = LK.getSound('redsound1'); } else if (block.color === 'Orange') { sound = LK.getSound('orangesound1'); } else if (block.color === 'Yellow') { sound = LK.getSound('yellowsound1'); } else if (block.color === 'Green') { sound = LK.getSound('greensound1'); } else if (block.color === 'Blue') { sound = LK.getSound('bluesound1'); } else if (block.color === 'Indigo') { sound = LK.getSound('purplesound1'); } else if (block.color === 'Violet') { sound = LK.getSound('pinksound1'); } if (sound) { // Set initial volume to 0 for fade-in effect sound.volume = 0; sound.play(); // Tween volume from 0 to 1 over 200ms for smooth fade-in tween(sound, { volume: 1 }, { duration: 200, easing: tween.easeOut }); } block.destroy(); terrainBlocks.splice(i, 1); } block.lastY = block.y; } };
===================================================================
--- original.js
+++ change.js
@@ -38,19 +38,19 @@
// Create thin vertical line shape
var lineGraphics = LK.getAsset('line' + self.color, {
width: 4,
height: 3000,
- // Very tall to reach bottom
+ // Very tall to reach top
color: lineColor,
shape: 'box',
anchorX: 0.5,
- anchorY: 0
+ anchorY: 1
});
self.line.addChild(lineGraphics);
self.addChild(self.line);
self.update = function () {
self.y += self.speed;
- // Keep line positioned at block center extending downward
+ // Keep line positioned at block center extending upward
if (self.line) {
self.line.x = 0;
self.line.y = 0;
}