User prompt
Place spinning earth asset a little more left and down ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Increase size of spinning earth asset ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Increase size of spinning earth asset ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Put a spinning earth asset on the top right corner of the instructions page ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Do not start spawning asteroids until a spaceship is placed
User prompt
Increase game instructions font size from 50 to 60
User prompt
Increase font size of game instructions
User prompt
Ensure game instructions are not off-screen.
User prompt
Display instruction text before got it is clicked
User prompt
Remove the game assets until “Got it!” Is clicked. This will start the game.
User prompt
Before the game starts, have a page with the following text: “ How to play: Goal: - protect the Earth from asteroid collisions - you will be given a spaceship that shoots lasers - you will use these lasers to destroy asteroids - if the Earth gets hit with 4 asteroids, you lose - If you have multiple spaceships, they will all fire where you choose Points: - every asteroid you destroy will earn you five points - every 50 points, you will recieve a new spaceship you can put in the solar system - if you reach 350 points, that interval will increase to every 100 points Asteroids: - asteroids are your enimies - they can be destroyed with one laser hit - they will come from random directions, so be aware of all sides of the screen Controls: - select a spaceship to move it, select it again to start firing - click any point on the sreen to fire lasers in that direction - if you have multiple spaceships, they will all fire where you choose Got it!”
User prompt
Remove the manual dis-selection of a defensive ship when it is on the solar system board.
User prompt
reduce the number of objects in orbit line to increase performance
User prompt
Increase the spawn frequency linearly rather than exponentially.
User prompt
Reduce lag if possible
User prompt
As time goes on after a score of 50, give a significant increase to the frequency of asteroid spawns
User prompt
As time goes on, give a significant increase to the frequency of asteroid spawns
User prompt
Dim the orbit line a bit
User prompt
Make orbit line a single connected line rather than a series of objects
User prompt
Reduce lag if possible
User prompt
Increase orbit line alpha slightly mote
User prompt
Make it so the player is able to see the orbit line
User prompt
Make the orbit line a circular line around the sun displaying the orbit of the planets ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Add faint white lines showing planet’s orbit ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
After a score of 350 points, only spawn in a new ship every 100 points
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Asteroid = Container.expand(function () { var self = Container.call(this); var asteroidGraphics = self.attachAsset('asteroid', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.targetPlanet = null; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; asteroidGraphics.rotation += 0.05; }; return self; }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; }; return self; }); var Laser = Container.expand(function () { var self = Container.call(this); var laserGraphics = self.attachAsset('bullet', { anchorX: 0.5, anchorY: 0.5 }); laserGraphics.tint = 0x00ff00; // Green laser color laserGraphics.scaleX = 0.5; // Make laser thinner laserGraphics.scaleY = 2; // Make laser longer self.velocityX = 0; self.velocityY = 0; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; }; return self; }); var OrbitLine = Container.expand(function (radius) { var self = Container.call(this); self.orbitRadius = radius; // Create a single connected circular line using small line segments var numSegments = Math.max(16, Math.floor(radius * 0.1)); // Fewer segments for better performance var twoPi = Math.PI * 2; // Cache the calculation for (var i = 0; i < numSegments; i++) { var angle1 = i / numSegments * twoPi; var angle2 = (i + 1) / numSegments * twoPi; var x1 = Math.cos(angle1) * radius; var y1 = Math.sin(angle1) * radius; var x2 = Math.cos(angle2) * radius; var y2 = Math.sin(angle2) * radius; // Calculate segment length and angle var segmentLength = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); var segmentAngle = Math.atan2(y2 - y1, x2 - x1); // Create line segment var lineSegment = self.attachAsset('orbitLine', { anchorX: 0, anchorY: 0.5, alpha: 0.4, scaleX: segmentLength / 2, // Scale to match segment length scaleY: 1 }); // Position and rotate the segment lineSegment.x = x1; lineSegment.y = y1; lineSegment.rotation = segmentAngle; } return self; }); var Planet = Container.expand(function (size, color, orbitRadius, orbitSpeed) { var self = Container.call(this); self.orbitRadius = orbitRadius; self.orbitSpeed = orbitSpeed; self.angle = Math.random() * Math.PI * 2; var assetName = 'mercury'; if (color === 0x4169e1) assetName = 'earth';else if (color === 0xff4500) assetName = 'mars';else if (color === 0xffc649) assetName = 'venus';else if (color === 0xd2691e) assetName = 'jupiter';else if (color === 0xffd700) assetName = 'saturn';else if (color === 0x40e0d0) assetName = 'uranus';else if (color === 0x4169e1 && size === 85) assetName = 'neptune'; var planetGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.angle += self.orbitSpeed; var cosAngle = Math.cos(self.angle); var sinAngle = Math.sin(self.angle); self.x = sunX + cosAngle * self.orbitRadius; self.y = sunY + sinAngle * self.orbitRadius; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000011 }); /**** * Game Code ****/ // Show instructions before game starts var instructionText = new Text2(" How to play:\n\nGoal:\n- protect the Earth from asteroid collisions\n- you will be given a spaceship that shoots lasers\n- you will use these lasers to destroy asteroids\n- if the Earth gets hit with 4 asteroids, you lose\n- If you have multiple spaceships, they will all fire where you choose\n\nPoints:\n- every asteroid you destroy will earn you five points\n- every 50 points, you will recieve a new spaceship you can put in the solar system\n- if you reach 350 points, that interval will increase to every 100 points\n\nAsteroids:\n- asteroids are your enimies\n- they can be destroyed with one laser hit\n- they will come from random directions, so be aware of all sides of the screen\n\nControls:\n- select a spaceship to move it, select it again to start firing\n- click any point on the sreen to fire lasers in that direction\n- if you have multiple spaceships, they will all fire where you choose\n\n\nGot it!", { size: 60, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: 1600 }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 2048 / 2; instructionText.y = 2732 / 2; game.addChild(instructionText); // Add click handler to dismiss instructions var instructionsVisible = true; game.down = function (x, y, obj) { if (instructionsVisible) { // Hide instructions and start the game instructionText.destroy(); instructionsVisible = false; // Initialize all game assets now initializeGameAssets(); // Re-define the game.down handler for normal gameplay return; } // If a defensive ship is selected and placed, shoot laser at clicked position if (selectedShipIndex >= 0 && defensiveShips[selectedShipIndex].placed && defensiveShips[selectedShipIndex].selected) { // Make all placed ships fire lasers at the selected point for (var k = 0; k < defensiveShips.length; k++) { var ship = defensiveShips[k]; // Only fire from ships that are placed if (!ship.placed) { continue; } var laser = new Laser(); laser.x = ship.x; laser.y = ship.y; // Calculate direction from this ship to clicked position var dx = x - laser.x; var dy = y - laser.y; var distance = Math.sqrt(dx * dx + dy * dy); // Calculate rotation angle to face the target point var targetRotation = Math.atan2(dy, dx) + Math.PI / 2; // Add PI/2 since ship top should face target // Rotate the ship to face the target tween(ship, { rotation: targetRotation }, { duration: 200, easing: tween.easeOut }); var speed = 8; if (distance > 0) { laser.velocityX = dx / distance * speed; laser.velocityY = dy / distance * speed; } lasers.push(laser); game.addChild(laser); } } }; // Define variables that will be initialized after instructions var sunX, sunY, sun, planets, mercury, venus, earth, mars, jupiter, saturn, uranus, neptune; var orbitLines, bullets, lasers, asteroids, asteroidSpawnTimer, lives; var scoreTxt, livesTxt, defensiveShips, selectedShipIndex, isDragging; var totalShips, availableShips, lastScoreCheck; // Function to initialize game assets function initializeGameAssets() { sunX = 2048 / 2; sunY = 2732 / 2; sun = game.addChild(LK.getAsset('sun', { anchorX: 0.5, anchorY: 0.5, x: sunX, y: sunY })); planets = []; mercury = new Planet(50, 0x8c7853, 150, 0.015); venus = new Planet(70, 0xffc649, 200, 0.012); earth = new Planet(80, 0x4169e1, 300, 0.008); mars = new Planet(60, 0xff4500, 450, 0.005); jupiter = new Planet(120, 0xd2691e, 600, 0.003); saturn = new Planet(100, 0xffd700, 750, 0.002); uranus = new Planet(90, 0x40e0d0, 900, 0.0015); neptune = new Planet(85, 0x4169e1, 1050, 0.001); planets.push(mercury); planets.push(venus); planets.push(earth); planets.push(mars); planets.push(jupiter); planets.push(saturn); planets.push(uranus); planets.push(neptune); // Create orbit lines for each planet orbitLines = []; var planetOrbits = [150, 200, 300, 450, 600, 750, 900, 1050]; // Mercury to Neptune orbit radii for (var i = 0; i < planetOrbits.length; i++) { var orbitLine = new OrbitLine(planetOrbits[i]); orbitLine.x = sunX; orbitLine.y = sunY; orbitLines.push(orbitLine); game.addChild(orbitLine); } for (var i = 0; i < planets.length; i++) { game.addChild(planets[i]); } bullets = []; lasers = []; asteroids = []; asteroidSpawnTimer = 0; lives = 4; scoreTxt = new Text2('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); scoreTxt.x = 0; LK.gui.top.addChild(scoreTxt); livesTxt = new Text2('Lives: 4', { size: 60, fill: 0xFFFFFF }); livesTxt.anchor.set(0.5, 0); livesTxt.x = 0; livesTxt.y = 70; LK.gui.top.addChild(livesTxt); defensiveShips = []; selectedShipIndex = -1; isDragging = false; totalShips = 4; // Maximum number of ships availableShips = 1; // Start with 1 ship available lastScoreCheck = 0; // Track score for adding new ships // Create 4 defensive ships but only show the available ones for (var i = 0; i < totalShips; i++) { var defensiveShip = LK.getAsset('defensiveShip', { anchorX: 0.5, anchorY: 0.5, x: -80, // Position all ships in the same spot in top right corner y: 80 }); defensiveShip.shipIndex = i; defensiveShip.placed = false; defensiveShip.selected = false; // Only show ships that are available defensiveShip.visible = i < availableShips; defensiveShips.push(defensiveShip); LK.gui.topRight.addChild(defensiveShip); } // Add down handler to each defensive ship for (var i = 0; i < defensiveShips.length; i++) { defensiveShips[i].down = function (x, y, obj) { var ship = this; var shipIndex = ship.shipIndex; // Only allow interaction with visible/available ships if (!ship.visible) { return; } if (ship.placed) { // Ship has been placed, allow selection for shooting // Deselect all other ships for (var j = 0; j < defensiveShips.length; j++) { if (j !== shipIndex && defensiveShips[j].selected) { defensiveShips[j].selected = false; tween(defensiveShips[j], { alpha: 1.0 }, { duration: 200 }); } } if (!ship.selected) { ship.selected = true; selectedShipIndex = shipIndex; tween(ship, { alpha: 0.7 }, { duration: 200 }); } // Removed else block to prevent manual dis-selection of placed ships return; } // Ship not placed yet - immediately start dragging // Deselect all other ships for (var j = 0; j < defensiveShips.length; j++) { if (j !== shipIndex && defensiveShips[j].selected) { defensiveShips[j].selected = false; tween(defensiveShips[j], { alpha: 1.0 }, { duration: 200 }); } } // Start dragging immediately isDragging = true; selectedShipIndex = shipIndex; ship.selected = true; // Store original scale before moving var originalScaleX = ship.scaleX; var originalScaleY = ship.scaleY; // No need to shift ships since they're all in the same position // Move defensive ship to game area for dragging var gamePos = game.toLocal(LK.gui.topRight.toGlobal({ x: ship.x, y: ship.y })); LK.gui.topRight.removeChild(ship); game.addChild(ship); ship.x = gamePos.x; ship.y = gamePos.y; // Restore original scale after moving to game area ship.scaleX = originalScaleX; ship.scaleY = originalScaleY; }; } } game.move = function (x, y, obj) { // Move ship to cursor position during dragging if (isDragging && selectedShipIndex >= 0) { var ship = defensiveShips[selectedShipIndex]; ship.x = x; ship.y = y; } }; game.up = function (x, y, obj) { if (isDragging && selectedShipIndex >= 0) { isDragging = false; // Defensive ship is now placed in the solar system var placedShip = defensiveShips[selectedShipIndex]; // Check if ship is off-screen and needs to be moved back to available ships area var shipHalfWidth = 40; // Half width of defensive ship (80/2) var shipHalfHeight = 55; // Half height of defensive ship (110/2) var isOffScreen = placedShip.x - shipHalfWidth < 0 || placedShip.x + shipHalfWidth > 2048 || placedShip.y - shipHalfHeight < 0 || placedShip.y + shipHalfHeight > 2732; if (isOffScreen) { // Move ship back to available ships area game.removeChild(placedShip); LK.gui.topRight.addChild(placedShip); // Place ship back at the single spawn position in top right corner placedShip.x = -80; placedShip.y = 80; placedShip.placed = false; } else { placedShip.placed = true; } placedShip.selected = false; selectedShipIndex = -1; tween(placedShip, { alpha: 1.0 }, { duration: 200 }); } }; game.update = function () { // Don't update game while instructions are visible if (instructionsVisible) { return; } // Check if we should add a new ship (every 50 points up to 350, then every 100 points) var currentScore = LK.getScore(); var newAvailableShips; if (currentScore <= 350) { // Every 50 points up to 350 newAvailableShips = Math.min(totalShips, 1 + Math.floor(currentScore / 50)); } else { // After 350: base ships from first 350 points (1 + 7 = 8) plus additional ships every 100 points var baseShips = 1 + Math.floor(350 / 50); // Ships earned up to 350 points var additionalShips = Math.floor((currentScore - 350) / 100); // Additional ships after 350 newAvailableShips = Math.min(totalShips, baseShips + additionalShips); } if (newAvailableShips > availableShips) { availableShips = newAvailableShips; // Make the newly available ship visible for (var k = 0; k < availableShips; k++) { if (!defensiveShips[k].visible) { defensiveShips[k].visible = true; } } } for (var i = 0; i < planets.length; i++) { planets[i].update(); } asteroidSpawnTimer++; // Calculate spawn frequency based on score - significant increase after score 50 var baseSpawnDelay = 120; var minSpawnDelay = 8; // Reduced minimum for more intense gameplay var cachedScore = LK.getScore(); // Cache score to avoid multiple calls var currentSpawnDelay; if (cachedScore < 50) { // Normal progression before score 50 var scoreSpeedUp = Math.floor(cachedScore / 100); currentSpawnDelay = Math.max(60, baseSpawnDelay - scoreSpeedUp * 10); } else { // Linear increase after score 50 var excessScore = cachedScore - 50; var linearSpeedUp = Math.floor(excessScore / 10); // Linear reduction every 10 points currentSpawnDelay = Math.max(minSpawnDelay, 60 - linearSpeedUp * 2); } if (asteroidSpawnTimer > currentSpawnDelay) { var asteroid = new Asteroid(); var spawnAngle = Math.random() * Math.PI * 2; var spawnDistance = 1500; var cosSpawn = Math.cos(spawnAngle); var sinSpawn = Math.sin(spawnAngle); asteroid.x = sunX + cosSpawn * spawnDistance; asteroid.y = sunY + sinSpawn * spawnDistance; // Set initial velocity toward Earth's current position var dx = earth.x - asteroid.x; var dy = earth.y - asteroid.y; var distanceSquared = dx * dx + dy * dy; if (distanceSquared > 0) { var distance = Math.sqrt(distanceSquared); var speed = 2 / distance; // Cache division asteroid.velocityX = dx * speed; asteroid.velocityY = dy * speed; } asteroids.push(asteroid); game.addChild(asteroid); asteroidSpawnTimer = 0; } for (var i = bullets.length - 1; i >= 0; i--) { var bullet = bullets[i]; if (bullet.x < -50 || bullet.x > 2098 || bullet.y < -50 || bullet.y > 2782) { bullet.destroy(); bullets.splice(i, 1); continue; } for (var j = asteroids.length - 1; j >= 0; j--) { if (bullet.intersects(asteroids[j])) { LK.setScore(LK.getScore() + 5); scoreTxt.setText('Score: ' + LK.getScore()); bullet.destroy(); bullets.splice(i, 1); asteroids[j].destroy(); asteroids.splice(j, 1); break; } } } // Update lasers for (var i = lasers.length - 1; i >= 0; i--) { var laser = lasers[i]; laser.update(); if (laser.x < -50 || laser.x > 2098 || laser.y < -50 || laser.y > 2782) { laser.destroy(); lasers.splice(i, 1); continue; } // Check laser collision with asteroids var laserHit = false; for (var j = asteroids.length - 1; j >= 0 && !laserHit; j--) { if (laser.intersects(asteroids[j])) { LK.setScore(LK.getScore() + 5); scoreTxt.setText('Score: ' + LK.getScore()); laser.destroy(); lasers.splice(i, 1); asteroids[j].destroy(); asteroids.splice(j, 1); laserHit = true; break; } } } for (var i = asteroids.length - 1; i >= 0; i--) { var asteroid = asteroids[i]; var asteroidHit = false; // Cache asteroid position relative to sun var dx = asteroid.x - sunX; var dy = asteroid.y - sunY; var sunDistanceSquared = dx * dx + dy * dy; // Check sun collision first (most common) if (sunDistanceSquared < 14400) { // 120 * 120 = 14400 asteroid.destroy(); asteroids.splice(i, 1); continue; } // Only check planet collisions if not destroyed by sun for (var j = 0; j < planets.length && !asteroidHit; j++) { if (asteroid.intersects(planets[j])) { if (planets[j] === earth) { LK.effects.flashScreen(0x440000, 1000); lives--; livesTxt.setText('Lives: ' + lives); if (lives <= 0) { LK.showGameOver(); return; } } asteroid.destroy(); asteroids.splice(i, 1); asteroidHit = true; break; } } } };
===================================================================
--- original.js
+++ change.js
@@ -117,9 +117,9 @@
* Game Code
****/
// Show instructions before game starts
var instructionText = new Text2(" How to play:\n\nGoal:\n- protect the Earth from asteroid collisions\n- you will be given a spaceship that shoots lasers\n- you will use these lasers to destroy asteroids\n- if the Earth gets hit with 4 asteroids, you lose\n- If you have multiple spaceships, they will all fire where you choose\n\nPoints:\n- every asteroid you destroy will earn you five points\n- every 50 points, you will recieve a new spaceship you can put in the solar system\n- if you reach 350 points, that interval will increase to every 100 points\n\nAsteroids:\n- asteroids are your enimies\n- they can be destroyed with one laser hit\n- they will come from random directions, so be aware of all sides of the screen\n\nControls:\n- select a spaceship to move it, select it again to start firing\n- click any point on the sreen to fire lasers in that direction\n- if you have multiple spaceships, they will all fire where you choose\n\n\nGot it!", {
- size: 50,
+ size: 60,
fill: 0xFFFFFF,
wordWrap: true,
wordWrapWidth: 1600
});