User prompt
Make shadows more obvious
User prompt
Put shadows under the containers βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Implement that in my game
User prompt
Use LK.setscore and LK.getscore
Code edit (1 edits merged)
Please save this source code
User prompt
Display high score in game over screen βͺπ‘ Consider importing and using the following plugins: @upit/storage.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Pause to play gameover sound before showing gameover screen
User prompt
Play gameover sound at game over
User prompt
Alternate between three different level up sounds
User prompt
Replace rotating slap sounds with random selection
User prompt
Alternate between 3 slap sounds
Code edit (4 edits merged)
Please save this source code
User prompt
Use impact for tariff font
User prompt
If player tap or click doesnβt touch a container, reset combo counter
Code edit (2 edits merged)
Please save this source code
User prompt
Change score counter to money counter
Code edit (1 edits merged)
Please save this source code
User prompt
Extend the length of the ship as more containers are added
User prompt
Make Trump hair bounce when advancing to the next level βͺπ‘ Consider importing and using the following plugins: @upit/tween.v1
User prompt
Donβt create a new speech bubble if the last one is still visible
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { highScore: 0, lastScore: 0 }); /**** * Classes ****/ var ShippingContainer = Container.expand(function (type) { var self = Container.call(this); // Set container type and properties self.type = type || 'container'; self.targetted = false; self.speed = 3 + Math.random() * 2; self.value = 10; // Adjust value based on container type if (self.type === 'foodContainer') { self.value = 15; } else if (self.type === 'paperContainer') { self.value = 20; } else if (self.type === 'diaperContainer') { self.value = 25; } else if (self.type === 'carPartsContainer') { self.value = 30; } // Get and automatically addChild appropriate asset with anchor set var containerGraphics = self.attachAsset(self.type, { anchorX: 0.5, anchorY: 0.5 }); // Create shadow effect beneath container self.shadow = new Container(); var shadowAsset = LK.getAsset(self.type, { anchorX: 0.5, anchorY: 0.5, tint: 0x000000, alpha: 0.3, scaleX: 0.95, scaleY: 0.95 }); self.shadow.addChild(shadowAsset); self.shadow.y = 15; // Position shadow below container self.addChildAt(self.shadow, 0); // Add shadow behind container // Label removed as requested // Tariff stamp that appears when tapped self.tariffStamp = self.attachAsset('tariffStamp', { anchorX: 0.5, anchorY: 0.5, alpha: 0 }); // Add text to stamp self.stampText = new Text2('TARIFF', { size: 40, fill: 0xFFFFFF, font: "Impact, Charcoal, sans-serif" }); self.stampText.anchor.set(0.5, 0.5); self.tariffStamp.addChild(self.stampText); // Update method called automatically each frame self.update = function () { // This method is now empty as container movement is controlled by the ship // Container position is relative to ship and doesn't need its own movement }; // Apply tariff to container self.applyTariff = function () { if (self.targetted) { return false; } self.targetted = true; // Show tariff stamp with animation self.tariffStamp.alpha = 1; self.tariffStamp.rotation = -0.3; tween(self.tariffStamp, { rotation: 0 }, { duration: 300, easing: tween.easeOut }); // Animate shadow when tariff is applied tween(self.shadow, { scaleX: 1.05, scaleY: 1.05, alpha: 0.5 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(self.shadow, { scaleX: 0.95, scaleY: 0.95, alpha: 0.3 }, { duration: 300, easing: tween.easeOut }); } }); // Play one of 3 slap sounds randomly var slapSounds = ['slap', 'slap2', 'slap3']; // Get a random sound from the array var randomIndex = Math.floor(Math.random() * slapSounds.length); var soundToPlay = slapSounds[randomIndex]; // Play the randomly selected sound LK.getSound(soundToPlay).play(); return true; }; // Tap/click handler self.down = function (x, y, obj) { // Add temporary shadow effect on press if (!self.targetted) { tween(self.shadow, { scaleX: 1.1, scaleY: 1.1, alpha: 0.6 }, { duration: 100, easing: tween.easeOut }); } // Call the global applyTariffToContainer function passing this container applyTariffToContainer(self); }; return self; }); var ShippingShip = Container.expand(function () { var self = Container.call(this); // Get and automatically addChild ship asset with anchor set var shipGraphics = self.attachAsset('ship', { anchorX: 0.5, anchorY: 0.5 }); // Store reference to ship graphics for resizing self.shipGraphics = shipGraphics; // Add containers to the ship self.containers = []; // Create containers for the ship self.createContainers = function (level) { // Clear existing containers for (var i = 0; i < self.containers.length; i++) { if (self.containers[i]) { self.removeChild(self.containers[i]); } } self.containers = []; // Determine how many containers to create based on level var containerCount = Math.min(Math.floor(2 + level / 2), 5); // Randomly decide which container types to use var containerTypes = ['foodContainer', 'paperContainer', 'diaperContainer', 'carPartsContainer']; // Create and position containers for (var i = 0; i < containerCount; i++) { var randomType = containerTypes[Math.floor(Math.random() * containerTypes.length)]; var container = new ShippingContainer(randomType); // Set fixed positions relative to the ship // Adjust X position based on total containers to center them on the extended ship var totalWidth = containerCount * 220; var startX = -totalWidth / 2 + 100; container.x = startX + i * 220; container.y = 0; self.addChild(container); self.containers.push(container); } // Adjust ship length based on container count var baseLength = 1.0; // Base scale factor var lengthPerContainer = 0.26; // Additional length per container var newLength = baseLength + (containerCount - 1) * lengthPerContainer; // Only adjust x-scale to change length, not height self.shipGraphics.scaleX = newLength; }; return self; }); var TrumpCharacter = Container.expand(function () { var self = Container.call(this); // Create Trump's face using shapes var face = self.attachAsset('trumpFace', { anchorX: 0.5, anchorY: 0.5, y: -150 }); self.hair = self.attachAsset('trumpHair', { anchorX: 0.5, anchorY: 0.5, y: -200 }); // Add speech bubble for occasional quotes self.speechBubble = new Container(); var bubbleText = new Text2('America First!', { size: 80, fill: 0x000000, font: "'Comic Sans MS', 'Comic Sans', cursive" }); bubbleText.anchor.set(0, 0.5); self.speechBubble.addChild(bubbleText); self.speechBubble.x = 140; self.speechBubble.y = -80; self.speechBubble.alpha = 0; self.addChild(self.speechBubble); // Method to show a random Trump quote self.showRandomQuote = function () { // Don't show a new quote if speech bubble is still visible if (self.speechBubble.alpha > 0) { return; } var quotes = ["America First!", "Beautiful Tariffs!", "Huge Tariffs!", "The Best Tariffs!", "China!", "Russia!", "Tremendous!", "Huge Profits!"]; bubbleText.setText(quotes[Math.floor(Math.random() * quotes.length)]); // Show speech bubble with animation tween(self.speechBubble, { alpha: 1 }, { duration: 300, easing: tween.easeOut }); // Hide speech bubble after delay LK.setTimeout(function () { tween(self.speechBubble, { alpha: 0 }, { duration: 300, easing: tween.easeIn }); }, 2000); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Game variables var score = 0; var level = 1; var combo = 0; var maxCombo = 0; var missedContainers = 0; var levelContainerCount = 0; var containersToNextLevel = 10; var isGameOver = false; var currentShip = null; var nextShipTimer = null; var ships = []; var trump = null; // Create UI elements var scoreTxt = new Text2('$0', { size: 60, fill: 0x00FF00 }); scoreTxt.anchor.set(0, 0); LK.gui.topRight.addChild(scoreTxt); scoreTxt.x = -300; scoreTxt.y = 20; var levelTxt = new Text2('Level: 1', { size: 60, fill: 0xFFFFFF }); levelTxt.anchor.set(0, 0); LK.gui.top.addChild(levelTxt); levelTxt.x = -50; levelTxt.y = 20; var comboTxt = new Text2('Combo: 0', { size: 40, fill: 0xFFFF00 }); comboTxt.anchor.set(0, 0); comboTxt.alpha = 0; LK.gui.topRight.addChild(comboTxt); comboTxt.x = -250; comboTxt.y = 90; // Initialize game function initGame() { // Reset game variables score = 0; LK.setScore(0); // Initialize score in LK system level = 1; combo = 0; maxCombo = 0; missedContainers = 0; levelContainerCount = 0; containersToNextLevel = 10; isGameOver = false; ships = []; currentShip = null; if (nextShipTimer) { LK.clearTimeout(nextShipTimer); } nextShipTimer = null; // Update UI scoreTxt.setText('$0'); levelTxt.setText('Level: 1'); comboTxt.setText('Combo: 0'); comboTxt.alpha = 0; // Create Trump character if (!trump) { trump = new TrumpCharacter(); trump.x = 300; trump.y = 400; game.addChild(trump); } // Start the game by spawning the first ship spawnNewShip(); // Play background music LK.playMusic('gameMusic'); } // Spawn a new shipping ship function spawnNewShip() { // Check if we already have 4 ships if (ships.length >= 4) { return; } // Create a new ship currentShip = new ShippingShip(); currentShip.x = 2048 + 600; // Start off-screen to the right // Assign different y coordinates for each ship // Define possible y positions var possibleYPositions = [700, 1000, 1700, 2400]; // Different y positions // Filter out positions that are already occupied by existing ships var availablePositions = possibleYPositions.filter(function (position) { // Check if any existing ship is at this y position for (var i = 0; i < ships.length; i++) { if (Math.abs(ships[i].y - position) < 10) { // Using a small threshold to account for floating point differences return false; // Position is occupied } } return true; // Position is available }); // If all positions are occupied, use the original list (should rarely happen since we limit to 4 ships) if (availablePositions.length === 0) { availablePositions = possibleYPositions; } // Choose a random position from the available options var randomIndex = Math.floor(Math.random() * availablePositions.length); var yPosition = availablePositions[randomIndex]; currentShip.y = yPosition; // Create containers for the ship based on current level currentShip.createContainers(level); // Add ship to game and tracking array game.addChild(currentShip); ships.push(currentShip); } // Apply tariff to a container when tapped function applyTariffToContainer(container) { if (!isGameOver && container && !container.targetted) { if (container.applyTariff()) { // Increase score based on container value and combo var pointsGained = container.value * (1 + combo * 0.1); score += Math.floor(pointsGained); // Update LK score system LK.setScore(score); // Update score text to show money scoreTxt.setText('$' + score); // Increase combo combo++; if (combo > maxCombo) { maxCombo = combo; } // Show combo text if combo is greater than 1 if (combo > 1) { comboTxt.setText('Combo: ' + combo + 'x'); comboTxt.alpha = 1; // Animate combo text tween(comboTxt, { size: 100 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(comboTxt, { size: 60 }, { duration: 200, easing: tween.easeIn }); } }); } // Track containers for level progression levelContainerCount++; // Check if we should level up if (levelContainerCount >= containersToNextLevel) { levelUp(); } // Occasionally make Trump say something if (Math.random() < 0.2) { trump.showRandomQuote(); } } } } // Level up function function levelUp() { level++; levelContainerCount = 0; containersToNextLevel = 10 + level * 2; // Save current level text for animation var levelValue = level; // Flash level text to indicate level up tween(levelTxt, { size: 100 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { // Update level text after scaling up levelTxt.setText('Level: ' + levelValue); tween(levelTxt, { size: 60 }, { duration: 300, easing: tween.easeIn }); } }); // Play one of the level up sounds randomly var levelUpSounds = ['levelUp', 'LevelUp2', 'LevelUp3']; var randomIndex = Math.floor(Math.random() * levelUpSounds.length); var soundToPlay = levelUpSounds[randomIndex]; LK.getSound(soundToPlay).play(); // Make Trump's hair bounce if (trump && trump.hair) { // Starting position var originalY = trump.hair.y; // Bounce up tween(trump.hair, { y: originalY - 50, scaleY: 1.2 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { // Bounce down tween(trump.hair, { y: originalY, scaleY: 1 }, { duration: 400, easing: tween.bounceOut }); } }); } // Make Trump say something about the level up trump.showRandomQuote(); } // Game over function function endGame() { if (!isGameOver) { isGameOver = true; // Save high score if current score is higher if (score > storage.highScore) { storage.highScore = score; } // Save last score storage.lastScore = score; // Set the score using LK.setScore before showing game over LK.setScore(score); // Play game over sound and wait for it to finish before showing game over screen LK.getSound('Gameover').play(); // Delay showing game over screen slightly to allow sound to play LK.setTimeout(function () { // Show game over screen with high score LK.showGameOver(); }, 1000); // Short delay for sound to start playing } } // Check if all containers on a ship have tariffs function checkShipCompleted(ship) { if (!ship) { return false; } var allTariffed = true; for (var i = 0; i < ship.containers.length; i++) { if (!ship.containers[i].targetted) { allTariffed = false; break; } } return allTariffed; } // Game update function called every frame game.update = function () { // Skip if game is over if (isGameOver) { return; } // Update all ships for (var i = ships.length - 1; i >= 0; i--) { var ship = ships[i]; // Check if ship is completely off screen if (ship.x < -1000) { // Count missed containers for (var j = 0; j < ship.containers.length; j++) { if (!ship.containers[j].targetted) { missedContainers++; // Reset combo when containers are missed combo = 0; comboTxt.setText('Combo: 0'); comboTxt.alpha = 0; // Play miss sound LK.getSound('miss').play(); } } // Remove ship game.removeChild(ship); ships.splice(i, 1); // Check if game over (missed too many containers) if (missedContainers >= 10) { endGame(); return; } // Schedule next ship if we have fewer than 4 if (ship === currentShip) { currentShip = null; // Clear any existing timer if (nextShipTimer) { LK.clearTimeout(nextShipTimer); } nextShipTimer = LK.setTimeout(spawnNewShip, 200); // Reduced from 400ms to 200ms for even faster respawning } } // If ship is off-screen to the right, move it into view else if (ship.x > 2048) { ship.x -= 10; } // Normal ship movement else { ship.x -= 5 + level; // Check if ship is completed and speed it up if (checkShipCompleted(ship)) { ship.x -= 10; } } } // Spawn new ships until we have up to 4 ships if (ships.length < 4) { if (!nextShipTimer) { nextShipTimer = LK.setTimeout(spawnNewShip, 150); // Reduced from 300ms to 150ms for more frequent spawning } // More frequently spawn a ship immediately if we have fewer than 2 ships on screen if (ships.length < 3 && LK.ticks % 30 === 0) { // Check twice as often spawnNewShip(); } } }; // Initialize the game initGame();
===================================================================
--- original.js
+++ change.js
@@ -31,8 +31,21 @@
var containerGraphics = self.attachAsset(self.type, {
anchorX: 0.5,
anchorY: 0.5
});
+ // Create shadow effect beneath container
+ self.shadow = new Container();
+ var shadowAsset = LK.getAsset(self.type, {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ tint: 0x000000,
+ alpha: 0.3,
+ scaleX: 0.95,
+ scaleY: 0.95
+ });
+ self.shadow.addChild(shadowAsset);
+ self.shadow.y = 15; // Position shadow below container
+ self.addChildAt(self.shadow, 0); // Add shadow behind container
// Label removed as requested
// Tariff stamp that appears when tapped
self.tariffStamp = self.attachAsset('tariffStamp', {
anchorX: 0.5,
@@ -66,8 +79,27 @@
}, {
duration: 300,
easing: tween.easeOut
});
+ // Animate shadow when tariff is applied
+ tween(self.shadow, {
+ scaleX: 1.05,
+ scaleY: 1.05,
+ alpha: 0.5
+ }, {
+ duration: 150,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self.shadow, {
+ scaleX: 0.95,
+ scaleY: 0.95,
+ alpha: 0.3
+ }, {
+ duration: 300,
+ easing: tween.easeOut
+ });
+ }
+ });
// Play one of 3 slap sounds randomly
var slapSounds = ['slap', 'slap2', 'slap3'];
// Get a random sound from the array
var randomIndex = Math.floor(Math.random() * slapSounds.length);
@@ -77,8 +109,19 @@
return true;
};
// Tap/click handler
self.down = function (x, y, obj) {
+ // Add temporary shadow effect on press
+ if (!self.targetted) {
+ tween(self.shadow, {
+ scaleX: 1.1,
+ scaleY: 1.1,
+ alpha: 0.6
+ }, {
+ duration: 100,
+ easing: tween.easeOut
+ });
+ }
// Call the global applyTariffToContainer function passing this container
applyTariffToContainer(self);
};
return self;
Long Cargo ship top down. In-Game asset. 2d. High contrast. No shadows
Trump face oval no hair. In-Game asset. 2d. High contrast. No shadows
Box of toilet paper top down. In-Game asset. 2d. High contrast. No shadows
Diaper container top down. In-Game asset. 2d. High contrast. No shadows
Bag of rice top down. In-Game asset. 2d. High contrast. No shadows
Car parts in crate top down. In-Game asset. 2d. High contrast. No shadows