/**** * Classes ****/ // Taille ajustée pour les segments var ColorCircle = Container.expand(function () { var self = Container.call(this); var circleGraphic = self.attachAsset('colorCircle', { anchorX: 0.5, anchorY: 0.5 }); self.segments = []; for (var i = 0; i < 6; i++) { var angle = i * (Math.PI / 3); var segment = new ColorSegment(i, angle); self.segments.push(segment); self.addChild(segment); } }); var ColorSegment = Container.expand(function (index, angle) { var self = Container.call(this); var segmentIds = ['colorSegmentBlue', 'colorSegmentYellow', 'colorSegmentPurple', 'colorSegmentAzur', 'colorSegmentOrange', 'colorSegmentGreen']; var segmentGraphic = self.attachAsset(segmentIds[index], { anchorX: 0.275, anchorY: 1.2 }); self.rotation = angle; self.on('down', function (obj) { if (!showingSequence) { checkPlayerSequence(index); } }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x212121 // Dark grey background }); /**** * Game Code ****/ // Initialize the ColorCircle and store it in a variable for global access var helpText = new Text2('Help me to improve my game', { size: 50, fill: '#ffffff', anchorX: 0.5, anchorY: 0.5 }); helpText.x = 0; helpText.y = 400; LK.gui.top.addChild(helpText); var gameInstruction = new Text2('Find the right color sequence', { size: 50, fill: '#ffffff', anchorX: 0.5, anchorY: 0.5 }); gameInstruction.x = 10; gameInstruction.y = 200; LK.gui.top.addChild(gameInstruction); function showSequence() { showingSequence = true; var i = 0; var interval = LK.setInterval(function () { if (i >= sequence.length) { LK.clearInterval(interval); waitForPlayerResponse(); } else { var segment = colorCircle.segments[sequence[i]]; LK.effects.flashObject(segment, 0xffffff, 500); i++; } }, 1000); } var sequence = []; var colorCircle = game.addChild(new ColorCircle()); colorCircle.x = 2048 / 2; // Center horizontally colorCircle.y = 2732 / 2; // Center vertically proposeColor(); // Game Logic var sequence = []; var playerSequence = []; var sequenceIndex = 0; var showingSequence = false; function startGame() { proposeColor(); } function proposeColor() { var proposedIndex = Math.floor(Math.random() * 6); // Randomly select a color to propose sequence.push(proposedIndex); // Add the proposed color to the sequence highlightColor(proposedIndex); waitForPlayerResponse(); } function highlightColor(index) { colorCircle.segments[index].alpha = 0.5; } function waitForPlayerResponse() { showingSequence = false; } function checkPlayerSequence(index) { playerSequence.push(index); if (sequence[playerSequence.length - 1] !== playerSequence[playerSequence.length - 1]) { LK.showGameOver(); } else if (playerSequence.length === sequence.length) { LK.setScore(LK.getScore() + 100); updateScoreDisplay(); sequence = []; playerSequence = []; proposeColor(); } } startGame(); // Display the current score var scoreTxt = new Text2('Score: 0', { size: 50, fill: "#ffffff", anchorX: 0.5, anchorY: 0.1 }); LK.gui.top.addChild(scoreTxt); // Update score display function function updateScoreDisplay() { scoreTxt.setText('Score: ' + LK.getScore()); } // Call updateScoreDisplay whenever the score needs to be updated // This will be integrated into the game logic where the score changes
/****
* Classes
****/
// Taille ajustée pour les segments
var ColorCircle = Container.expand(function () {
var self = Container.call(this);
var circleGraphic = self.attachAsset('colorCircle', {
anchorX: 0.5,
anchorY: 0.5
});
self.segments = [];
for (var i = 0; i < 6; i++) {
var angle = i * (Math.PI / 3);
var segment = new ColorSegment(i, angle);
self.segments.push(segment);
self.addChild(segment);
}
});
var ColorSegment = Container.expand(function (index, angle) {
var self = Container.call(this);
var segmentIds = ['colorSegmentBlue', 'colorSegmentYellow', 'colorSegmentPurple', 'colorSegmentAzur', 'colorSegmentOrange', 'colorSegmentGreen'];
var segmentGraphic = self.attachAsset(segmentIds[index], {
anchorX: 0.275,
anchorY: 1.2
});
self.rotation = angle;
self.on('down', function (obj) {
if (!showingSequence) {
checkPlayerSequence(index);
}
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x212121 // Dark grey background
});
/****
* Game Code
****/
// Initialize the ColorCircle and store it in a variable for global access
var helpText = new Text2('Help me to improve my game', {
size: 50,
fill: '#ffffff',
anchorX: 0.5,
anchorY: 0.5
});
helpText.x = 0;
helpText.y = 400;
LK.gui.top.addChild(helpText);
var gameInstruction = new Text2('Find the right color sequence', {
size: 50,
fill: '#ffffff',
anchorX: 0.5,
anchorY: 0.5
});
gameInstruction.x = 10;
gameInstruction.y = 200;
LK.gui.top.addChild(gameInstruction);
function showSequence() {
showingSequence = true;
var i = 0;
var interval = LK.setInterval(function () {
if (i >= sequence.length) {
LK.clearInterval(interval);
waitForPlayerResponse();
} else {
var segment = colorCircle.segments[sequence[i]];
LK.effects.flashObject(segment, 0xffffff, 500);
i++;
}
}, 1000);
}
var sequence = [];
var colorCircle = game.addChild(new ColorCircle());
colorCircle.x = 2048 / 2; // Center horizontally
colorCircle.y = 2732 / 2; // Center vertically
proposeColor();
// Game Logic
var sequence = [];
var playerSequence = [];
var sequenceIndex = 0;
var showingSequence = false;
function startGame() {
proposeColor();
}
function proposeColor() {
var proposedIndex = Math.floor(Math.random() * 6); // Randomly select a color to propose
sequence.push(proposedIndex); // Add the proposed color to the sequence
highlightColor(proposedIndex);
waitForPlayerResponse();
}
function highlightColor(index) {
colorCircle.segments[index].alpha = 0.5;
}
function waitForPlayerResponse() {
showingSequence = false;
}
function checkPlayerSequence(index) {
playerSequence.push(index);
if (sequence[playerSequence.length - 1] !== playerSequence[playerSequence.length - 1]) {
LK.showGameOver();
} else if (playerSequence.length === sequence.length) {
LK.setScore(LK.getScore() + 100);
updateScoreDisplay();
sequence = [];
playerSequence = [];
proposeColor();
}
}
startGame();
// Display the current score
var scoreTxt = new Text2('Score: 0', {
size: 50,
fill: "#ffffff",
anchorX: 0.5,
anchorY: 0.1
});
LK.gui.top.addChild(scoreTxt);
// Update score display function
function updateScoreDisplay() {
scoreTxt.setText('Score: ' + LK.getScore());
}
// Call updateScoreDisplay whenever the score needs to be updated
// This will be integrated into the game logic where the score changes
a slice of pizza on a transparent background, predominantly purple. Slice of pizza
a slice of pizza on a transparent background, predominantly azur. Slice of pizza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a slice of pizza on a transparent background, predominantly orange. Slice of pizza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a slice of pizza on a transparent background, predominantly green. Slice of pizza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a slice of pizza on a transparent background, predominantly blue. Slice of pizza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a slice of pizza on a transparent background, predominantly yellow. Slice of pizza. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.