User prompt
pero e dicho QUE NO SEA DE PREGUNTAS JOE
User prompt
PERO QUE NO SEA UNA TRIVIA QUE SE PARA VER PELICULAS
User prompt
QUE NO SEAN PREGUNTAS QUE TENGAS QUE VR PELICULAS
Code edit (1 edits merged)
Please save this source code
User prompt
Movie Night Trivia
Initial prompt
un juego de ver peliculas
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Bucket = Container.expand(function () {
var self = Container.call(this);
var bucketGraphics = self.attachAsset('bucket', {
anchorX: 0.5,
anchorY: 0.5
});
self.targetX = self.x;
self.update = function () {
var diff = self.targetX - self.x;
self.x += diff * 0.15;
};
return self;
});
var Popcorn = Container.expand(function () {
var self = Container.call(this);
var popcornGraphics = self.attachAsset('popcorn', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3 + Math.random() * 4;
self.rotationSpeed = (Math.random() - 0.5) * 0.2;
self.lastY = self.y;
self.caught = false;
self.update = function () {
if (self.caught) return;
self.y += self.speed;
popcornGraphics.rotation += self.rotationSpeed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x1a1a1a
});
/****
* Game Code
****/
// Game variables
var gameEnded = false;
var popcorns = [];
var gameTime = 0;
var streak = 0;
var missedPopcorn = 0;
var maxMisses = 10;
var spawnRate = 120; // frames between spawns
// Create movie theater setup
var movieFrame = game.addChild(LK.getAsset('movieFrame', {
anchorX: 0.5,
anchorY: 0.5
}));
movieFrame.x = 1024;
movieFrame.y = 600;
var movieScreen = game.addChild(LK.getAsset('movieScreen', {
anchorX: 0.5,
anchorY: 0.5
}));
movieScreen.x = 1024;
movieScreen.y = 600;
// Add "Now Playing" text on screen
var movieText = new Text2('🎬 MOVIE NIGHT 🎬\nCatch the popcorn!', {
size: 80,
fill: 0xFFFFFF
});
movieText.anchor.set(0.5, 0.5);
movieText.x = 1024;
movieText.y = 600;
game.addChild(movieText);
// Create bucket
var bucket = game.addChild(new Bucket());
bucket.x = 1024;
bucket.y = 2400;
// Score display
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
var missText = new Text2('Missed: 0/10', {
size: 60,
fill: 0xFF6B6B
});
missText.anchor.set(0.5, 0);
missText.y = 100;
LK.gui.top.addChild(missText);
var streakText = new Text2('Streak: 0', {
size: 50,
fill: 0xF39C12
});
streakText.anchor.set(1, 0);
streakText.y = 200;
LK.gui.topRight.addChild(streakText);
// Game functions
function spawnPopcorn() {
if (gameEnded) return;
var popcorn = new Popcorn();
popcorn.x = 200 + Math.random() * 1648; // Random X position across screen
popcorn.y = -50; // Start above screen
popcorn.lastY = popcorn.y;
popcorns.push(popcorn);
game.addChild(popcorn);
LK.getSound('pop').play();
}
function catchPopcorn(popcorn) {
if (popcorn.caught) return;
popcorn.caught = true;
LK.getSound('catch').play();
var points = 10 + streak * 2;
LK.setScore(LK.getScore() + points);
streak++;
scoreText.setText('Score: ' + LK.getScore());
streakText.setText('Streak: ' + streak);
// Remove popcorn
for (var i = 0; i < popcorns.length; i++) {
if (popcorns[i] === popcorn) {
popcorns[i].destroy();
popcorns.splice(i, 1);
break;
}
}
}
function missPopcorn() {
LK.getSound('miss').play();
missedPopcorn++;
streak = 0;
streakText.setText('Streak: ' + streak);
missText.setText('Missed: ' + missedPopcorn + '/' + maxMisses);
if (missedPopcorn >= maxMisses) {
endGame();
}
}
function endGame() {
gameEnded = true;
// Save high score
var highScore = storage.highScore || 0;
if (LK.getScore() > highScore) {
storage.highScore = LK.getScore();
}
storage.gamesPlayed = (storage.gamesPlayed || 0) + 1;
if (LK.getScore() >= 500) {
LK.showYouWin();
} else {
LK.showGameOver();
}
}
// Touch controls
game.move = function (x, y, obj) {
if (gameEnded) return;
bucket.targetX = x;
};
game.down = function (x, y, obj) {
if (gameEnded) return;
bucket.targetX = x;
};
// Main game update
game.update = function () {
if (gameEnded) return;
gameTime++;
// Spawn popcorn
if (gameTime % spawnRate === 0) {
spawnPopcorn();
// Increase difficulty over time
if (spawnRate > 30) {
spawnRate -= 1;
}
}
// Update popcorns and check collisions
for (var i = popcorns.length - 1; i >= 0; i--) {
var popcorn = popcorns[i];
if (popcorn.caught) continue;
// Check if popcorn fell off screen
if (popcorn.lastY <= 2732 && popcorn.y > 2732) {
missPopcorn();
popcorns[i].destroy();
popcorns.splice(i, 1);
continue;
}
// Check collision with bucket
if (popcorn.intersects(bucket)) {
catchPopcorn(popcorn);
continue;
}
popcorn.lastY = popcorn.y;
}
}; ===================================================================
--- original.js
+++ change.js
@@ -6,59 +6,35 @@
/****
* Classes
****/
-var AnswerButton = Container.expand(function (answerText, isCorrect) {
+var Bucket = Container.expand(function () {
var self = Container.call(this);
- self.isCorrect = isCorrect;
- self.answered = false;
- var buttonBg = self.attachAsset('answerButton', {
+ var bucketGraphics = self.attachAsset('bucket', {
anchorX: 0.5,
anchorY: 0.5
});
- var buttonText = new Text2(answerText, {
- size: 45,
- fill: 0xFFFFFF
- });
- buttonText.anchor.set(0.5, 0.5);
- self.addChild(buttonText);
- self.setCorrect = function () {
- self.removeChild(buttonBg);
- buttonBg = self.attachAsset('answerButtonCorrect', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.addChildAt(buttonBg, 0);
+ self.targetX = self.x;
+ self.update = function () {
+ var diff = self.targetX - self.x;
+ self.x += diff * 0.15;
};
- self.setWrong = function () {
- self.removeChild(buttonBg);
- buttonBg = self.attachAsset('answerButtonWrong', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.addChildAt(buttonBg, 0);
- };
- self.down = function (x, y, obj) {
- if (self.answered || gameEnded) return;
- self.answered = true;
- answerQuestion(self.isCorrect);
- };
return self;
});
-var QuestionDisplay = Container.expand(function () {
+var Popcorn = Container.expand(function () {
var self = Container.call(this);
- var containerBg = self.attachAsset('questionContainer', {
+ var popcornGraphics = self.attachAsset('popcorn', {
anchorX: 0.5,
anchorY: 0.5
});
- self.questionText = new Text2('', {
- size: 50,
- fill: 0xFFFFFF
- });
- self.questionText.anchor.set(0.5, 0.5);
- self.addChild(self.questionText);
- self.setQuestion = function (questionStr) {
- self.questionText.setText(questionStr);
+ self.speed = 3 + Math.random() * 4;
+ self.rotationSpeed = (Math.random() - 0.5) * 0.2;
+ self.lastY = self.y;
+ self.caught = false;
+ self.update = function () {
+ if (self.caught) return;
+ self.y += self.speed;
+ popcornGraphics.rotation += self.rotationSpeed;
};
return self;
});
@@ -72,201 +48,151 @@
/****
* Game Code
****/
// Game variables
-var currentQuestion = 0;
-var totalQuestions = 10;
-var timePerQuestion = 15;
-var timeRemaining = timePerQuestion;
var gameEnded = false;
-var questionStartTime = 0;
+var popcorns = [];
+var gameTime = 0;
var streak = 0;
-var maxStreak = 0;
-// General knowledge trivia questions - no movies required
-var movieQuestions = [{
- question: "What is the capital of Australia?",
- answers: ["Sydney", "Canberra", "Melbourne", "Brisbane"],
- correct: 1
-}, {
- question: "How many continents are there?",
- answers: ["5", "6", "7", "8"],
- correct: 2
-}, {
- question: "What is the largest planet in our solar system?",
- answers: ["Saturn", "Jupiter", "Neptune", "Earth"],
- correct: 1
-}, {
- question: "Which element has the chemical symbol 'O'?",
- answers: ["Gold", "Silver", "Oxygen", "Iron"],
- correct: 2
-}, {
- question: "How many sides does a hexagon have?",
- answers: ["5", "6", "7", "8"],
- correct: 1
-}, {
- question: "What is the smallest country in the world?",
- answers: ["Monaco", "Vatican City", "San Marino", "Liechtenstein"],
- correct: 1
-}, {
- question: "Which ocean is the largest?",
- answers: ["Atlantic", "Indian", "Arctic", "Pacific"],
- correct: 3
-}, {
- question: "What year did World War II end?",
- answers: ["1944", "1945", "1946", "1947"],
- correct: 1
-}, {
- question: "What is the hardest natural substance on Earth?",
- answers: ["Gold", "Iron", "Diamond", "Platinum"],
- correct: 2
-}, {
- question: "How many bones are there in an adult human body?",
- answers: ["196", "206", "216", "226"],
- correct: 1
-}];
-// UI Elements
-var questionDisplay = game.addChild(new QuestionDisplay());
-questionDisplay.x = 1024;
-questionDisplay.y = 600;
-var answerButtons = [];
-var timerBarBg = game.addChild(LK.getAsset('timerBarBg', {
+var missedPopcorn = 0;
+var maxMisses = 10;
+var spawnRate = 120; // frames between spawns
+// Create movie theater setup
+var movieFrame = game.addChild(LK.getAsset('movieFrame', {
anchorX: 0.5,
anchorY: 0.5
}));
-timerBarBg.x = 1024;
-timerBarBg.y = 200;
-var timerBar = game.addChild(LK.getAsset('timerBar', {
- anchorX: 0,
+movieFrame.x = 1024;
+movieFrame.y = 600;
+var movieScreen = game.addChild(LK.getAsset('movieScreen', {
+ anchorX: 0.5,
anchorY: 0.5
}));
-timerBar.x = 124;
-timerBar.y = 200;
+movieScreen.x = 1024;
+movieScreen.y = 600;
+// Add "Now Playing" text on screen
+var movieText = new Text2('🎬 MOVIE NIGHT 🎬\nCatch the popcorn!', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+movieText.anchor.set(0.5, 0.5);
+movieText.x = 1024;
+movieText.y = 600;
+game.addChild(movieText);
+// Create bucket
+var bucket = game.addChild(new Bucket());
+bucket.x = 1024;
+bucket.y = 2400;
// Score display
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
-var questionCountText = new Text2('Question 1 of 10', {
+var missText = new Text2('Missed: 0/10', {
size: 60,
- fill: 0xFFFFFF
+ fill: 0xFF6B6B
});
-questionCountText.anchor.set(0.5, 0);
-questionCountText.y = 100;
-LK.gui.top.addChild(questionCountText);
+missText.anchor.set(0.5, 0);
+missText.y = 100;
+LK.gui.top.addChild(missText);
var streakText = new Text2('Streak: 0', {
size: 50,
fill: 0xF39C12
});
streakText.anchor.set(1, 0);
streakText.y = 200;
LK.gui.topRight.addChild(streakText);
// Game functions
-function setupAnswerButtons() {
- // Clear existing buttons
- for (var i = 0; i < answerButtons.length; i++) {
- answerButtons[i].destroy();
+function spawnPopcorn() {
+ if (gameEnded) return;
+ var popcorn = new Popcorn();
+ popcorn.x = 200 + Math.random() * 1648; // Random X position across screen
+ popcorn.y = -50; // Start above screen
+ popcorn.lastY = popcorn.y;
+ popcorns.push(popcorn);
+ game.addChild(popcorn);
+ LK.getSound('pop').play();
+}
+function catchPopcorn(popcorn) {
+ if (popcorn.caught) return;
+ popcorn.caught = true;
+ LK.getSound('catch').play();
+ var points = 10 + streak * 2;
+ LK.setScore(LK.getScore() + points);
+ streak++;
+ scoreText.setText('Score: ' + LK.getScore());
+ streakText.setText('Streak: ' + streak);
+ // Remove popcorn
+ for (var i = 0; i < popcorns.length; i++) {
+ if (popcorns[i] === popcorn) {
+ popcorns[i].destroy();
+ popcorns.splice(i, 1);
+ break;
+ }
}
- answerButtons = [];
- var question = movieQuestions[currentQuestion];
- var buttonPositions = [{
- x: 512,
- y: 1200
- }, {
- x: 1536,
- y: 1200
- }, {
- x: 512,
- y: 1350
- }, {
- x: 1536,
- y: 1350
- }];
- for (var i = 0; i < question.answers.length; i++) {
- var button = new AnswerButton(question.answers[i], i === question.correct);
- button.x = buttonPositions[i].x;
- button.y = buttonPositions[i].y;
- answerButtons.push(button);
- game.addChild(button);
- }
}
-function startQuestion() {
- if (currentQuestion >= totalQuestions) {
+function missPopcorn() {
+ LK.getSound('miss').play();
+ missedPopcorn++;
+ streak = 0;
+ streakText.setText('Streak: ' + streak);
+ missText.setText('Missed: ' + missedPopcorn + '/' + maxMisses);
+ if (missedPopcorn >= maxMisses) {
endGame();
- return;
}
- timeRemaining = timePerQuestion;
- questionStartTime = LK.ticks;
- var question = movieQuestions[currentQuestion];
- questionDisplay.setQuestion(question.question);
- setupAnswerButtons();
- questionCountText.setText('Question ' + (currentQuestion + 1) + ' of ' + totalQuestions);
}
-function answerQuestion(isCorrect) {
- for (var i = 0; i < answerButtons.length; i++) {
- answerButtons[i].answered = true;
- if (answerButtons[i].isCorrect) {
- answerButtons[i].setCorrect();
- } else {
- answerButtons[i].setWrong();
- }
- }
- if (isCorrect) {
- LK.getSound('correct').play();
- var timeBonus = Math.floor(timeRemaining / timePerQuestion * 50);
- var streakBonus = streak * 10;
- var points = 100 + timeBonus + streakBonus;
- LK.setScore(LK.getScore() + points);
- streak++;
- if (streak > maxStreak) {
- maxStreak = streak;
- }
- } else {
- LK.getSound('wrong').play();
- streak = 0;
- }
- scoreText.setText('Score: ' + LK.getScore());
- streakText.setText('Streak: ' + streak);
- LK.setTimeout(function () {
- currentQuestion++;
- startQuestion();
- }, 2000);
-}
function endGame() {
gameEnded = true;
// Save high score
var highScore = storage.highScore || 0;
if (LK.getScore() > highScore) {
storage.highScore = LK.getScore();
}
- storage.maxStreak = Math.max(storage.maxStreak || 0, maxStreak);
storage.gamesPlayed = (storage.gamesPlayed || 0) + 1;
- if (LK.getScore() >= 800) {
+ if (LK.getScore() >= 500) {
LK.showYouWin();
} else {
LK.showGameOver();
}
}
-// Timer update
+// Touch controls
+game.move = function (x, y, obj) {
+ if (gameEnded) return;
+ bucket.targetX = x;
+};
+game.down = function (x, y, obj) {
+ if (gameEnded) return;
+ bucket.targetX = x;
+};
+// Main game update
game.update = function () {
if (gameEnded) return;
- // Update timer
- var ticksPassed = LK.ticks - questionStartTime;
- var secondsPassed = ticksPassed / 60;
- timeRemaining = Math.max(0, timePerQuestion - secondsPassed);
- // Update timer bar
- var timerPercent = timeRemaining / timePerQuestion;
- timerBar.width = 1800 * timerPercent;
- // Check if time ran out
- if (timeRemaining <= 0) {
- LK.getSound('tick').play();
- answerQuestion(false);
- return;
+ gameTime++;
+ // Spawn popcorn
+ if (gameTime % spawnRate === 0) {
+ spawnPopcorn();
+ // Increase difficulty over time
+ if (spawnRate > 30) {
+ spawnRate -= 1;
+ }
}
- // Timer warning sound
- if (timeRemaining <= 3 && timeRemaining > 2.95) {
- LK.getSound('tick').play();
+ // Update popcorns and check collisions
+ for (var i = popcorns.length - 1; i >= 0; i--) {
+ var popcorn = popcorns[i];
+ if (popcorn.caught) continue;
+ // Check if popcorn fell off screen
+ if (popcorn.lastY <= 2732 && popcorn.y > 2732) {
+ missPopcorn();
+ popcorns[i].destroy();
+ popcorns.splice(i, 1);
+ continue;
+ }
+ // Check collision with bucket
+ if (popcorn.intersects(bucket)) {
+ catchPopcorn(popcorn);
+ continue;
+ }
+ popcorn.lastY = popcorn.y;
}
-};
-// Start first question
-startQuestion();
\ No newline at end of file
+};
\ No newline at end of file