User prompt
guarda el contador del puntaje mas alto de flechas destruidas en la parte superior derecha ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Guarda un contador de flechas destruidas en la parte inferior
User prompt
reinicia la music can cada game over
User prompt
reinicia el nivel cada game over
User prompt
elimina el High Score y el Game Over de la parte inferior
User prompt
actualiza el contador de la parte inferior cada Game Over
User prompt
elimina el contador de la parte inferir
User prompt
actualiza el High Score cada ves que sea mas alto ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
guardar el puntaje mas alto y mostrarlo en la parte inferior ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
aumentar la velocidad de las flechas y círculos cada 1 minutos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega un fondo Fondo Fan
User prompt
las flechas y círculos solo se pueden destruir después de 2 segundos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega mas flechas y círculos que suben
User prompt
agrega music can
User prompt
elimina el 0 de la parte superior
User prompt
baja un poco las flechas y círculos
User prompt
baja un poco las flechas y círculos
User prompt
separa mas las flechas y círculos
User prompt
aumenta el tamaño de las flechas y los círculos
User prompt
en el marcador de circulo destruido únelo al marcador de las flechas
User prompt
remplaza el circulo por flecha
User prompt
as un contador de flecha y círculos destruidos
User prompt
separa mas las flechas y el circulo
User prompt
aumenta el tamaño de las flechas y círculos que suben
User prompt
aumenta la velocidad de las flechas y círculos que suben + 0.05
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Arrow = Container.expand(function (direction) {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = direction;
self.isPressed = false;
// Set rotation based on direction
if (direction === 'up-right') {
arrowGraphics.rotation = -Math.PI / 4;
} else if (direction === 'up-left') {
arrowGraphics.rotation = -3 * Math.PI / 4;
} else if (direction === 'down-right') {
arrowGraphics.rotation = Math.PI / 4;
} else if (direction === 'down-left') {
arrowGraphics.rotation = 3 * Math.PI / 4;
}
self.highlight = function () {
arrowGraphics.tint = 0xFFFF00;
self.isPressed = true;
};
self.unhighlight = function () {
arrowGraphics.tint = 0xFFFFFF;
self.isPressed = false;
};
self.down = function (x, y, obj) {
checkArrowPress(self.direction);
};
return self;
});
var GameCircle = Container.expand(function () {
var self = Container.call(this);
var circleGraphics = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5
});
// Rotate to make it point upward like an arrow
circleGraphics.rotation = -Math.PI / 2;
self.originalX = 0;
self.originalY = 0;
self.moveInDirection = function (direction) {
var targetX = self.originalX;
var targetY = self.originalY;
var moveDistance = 50;
if (direction === 'up-right') {
targetX += moveDistance;
targetY -= moveDistance;
} else if (direction === 'up-left') {
targetX -= moveDistance;
targetY -= moveDistance;
} else if (direction === 'down-right') {
targetX += moveDistance;
targetY += moveDistance;
} else if (direction === 'down-left') {
targetX -= moveDistance;
targetY += moveDistance;
}
tween(self, {
x: targetX,
y: targetY
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
x: self.originalX,
y: self.originalY
}, {
duration: 200,
easing: tween.easeOut
});
}
});
};
return self;
});
var MovingArrow = Container.expand(function (direction) {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = direction;
self.speed = 12.65;
self.targetY = 400; // Same height as static arrows
self.lastY = undefined;
// Set rotation based on direction
if (direction === 'up-right') {
arrowGraphics.rotation = -Math.PI / 4;
} else if (direction === 'up-left') {
arrowGraphics.rotation = -3 * Math.PI / 4;
} else if (direction === 'down-right') {
arrowGraphics.rotation = Math.PI / 4;
} else if (direction === 'down-left') {
arrowGraphics.rotation = 3 * Math.PI / 4;
}
self.update = function () {
// Track last Y position
if (self.lastY === undefined) self.lastY = self.y;
// Move upward
self.y -= self.speed;
};
self.down = function (x, y, obj) {
// Destroy this arrow when clicked
for (var i = movingArrows.length - 1; i >= 0; i--) {
if (movingArrows[i] === self) {
totalDestroyedCount++;
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
self.destroy();
movingArrows.splice(i, 1);
break;
}
}
};
return self;
});
var MovingCircle = Container.expand(function () {
var self = Container.call(this);
var circleGraphics = self.attachAsset('circle', {
anchorX: 0.5,
anchorY: 0.5
});
// Rotate to make it point upward like an arrow
circleGraphics.rotation = -Math.PI / 2;
self.speed = 12.65;
self.targetY = 400; // Same height as static circle
self.lastY = undefined;
self.update = function () {
// Track last Y position
if (self.lastY === undefined) self.lastY = self.y;
// Move upward
self.y -= self.speed;
};
self.down = function (x, y, obj) {
// Destroy this circle when clicked
for (var i = movingCircles.length - 1; i >= 0; i--) {
if (movingCircles[i] === self) {
totalDestroyedCount++;
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
self.destroy();
movingCircles.splice(i, 1);
break;
}
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
var gameCircle;
var arrows = [];
var movingArrows = [];
var movingCircles = [];
var currentCommand = '';
var gameSpeed = 2000;
var minSpeed = 800;
var speedIncrease = 50;
var isGameActive = false;
var commandTimeout;
var passedArrowsCount = 0;
var passedCirclesCount = 0;
var totalDestroyedCount = 0;
// UI Elements
var scoreTxt = new Text2('0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
var commandTxt = new Text2('', {
size: 60,
fill: 0xFFFFFF
});
commandTxt.anchor.set(0.5, 0.5);
// Position command text
commandTxt.x = 2048 / 2;
commandTxt.y = 400;
game.addChild(commandTxt);
var destroyedTxt = new Text2('Destroyed: 0', {
size: 50,
fill: 0xFFFFFF
});
destroyedTxt.anchor.set(0.5, 0);
destroyedTxt.x = 2048 / 2;
destroyedTxt.y = 100;
game.addChild(destroyedTxt);
// Create game circle
gameCircle = game.addChild(new GameCircle());
gameCircle.x = 2048 / 2;
gameCircle.y = 400; // Position circle at the same height as arrows
gameCircle.originalX = gameCircle.x;
gameCircle.originalY = gameCircle.y;
// Create arrows aligned at the top of the screen
var arrowPositions = [{
dir: 'up-right',
x: 2048 / 2 + 700,
y: 400
}, {
dir: 'up-left',
x: 2048 / 2 + 300,
y: 400
}, {
dir: 'down-right',
x: 2048 / 2 - 300,
y: 400
}, {
dir: 'down-left',
x: 2048 / 2 - 700,
y: 400
}];
for (var i = 0; i < arrowPositions.length; i++) {
var arrow = new Arrow(arrowPositions[i].dir);
arrow.x = arrowPositions[i].x;
arrow.y = arrowPositions[i].y;
arrows.push(arrow);
game.addChild(arrow);
}
// Game functions
function getRandomDirection() {
var directions = ['up-right', 'up-left', 'down-right', 'down-left'];
return directions[Math.floor(Math.random() * directions.length)];
}
function generateCommand() {
if (!isGameActive) return;
currentCommand = getRandomDirection();
commandTxt.setText(currentCommand.toUpperCase());
// Flash command text
tween(commandTxt, {
alpha: 0.3
}, {
duration: 100,
onFinish: function onFinish() {
tween(commandTxt, {
alpha: 1
}, {
duration: 100
});
}
});
// Set timeout for next command
commandTimeout = LK.setTimeout(function () {
if (isGameActive) {
// Player didn't respond in time - just generate new command
currentCommand = '';
commandTxt.setText('');
generateCommand();
}
}, gameSpeed);
}
function checkArrowPress(direction) {
if (!isGameActive || currentCommand === '') return;
// Clear timeout
LK.clearTimeout(commandTimeout);
// Find and highlight the pressed arrow
for (var i = 0; i < arrows.length; i++) {
if (arrows[i].direction === direction) {
arrows[i].highlight();
LK.setTimeout(function () {
arrows[i].unhighlight();
}, 200);
break;
}
}
if (direction === currentCommand) {
// Correct answer
LK.getSound('correct').play();
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
// Move circle in correct direction
gameCircle.moveInDirection(direction);
// Increase speed slightly
gameSpeed = Math.max(minSpeed, gameSpeed - speedIncrease);
// Clear command and generate new one
currentCommand = '';
commandTxt.setText('');
LK.setTimeout(generateCommand, 500);
} else {
// Wrong answer - continue game
LK.getSound('wrong').play();
// Just generate a new command instead of game over
currentCommand = '';
commandTxt.setText('');
LK.setTimeout(generateCommand, 500);
}
}
function gameOver() {
isGameActive = false;
LK.clearTimeout(commandTimeout);
currentCommand = '';
commandTxt.setText('');
// Flash screen red
LK.effects.flashScreen(0xff0000, 1000);
// Show game over after flash
LK.setTimeout(function () {
LK.showGameOver();
}, 500);
}
function startGame() {
isGameActive = true;
LK.setScore(0);
scoreTxt.setText('0');
gameSpeed = 2000;
passedArrowsCount = 0;
passedCirclesCount = 0;
totalDestroyedCount = 0;
destroyedTxt.setText('Destroyed: 0');
// Start first command after a brief delay
LK.setTimeout(generateCommand, 1000);
}
// Keyboard event handler
game.keydown = function (keyCode) {
if (keyCode === 55) {
// Key '7' - Destroy up-left arrows
for (var i = movingArrows.length - 1; i >= 0; i--) {
var arrow = movingArrows[i];
if (arrow.direction === 'up-left') {
totalDestroyedCount++;
arrow.destroy();
movingArrows.splice(i, 1);
}
}
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
} else if (keyCode === 57) {
// Key '9' - Destroy up-right arrows
for (var i = movingArrows.length - 1; i >= 0; i--) {
var arrow = movingArrows[i];
if (arrow.direction === 'up-right') {
totalDestroyedCount++;
arrow.destroy();
movingArrows.splice(i, 1);
}
}
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
} else if (keyCode === 49) {
// Key '1' - Destroy down-left arrows
for (var i = movingArrows.length - 1; i >= 0; i--) {
var arrow = movingArrows[i];
if (arrow.direction === 'down-left') {
totalDestroyedCount++;
arrow.destroy();
movingArrows.splice(i, 1);
}
}
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
} else if (keyCode === 51) {
// Key '3' - Destroy down-right arrows
for (var i = movingArrows.length - 1; i >= 0; i--) {
var arrow = movingArrows[i];
if (arrow.direction === 'down-right') {
totalDestroyedCount++;
arrow.destroy();
movingArrows.splice(i, 1);
}
}
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
} else if (keyCode === 53) {
// Key '5' - Destroy all moving circles
for (var i = movingCircles.length - 1; i >= 0; i--) {
var circle = movingCircles[i];
totalDestroyedCount++;
circle.destroy();
movingCircles.splice(i, 1);
}
destroyedTxt.setText('Destroyed: ' + totalDestroyedCount);
} else if (keyCode === 81) {
// Key 'Q' - Triple the speed of all moving arrows and circles
for (var i = 0; i < movingArrows.length; i++) {
movingArrows[i].speed *= 3;
}
for (var j = 0; j < movingCircles.length; j++) {
movingCircles[j].speed *= 3;
}
}
};
// Right-click event handler
game.rightdown = function (x, y, obj) {
// Increase speed of all moving arrows
for (var i = 0; i < movingArrows.length; i++) {
movingArrows[i].speed += 1;
}
// Increase speed of all moving circles
for (var j = 0; j < movingCircles.length; j++) {
movingCircles[j].speed += 1;
}
// Increase overall game speed (reduce command timeout)
gameSpeed = Math.max(minSpeed, gameSpeed - speedIncrease);
};
// Start the game
startGame();
game.update = function () {
// Spawn moving arrows periodically
if (LK.ticks % 120 === 0) {
var directions = ['up-right', 'up-left', 'down-right', 'down-left'];
var randomDirection = directions[Math.floor(Math.random() * directions.length)];
var movingArrow = new MovingArrow(randomDirection);
// Position at bottom of screen, aligned with corresponding static arrow
var arrowX = 2048 / 2;
if (randomDirection === 'up-right') arrowX = 2048 / 2 + 700;else if (randomDirection === 'up-left') arrowX = 2048 / 2 + 300;else if (randomDirection === 'down-right') arrowX = 2048 / 2 - 300;else if (randomDirection === 'down-left') arrowX = 2048 / 2 - 700;
movingArrow.x = arrowX;
movingArrow.y = 2732; // Start at bottom of screen
movingArrows.push(movingArrow);
game.addChild(movingArrow);
}
// Spawn moving circles periodically
if (LK.ticks % 180 === 0) {
var movingCircle = new MovingCircle();
movingCircle.x = 2048 / 2; // Center position like static circle
movingCircle.y = 2732; // Start at bottom of screen
movingCircles.push(movingCircle);
game.addChild(movingCircle);
}
// Update moving arrows
for (var i = movingArrows.length - 1; i >= 0; i--) {
var arrow = movingArrows[i];
// Increase speed by 0.05 for existing arrows
arrow.speed += 0.05;
if (arrow.lastY === undefined) arrow.lastY = arrow.y;
// Check if arrow passed the static arrows (y position 400)
if (arrow.lastY >= 400 && arrow.y < 400) {
passedArrowsCount++;
if (passedArrowsCount >= 10) {
gameOver();
return;
}
}
arrow.lastY = arrow.y;
}
// Update moving circles
for (var j = movingCircles.length - 1; j >= 0; j--) {
var circle = movingCircles[j];
// Increase speed by 0.05 for existing circles
circle.speed += 0.05;
if (circle.lastY === undefined) circle.lastY = circle.y;
// Check if circle passed the static circle (y position 400)
if (circle.lastY >= 400 && circle.y < 400) {
passedCirclesCount++;
if (passedCirclesCount >= 10) {
gameOver();
return;
}
}
circle.lastY = circle.y;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -90,9 +90,9 @@
anchorY: 0.5
});
self.direction = direction;
self.speed = 12.65;
- self.targetY = 300; // Same height as static arrows
+ self.targetY = 400; // Same height as static arrows
self.lastY = undefined;
// Set rotation based on direction
if (direction === 'up-right') {
arrowGraphics.rotation = -Math.PI / 4;
@@ -131,9 +131,9 @@
});
// Rotate to make it point upward like an arrow
circleGraphics.rotation = -Math.PI / 2;
self.speed = 12.65;
- self.targetY = 300; // Same height as static circle
+ self.targetY = 400; // Same height as static circle
self.lastY = undefined;
self.update = function () {
// Track last Y position
if (self.lastY === undefined) self.lastY = self.y;
@@ -204,28 +204,28 @@
game.addChild(destroyedTxt);
// Create game circle
gameCircle = game.addChild(new GameCircle());
gameCircle.x = 2048 / 2;
-gameCircle.y = 300; // Position circle at the same height as arrows
+gameCircle.y = 400; // Position circle at the same height as arrows
gameCircle.originalX = gameCircle.x;
gameCircle.originalY = gameCircle.y;
// Create arrows aligned at the top of the screen
var arrowPositions = [{
dir: 'up-right',
x: 2048 / 2 + 700,
- y: 300
+ y: 400
}, {
dir: 'up-left',
x: 2048 / 2 + 300,
- y: 300
+ y: 400
}, {
dir: 'down-right',
x: 2048 / 2 - 300,
- y: 300
+ y: 400
}, {
dir: 'down-left',
x: 2048 / 2 - 700,
- y: 300
+ y: 400
}];
for (var i = 0; i < arrowPositions.length; i++) {
var arrow = new Arrow(arrowPositions[i].dir);
arrow.x = arrowPositions[i].x;
@@ -432,10 +432,10 @@
var arrow = movingArrows[i];
// Increase speed by 0.05 for existing arrows
arrow.speed += 0.05;
if (arrow.lastY === undefined) arrow.lastY = arrow.y;
- // Check if arrow passed the static arrows (y position 300)
- if (arrow.lastY >= 300 && arrow.y < 300) {
+ // Check if arrow passed the static arrows (y position 400)
+ if (arrow.lastY >= 400 && arrow.y < 400) {
passedArrowsCount++;
if (passedArrowsCount >= 10) {
gameOver();
return;
@@ -448,10 +448,10 @@
var circle = movingCircles[j];
// Increase speed by 0.05 for existing circles
circle.speed += 0.05;
if (circle.lastY === undefined) circle.lastY = circle.y;
- // Check if circle passed the static circle (y position 300)
- if (circle.lastY >= 300 && circle.y < 300) {
+ // Check if circle passed the static circle (y position 400)
+ if (circle.lastY >= 400 && circle.y < 400) {
passedCirclesCount++;
if (passedCirclesCount >= 10) {
gameOver();
return;