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 }); // 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: 30, fill: 0xFFFFFF }); 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 }); // Play slap sound LK.getSound('slap').play(); return true; }; // Tap/click handler self.down = function (x, y, obj) { // 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 }); // 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 container.x = i * 220 - 220; container.y = 0; self.addChild(container); self.containers.push(container); } }; 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 }); var 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!", "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('Score: 0', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0, 0); LK.gui.topRight.addChild(scoreTxt); scoreTxt.x = -350; 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; 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('Score: 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 score text scoreTxt.setText('Score: ' + 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 level up sound LK.getSound('levelUp').play(); // 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; // Show game over screen LK.showGameOver(); } } // 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 < 2 && LK.ticks % 30 === 0) { // Check twice as often spawnNewShip(); } } }; // Initialize the game initGame();
/****
* 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
});
// 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: 30,
fill: 0xFFFFFF
});
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
});
// Play slap sound
LK.getSound('slap').play();
return true;
};
// Tap/click handler
self.down = function (x, y, obj) {
// 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
});
// 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
container.x = i * 220 - 220;
container.y = 0;
self.addChild(container);
self.containers.push(container);
}
};
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
});
var 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!", "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('Score: 0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreTxt);
scoreTxt.x = -350;
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;
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('Score: 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 score text
scoreTxt.setText('Score: ' + 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 level up sound
LK.getSound('levelUp').play();
// 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;
// Show game over screen
LK.showGameOver();
}
}
// 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 < 2 && LK.ticks % 30 === 0) {
// Check twice as often
spawnNewShip();
}
}
};
// Initialize the game
initGame();
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