User prompt
el juego se gana is ganas 5 rondas
User prompt
creame un background asset para ponerle fondo al juego
User prompt
y que tenga una musica jaz cantada por gatitos bebes
User prompt
cuando suena el miau caiga un pescado y el que llega a tener 10 pescados gana, separa mas a los jugadores y haz que sea mucho mas grande la mesa y generame asset de un back ground para hacer el fondo
Code edit (1 edits merged)
Please save this source code
User prompt
Miau Reflex - Cat Paw Slap Game
Initial prompt
crea un juego de 4 jugadores 3 son ia todos son patitas de gatos y hay un cronometro invisible y una voz que dice miau cuando hay que golpear una mesa el ultimo en golpearla pierde
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var CatPaw = Container.expand(function (assetId, startX, startY, isPlayer, reactionSpeed) {
var self = Container.call(this);
self.isPlayer = isPlayer || false;
self.reactionSpeed = reactionSpeed || 300;
self.startX = startX;
self.startY = startY;
self.isEliminated = false;
self.hasReacted = false;
self.reactionTime = 0;
var pawGraphics = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
self.x = startX;
self.y = startY;
self.resetPosition = function () {
self.x = self.startX;
self.y = self.startY;
self.hasReacted = false;
self.reactionTime = 0;
};
self.slapTable = function () {
if (self.isEliminated || self.hasReacted) return;
self.hasReacted = true;
self.reactionTime = Date.now() - gameStartTime;
// Animate paw moving to table
tween(self, {
x: 1024,
y: 1366
}, {
duration: 200,
easing: tween.easeOut
});
};
self.eliminate = function () {
self.isEliminated = true;
tween(pawGraphics, {
alpha: 0.3,
scaleX: 0.5,
scaleY: 0.5
}, {
duration: 500,
easing: tween.easeInOut
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
// Add background
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var table = game.addChild(LK.getAsset('table', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
// Create paws array
var paws = [];
var playerPaw = game.addChild(new CatPaw('playerPaw', 1024, 1800, true, 0));
var aiPaw1 = game.addChild(new CatPaw('aiPaw1', 400, 1366, false, 250 + Math.random() * 200));
var aiPaw2 = game.addChild(new CatPaw('aiPaw2', 1648, 1366, false, 300 + Math.random() * 250));
var aiPaw3 = game.addChild(new CatPaw('aiPaw3', 1024, 932, false, 200 + Math.random() * 300));
paws.push(playerPaw, aiPaw1, aiPaw2, aiPaw3);
// Game state variables
var gameState = 'waiting'; // 'waiting', 'countdown', 'listening', 'reacting', 'roundEnd'
var gameStartTime = 0;
var waitTimer = 0;
var roundNumber = 1;
var playerWins = storage.playerWins || 0;
var totalGames = storage.totalGames || 0;
var roundsWon = storage.roundsWon || 0;
// UI Elements
var instructionText = new Text2('Wait for the "MIAU" sound, then tap the table!', {
size: 60,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
var scoreText = new Text2('Rounds Won: ' + roundsWon + '/5', {
size: 50,
fill: 0xFFFFFF
});
scoreText.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreText);
var roundText = new Text2('Round ' + roundNumber, {
size: 80,
fill: 0xFFD700
});
roundText.anchor.set(0.5, 0.5);
game.addChild(roundText);
roundText.x = 1024;
roundText.y = 600;
function startNewRound() {
gameState = 'waiting';
waitTimer = LK.ticks + (180 + Math.random() * 300); // 3-8 seconds wait
// Reset all non-eliminated paws
for (var i = 0; i < paws.length; i++) {
if (!paws[i].isEliminated) {
paws[i].resetPosition();
}
}
instructionText.setText('Wait for the "MIAU" sound...');
roundText.setText('Round ' + roundNumber);
}
function playMiauSound() {
gameState = 'reacting';
gameStartTime = Date.now();
LK.getSound('miau').play();
instructionText.setText('SLAP THE TABLE NOW!');
// AI reactions with their individual speeds
for (var i = 0; i < paws.length; i++) {
var paw = paws[i];
if (!paw.isPlayer && !paw.isEliminated) {
LK.setTimeout(function (p) {
return function () {
p.slapTable();
};
}(paw), paw.reactionSpeed + Math.random() * 100);
}
}
}
function checkRoundEnd() {
var activePaws = [];
var reactedPaws = [];
for (var i = 0; i < paws.length; i++) {
if (!paws[i].isEliminated) {
activePaws.push(paws[i]);
if (paws[i].hasReacted) {
reactedPaws.push(paws[i]);
}
}
}
if (reactedPaws.length === activePaws.length && activePaws.length > 1) {
// Find slowest paw
var slowestPaw = reactedPaws[0];
for (var i = 1; i < reactedPaws.length; i++) {
if (reactedPaws[i].reactionTime > slowestPaw.reactionTime) {
slowestPaw = reactedPaws[i];
}
}
// Eliminate slowest paw
slowestPaw.eliminate();
if (slowestPaw.isPlayer) {
instructionText.setText('You lost this round!');
// Reset eliminated status for next round
for (var k = 0; k < paws.length; k++) {
paws[k].isEliminated = false;
paws[k].resetPosition();
}
roundNumber++;
LK.setTimeout(function () {
startNewRound();
}, 1500);
} else {
activePaws = [];
for (var j = 0; j < paws.length; j++) {
if (!paws[j].isEliminated) {
activePaws.push(paws[j]);
}
}
if (activePaws.length === 1 && activePaws[0].isPlayer) {
instructionText.setText('You won this round!');
roundsWon++;
storage.roundsWon = roundsWon;
scoreText.setText('Rounds Won: ' + roundsWon + '/5');
if (roundsWon >= 5) {
instructionText.setText('You Won the Game! 5 rounds completed!');
totalGames++;
playerWins++;
storage.playerWins = playerWins;
storage.totalGames = totalGames;
storage.roundsWon = 0; // Reset for next game
LK.setTimeout(function () {
LK.showYouWin();
}, 2000);
} else {
// Reset eliminated status for next round
for (var k = 0; k < paws.length; k++) {
paws[k].isEliminated = false;
paws[k].resetPosition();
}
roundNumber++;
LK.setTimeout(function () {
startNewRound();
}, 1500);
}
} else {
roundNumber++;
LK.setTimeout(function () {
startNewRound();
}, 1500);
}
}
}
}
// Touch controls for player
game.down = function (x, y, obj) {
if (gameState === 'reacting' && !playerPaw.isEliminated) {
playerPaw.slapTable();
}
};
// Start baby kitten jazz background music
LK.playMusic('babyKittenJazz');
// Initialize first round
startNewRound();
game.update = function () {
if (gameState === 'waiting' && LK.ticks >= waitTimer) {
playMiauSound();
}
if (gameState === 'reacting') {
checkRoundEnd();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -91,16 +91,17 @@
var waitTimer = 0;
var roundNumber = 1;
var playerWins = storage.playerWins || 0;
var totalGames = storage.totalGames || 0;
+var roundsWon = storage.roundsWon || 0;
// UI Elements
var instructionText = new Text2('Wait for the "MIAU" sound, then tap the table!', {
size: 60,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
-var scoreText = new Text2('Wins: ' + playerWins + '/' + totalGames, {
+var scoreText = new Text2('Rounds Won: ' + roundsWon + '/5', {
size: 50,
fill: 0xFFFFFF
});
scoreText.anchor.set(1, 0);
@@ -163,32 +164,51 @@
}
// Eliminate slowest paw
slowestPaw.eliminate();
if (slowestPaw.isPlayer) {
- instructionText.setText('You were eliminated! Game Over');
- totalGames++;
- storage.totalGames = totalGames;
- scoreText.setText('Wins: ' + playerWins + '/' + totalGames);
+ instructionText.setText('You lost this round!');
+ // Reset eliminated status for next round
+ for (var k = 0; k < paws.length; k++) {
+ paws[k].isEliminated = false;
+ paws[k].resetPosition();
+ }
+ roundNumber++;
LK.setTimeout(function () {
- LK.showGameOver();
- }, 2000);
+ startNewRound();
+ }, 1500);
} else {
activePaws = [];
for (var j = 0; j < paws.length; j++) {
if (!paws[j].isEliminated) {
activePaws.push(paws[j]);
}
}
if (activePaws.length === 1 && activePaws[0].isPlayer) {
- instructionText.setText('You Won! Well done!');
- playerWins++;
- totalGames++;
- storage.playerWins = playerWins;
- storage.totalGames = totalGames;
- scoreText.setText('Wins: ' + playerWins + '/' + totalGames);
- LK.setTimeout(function () {
- LK.showYouWin();
- }, 2000);
+ instructionText.setText('You won this round!');
+ roundsWon++;
+ storage.roundsWon = roundsWon;
+ scoreText.setText('Rounds Won: ' + roundsWon + '/5');
+ if (roundsWon >= 5) {
+ instructionText.setText('You Won the Game! 5 rounds completed!');
+ totalGames++;
+ playerWins++;
+ storage.playerWins = playerWins;
+ storage.totalGames = totalGames;
+ storage.roundsWon = 0; // Reset for next game
+ LK.setTimeout(function () {
+ LK.showYouWin();
+ }, 2000);
+ } else {
+ // Reset eliminated status for next round
+ for (var k = 0; k < paws.length; k++) {
+ paws[k].isEliminated = false;
+ paws[k].resetPosition();
+ }
+ roundNumber++;
+ LK.setTimeout(function () {
+ startNewRound();
+ }, 1500);
+ }
} else {
roundNumber++;
LK.setTimeout(function () {
startNewRound();