User prompt
make the P2 lines hit the second target and not the first one.
User prompt
add another target for p2 to shoot too.
User prompt
make the game to force you to play with 2 players.
User prompt
remove the text “PRESS START 0/1 CREDITS” on gameplay.
User prompt
when added credit. make sure it automatically takes you to the ready screen and not the gameplay.
User prompt
I ment to remove the tap mechanism to skip and change the tap mechanism to add another credit.
User prompt
remove the tap mechanism to on the ready screen you can add another credit when tapped.
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'creditsText.setText(coins + '/' + maxCoins + ' CREDITS');' Line Number: 101
User prompt
remove the hold mechanism and change that hold mechanism to hold to skip. and make sure that the credit is gone when used for player 1.
User prompt
on the ready screen. keep the “INSERT COIN 0/1 CREDITS” there.
User prompt
when there is only 1 player. there can only be 2 cannons. if there is 2 players. then 4 cannons should be there.
User prompt
remove the tap/hold mechanism when it’s on the game play so I can drag the target.
User prompt
why does when I tap To insert a coin. I automatically go into the gameplay? change it so I can hold to skip the countdown on the ready screen
User prompt
when there is 1 credit. P1 doesn’t press start. plus when added credit. Make it take you to the ready screen. and Instead of tapping to skip countdown. you have to hold again so when you tap. you insert another coin.
User prompt
why is there another 2 cannons on the top? they are supposed to be on the bottom next to the P1 cannons.
User prompt
the target isn’t movable. and when moving the target with the persons hand moving. the lines appear.
User prompt
Make the target movable. And while shooting. Lines come from the cannons to the target. and there is supposed to be 4 cannons. not 2. and make it so when you press start. the credit goes away and only 1 player is ready.
User prompt
why is there still 2 ships in a middle. they are supposed to be in each corner? (only on the bottom.)
User prompt
When gameplay starts. And when there is 2 players. There is 2 ships in each corner 1 red for P1 and on the other side and Blue for P2 which is also on each side. and those ships don’t move. and a target appears during gameplay. also in the ready screen where players join you can tap to skip the countdown.
User prompt
When On the Ready Screen. After the 15 countdown. There is 4 ships. Two for P1 and one for P2. Those Ships don’t move. And When there is only 1 player. There is only 2 ships. When on gameplay. A text will pop up saying “Shoot Enemy Ships” and after 2 seconds a text will pop up saying “Ready?” And After 1 Second it will say “Go!” And on the bottom. Two arrows will appear by the Word “Protect Cannons” and the gameplay starts.
User prompt
When you hold. A Ship icon Appears. Another Ship Icon Appears. But Faded. When Inserted a coin and Pressed Start. The Second Ship Will Appear but it’s not faded. And while that happens. A 15 Second Countdown appears. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the controls. On the title screen. Tap to insert a coin. Hold to Press Start.
User prompt
after the 2 The “INSERT COIN! 0/1 CREDITS” will appear of the top of the screen. The “0/1 CREDITS” will appear under the “INSERT COIN!”
User prompt
let’s make an animation for the 2. After 3 seconds. The 2 will come up and finish the title.
User prompt
move the 2 By the Invader Blits.
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Game state variables
// Red ship for P1
// Blue ship for P2
// Yellow target
var coins = 0;
var maxCoins = 1;
var gameStarted = false;
var insertCoinText;
var creditsText;
var pressStartText;
var holdStartTime = 0; // Only used for hold-to-skip in ready screen
var isHolding = false; // Only used for hold-to-skip in ready screen
var ship1;
var ship2;
var countdownText;
var countdownTimer;
var gameplayShips = [];
var target;
var cannons = [];
var cannonLines = [];
var isDraggingTarget = false;
var isShooting = false;
var isInReadyScreen = false;
// Create main title text "Invader Blits"
var titleText = new Text2('Invader Blits', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.x = 2048 / 2;
titleText.y = 2732 / 2 - 50;
game.addChild(titleText);
// Create the "2" text (initially hidden)
var numberText = new Text2('2', {
size: 120,
fill: 0xFFFFFF
});
numberText.anchor.set(0.5, 0.5);
numberText.x = 2048 / 2 + titleText.width / 2 + 20; // Position it after "Invader Blits"
numberText.y = 2732 / 2 - 50;
numberText.alpha = 0; // Start invisible
game.addChild(numberText);
// Position the "2" below the screen initially for slide-up animation
numberText.y = 2732 + 100; // Start below screen
numberText.alpha = 1; // Make it visible but positioned off-screen
// Show the "2" after 3 seconds with a slide-up animation
LK.setTimeout(function () {
tween(numberText, {
y: 2732 / 2 - 50 // Slide up to final position next to title
}, {
duration: 800,
easing: tween.easeOut
});
// After the "2" animation completes, show the INSERT COIN! text
LK.setTimeout(function () {
// Create "INSERT COIN!" text
insertCoinText = new Text2('INSERT COIN!', {
size: 60,
fill: 0xFFFF00 // Yellow color
});
insertCoinText.anchor.set(0.5, 0.5);
insertCoinText.x = 2048 / 2;
insertCoinText.y = 300; // Top of screen
game.addChild(insertCoinText);
// Create "0/1 CREDITS" text
creditsText = new Text2('0/1 CREDITS', {
size: 40,
fill: 0xFFFFFF // White color
});
creditsText.anchor.set(0.5, 0.5);
creditsText.x = 2048 / 2;
creditsText.y = 380; // Below INSERT COIN!
game.addChild(creditsText);
}, 800); // Wait for the "2" animation to complete
}, 3000);
// Function to update credits display
function updateCreditsDisplay() {
creditsText.setText(coins + '/' + maxCoins + ' CREDITS');
// Show "PRESS START" when we have coins
if (coins > 0 && !pressStartText) {
pressStartText = new Text2('PRESS START', {
size: 50,
fill: 0x00FF00 // Green color
});
pressStartText.anchor.set(0.5, 0.5);
pressStartText.x = 2048 / 2;
pressStartText.y = 450; // Below credits
game.addChild(pressStartText);
// Make it blink
tween(pressStartText, {
alpha: 0.3
}, {
duration: 500,
yoyo: true,
repeat: -1
});
}
// Handle target dragging
game.move = function (x, y, obj) {
if (isDraggingTarget && target) {
target.x = x;
target.y = y;
// Update lines to point at target while dragging
for (var i = 0; i < cannons.length; i++) {
var cannon = cannons[i];
var line = cannonLines[i];
// Calculate distance and angle to target
var dx = target.x - cannon.x;
var dy = target.y - cannon.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
// Update line position and rotation
line.x = cannon.x;
line.y = cannon.y;
line.rotation = angle;
line.scaleX = distance / 100; // Adjust line length
}
}
};
// Update down handler to include target dragging
var originalDown = game.down;
game.down = function (x, y, obj) {
// Call original down handler first
originalDown.call(this, x, y, obj);
// Check if clicking on target during gameplay
if (target && gameStarted) {
var dx = x - target.x;
var dy = y - target.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
// Within target radius
isDraggingTarget = true;
// Show lines when starting to drag
for (var i = 0; i < cannonLines.length; i++) {
cannonLines[i].alpha = 0.8;
}
}
}
};
// Update up handler to stop target dragging
var originalUp = game.up;
game.up = function (x, y, obj) {
// Call original up handler first
originalUp.call(this, x, y, obj);
if (isDraggingTarget) {
isDraggingTarget = false;
// Hide lines when stopping drag
for (var i = 0; i < cannonLines.length; i++) {
cannonLines[i].alpha = 0;
}
}
};
// Function to update cannon lines to point at target
function updateCannonLines() {
if (!target || !isShooting) return;
for (var i = 0; i < cannons.length; i++) {
var cannon = cannons[i];
var line = cannonLines[i];
// Calculate distance and angle to target
var dx = target.x - cannon.x;
var dy = target.y - cannon.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var angle = Math.atan2(dy, dx);
// Update line position and rotation
line.x = cannon.x;
line.y = cannon.y;
line.rotation = angle;
line.scaleX = distance / 100; // Adjust line length
}
}
// Add shooting functionality
game.update = function () {
// Lines are now controlled by dragging, not automatic shooting
};
}
// Touch down event for inserting coins and starting game
game.down = function (x, y, obj) {
if (gameStarted) {
// Allow target dragging at any time during gameplay
if (target) {
var dx = x - target.x;
var dy = y - target.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 60) {
isDraggingTarget = true;
// Show lines when starting to drag
for (var i = 0; i < cannonLines.length; i++) {
cannonLines[i].alpha = 0.8;
}
}
}
return;
}
// If in ready screen (countdown), tap inserts coin instead of skipping
if (isInReadyScreen) {
// Insert coin with tap during ready screen
if (coins < maxCoins) {
coins++;
updateCreditsDisplay();
}
// Do NOT go to ready screen automatically; require hold for PRESS START
return;
}
// Insert coin with tap
if (coins < maxCoins) {
coins++;
updateCreditsDisplay();
// Hide INSERT COIN text when max coins reached
if (coins >= maxCoins && insertCoinText) {
insertCoinText.alpha = 0.3; // Dim it
}
// Do NOT go to ready screen automatically; require hold for PRESS START
return;
}
// Start ready screen immediately when pressing start (no hold)
if (coins > 0 && !isInReadyScreen) {
startReadyScreen();
}
};
// Touch up event to stop holding
game.up = function (x, y, obj) {
if (gameStarted) {
// Only allow hold-to-skip during ready screen countdown
if (isInReadyScreen && countdownTimer && Date.now() - holdStartTime >= 1000) {
isHolding = false;
// Skip countdown
LK.clearInterval(countdownTimer);
countdownText.setText('GO!');
LK.setTimeout(function () {
if (countdownText) countdownText.alpha = 0;
isInReadyScreen = false;
// Show player ships after countdown
showPlayerShips();
// Start gameplay sequence
startGameplaySequence();
}, 500);
}
return;
}
isHolding = false;
// No hold-to-start for game; do nothing here except for hold-to-skip in ready screen
};
// Function to start ready screen
function startReadyScreen() {
gameStarted = true;
isInReadyScreen = true;
// Consume one credit when starting
coins--;
updateCreditsDisplay();
// Hide all title screen elements except creditsText (keep creditsText visible in ready screen)
if (titleText) titleText.alpha = 0;
if (numberText) numberText.alpha = 0;
if (insertCoinText) insertCoinText.alpha = 0;
if (creditsText) creditsText.alpha = 1; // Show creditsText during ready screen
if (pressStartText) pressStartText.alpha = 0;
// Make ship2 fully visible (unfade it) only if ship2 exists
if (ship2) {
tween(ship2, {
alpha: 1
}, {
duration: 500,
easing: tween.easeOut
});
}
// Show 15 second countdown
countdownText = new Text2('15', {
size: 80,
fill: 0xFF0000 // Red color
});
countdownText.anchor.set(0.5, 0.5);
countdownText.x = 2048 / 2;
countdownText.y = 400;
game.addChild(countdownText);
// Start countdown timer
var timeLeft = 15;
countdownTimer = LK.setInterval(function () {
timeLeft--;
if (timeLeft <= 0) {
LK.clearInterval(countdownTimer);
countdownText.setText('GO!');
LK.setTimeout(function () {
if (countdownText) countdownText.alpha = 0;
isInReadyScreen = false;
// Show player ships after countdown
showPlayerShips();
// Start gameplay sequence
startGameplaySequence();
}, 1000);
} else {
countdownText.setText(timeLeft.toString());
}
}, 1000);
// Game would start here - for now just clear screen
game.setBackgroundColor(0x000020); // Dark blue to show game started
}
// Function to show player ships on ready screen
function showPlayerShips() {
// Hide the hold-to-start ships
if (ship1) ship1.alpha = 0;
if (ship2) ship2.alpha = 0;
// Always show 1 player setup (since we consumed a credit)
var numPlayers = 1;
var shipPositions = [];
if (numPlayers === 1) {
// 2 ships for single player - bottom left and bottom right corners
shipPositions = [{
x: 100,
y: 2732 - 100
}, {
x: 2048 - 100,
y: 2732 - 100
}];
} else {
// 4 ships for 2 players (2 for P1 on left, 2 for P2 on right)
shipPositions = [{
x: 100,
y: 2732 - 100
},
// P1 ship 1 - bottom left
{
x: 100,
y: 2732 - 200
},
// P1 ship 2 - left side higher up
{
x: 2048 - 100,
y: 2732 - 100
},
// P2 ship 1 - bottom right
{
x: 2048 - 100,
y: 2732 - 200
} // P2 ship 2 - right side higher up
];
}
// Create ships
for (var i = 0; i < shipPositions.length; i++) {
var ship = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
x: shipPositions[i].x,
y: shipPositions[i].y,
scaleX: 0.6,
scaleY: 0.6
});
game.addChild(ship);
}
}
// Function to start the gameplay sequence
function startGameplaySequence() {
// Show "Shoot Enemy Ships" text
var shootText = new Text2('Shoot Enemy Ships', {
size: 80,
fill: 0xFFFF00 // Yellow
});
shootText.anchor.set(0.5, 0.5);
shootText.x = 2048 / 2;
shootText.y = 2732 / 2 - 200;
game.addChild(shootText);
// After 2 seconds, show "Ready?"
LK.setTimeout(function () {
shootText.alpha = 0;
var readyText = new Text2('Ready?', {
size: 100,
fill: 0x00FF00 // Green
});
readyText.anchor.set(0.5, 0.5);
readyText.x = 2048 / 2;
readyText.y = 2732 / 2;
game.addChild(readyText);
// After 1 more second, show "Go!" and start game
LK.setTimeout(function () {
readyText.alpha = 0;
var goText = new Text2('Go!', {
size: 120,
fill: 0xFF0000 // Red
});
goText.anchor.set(0.5, 0.5);
goText.x = 2048 / 2;
goText.y = 2732 / 2;
game.addChild(goText);
// Show "Protect Cannons" with arrows at bottom
var protectText = new Text2('Protect Cannons', {
size: 60,
fill: 0xFFFFFF // White
});
protectText.anchor.set(0.5, 0.5);
protectText.x = 2048 / 2;
protectText.y = 2732 - 100;
game.addChild(protectText);
// Create left arrow
var leftArrow = new Text2('←', {
size: 80,
fill: 0xFFFFFF // White
});
leftArrow.anchor.set(0.5, 0.5);
leftArrow.x = 2048 / 2 - 300;
leftArrow.y = 2732 - 100;
game.addChild(leftArrow);
// Create right arrow
var rightArrow = new Text2('→', {
size: 80,
fill: 0xFFFFFF // White
});
rightArrow.anchor.set(0.5, 0.5);
rightArrow.x = 2048 / 2 + 300;
rightArrow.y = 2732 - 100;
game.addChild(rightArrow);
// Fade out "Go!" after a moment
LK.setTimeout(function () {
goText.alpha = 0;
// Gameplay starts here
// Create corner ships for 2-player mode
if (coins === 2) {
// P1 ships (red) - left corners
var p1Ship1 = LK.getAsset('p1Ship', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 100,
scaleX: 1,
scaleY: 1
});
game.addChild(p1Ship1);
gameplayShips.push(p1Ship1);
var p1Ship2 = LK.getAsset('p1Ship', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 2732 - 100,
scaleX: 1,
scaleY: 1
});
game.addChild(p1Ship2);
gameplayShips.push(p1Ship2);
// P2 ships (blue) - right corners
var p2Ship1 = LK.getAsset('p2Ship', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 - 100,
y: 100,
scaleX: 1,
scaleY: 1
});
game.addChild(p2Ship1);
gameplayShips.push(p2Ship1);
var p2Ship2 = LK.getAsset('p2Ship', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 - 100,
y: 2732 - 100,
scaleX: 1,
scaleY: 1
});
game.addChild(p2Ship2);
gameplayShips.push(p2Ship2);
}
// Create target in center
target = LK.getAsset('target', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
scaleX: 1,
scaleY: 1
});
game.addChild(target);
// Create cannons on the bottom: 2 for 1 player, 4 for 2 players
var cannonPositions;
if (coins === 2) {
// 2-player: 4 cannons
cannonPositions = [{
x: 100,
y: 2732 - 100
},
// Bottom left P1 cannon 1
{
x: 200,
y: 2732 - 100
},
// Bottom left P1 cannon 2
{
x: 2048 - 200,
y: 2732 - 100
},
// Bottom right P2 cannon 1
{
x: 2048 - 100,
y: 2732 - 100
} // Bottom right P2 cannon 2
];
} else {
// 1-player: 2 cannons
cannonPositions = [{
x: 100,
y: 2732 - 100
},
// Bottom left cannon
{
x: 2048 - 100,
y: 2732 - 100
} // Bottom right cannon
];
}
for (var i = 0; i < cannonPositions.length; i++) {
var cannon = LK.getAsset('character', {
anchorX: 0.5,
anchorY: 0.5,
x: cannonPositions[i].x,
y: cannonPositions[i].y,
scaleX: 0.5,
scaleY: 0.5,
tint: 0x808080 // Gray color for cannons
});
game.addChild(cannon);
cannons.push(cannon);
}
// Create lines from cannons to target (initially hidden)
for (var i = 0; i < cannons.length; i++) {
var line = LK.getAsset('character', {
anchorX: 0,
anchorY: 0.5,
x: cannons[i].x,
y: cannons[i].y,
scaleX: 1,
scaleY: 0.02,
// Very thin to simulate a line
tint: 0xFF0000,
// Red laser color
alpha: 0 // Initially hidden
});
game.addChild(line);
cannonLines.push(line);
}
}, 1000);
}, 1000);
}, 2000);
} ===================================================================
--- original.js
+++ change.js
@@ -22,10 +22,10 @@
var gameStarted = false;
var insertCoinText;
var creditsText;
var pressStartText;
-var holdStartTime = 0;
-var isHolding = false;
+var holdStartTime = 0; // Only used for hold-to-skip in ready screen
+var isHolding = false; // Only used for hold-to-skip in ready screen
var ship1;
var ship2;
var countdownText;
var countdownTimer;
@@ -226,42 +226,17 @@
}
// Do NOT go to ready screen automatically; require hold for PRESS START
return;
}
- // Start holding for PRESS START
+ // Start ready screen immediately when pressing start (no hold)
if (coins > 0 && !isInReadyScreen) {
- isHolding = true;
- holdStartTime = Date.now();
- // Show ship icons when holding
- if (!ship1) {
- ship1 = LK.getAsset('character', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2 - 100,
- y: 600,
- scaleX: 0.8,
- scaleY: 0.8
- });
- game.addChild(ship1);
- }
- if (!ship2) {
- ship2 = LK.getAsset('character', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 2048 / 2 + 100,
- y: 600,
- scaleX: 0.8,
- scaleY: 0.8,
- alpha: 0.3
- });
- game.addChild(ship2);
- }
+ startReadyScreen();
}
};
// Touch up event to stop holding
game.up = function (x, y, obj) {
if (gameStarted) {
- // Check if held long enough to skip countdown (1 second)
+ // Only allow hold-to-skip during ready screen countdown
if (isInReadyScreen && countdownTimer && Date.now() - holdStartTime >= 1000) {
isHolding = false;
// Skip countdown
LK.clearInterval(countdownTimer);
@@ -277,19 +252,17 @@
}
return;
}
isHolding = false;
- // Check if held long enough to start game (1 second)
- if (coins > 0 && Date.now() - holdStartTime >= 1000 && !isInReadyScreen) {
- startReadyScreen();
- }
+ // No hold-to-start for game; do nothing here except for hold-to-skip in ready screen
};
// Function to start ready screen
function startReadyScreen() {
gameStarted = true;
isInReadyScreen = true;
// Consume one credit when starting
coins--;
+ updateCreditsDisplay();
// Hide all title screen elements except creditsText (keep creditsText visible in ready screen)
if (titleText) titleText.alpha = 0;
if (numberText) numberText.alpha = 0;
if (insertCoinText) insertCoinText.alpha = 0;