/**** * Classes ****/ var SquareWhite = Container.expand(function () { var self = Container.call(this); var lightTypes = ['off', 'on1', 'on2', 'on3']; self.LightType = 'off'; self.squarePosition = 0; var squareAsset = self.attachAsset('SquareWhite', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.716, scaleY: 2.716, tint: self.LightType === 'on3' ? 0xEDF8FF : self.LightType === 'on2' ? 0xA2AABA : self.LightType === 'on1' ? 0x5D637A : 0x121636 }); self.down = function (x, y, obj) { LK.setScore(self.squarePosition); scoreTxt.setText(LK.getScore()); }; }); var WhiteRectangle = Container.expand(function () { var self = Container.call(this); var rectangleAsset = self.attachAsset('WhiteRectangle', { anchorX: 0.5, anchorY: 0.5 }); rectangleAsset.scale.set(0.25, 0.7); self.targetScale = Math.random() * 1.5; self.update = function () { rectangleAsset.scale.x += (self.targetScale - rectangleAsset.scale.x) * 0.02; if (Math.abs(rectangleAsset.scale.x - self.targetScale) < 0.005) { self.targetScale = Math.random() * 1.5; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Assets function attachSquareWhiteAsset(square) { square.attachAsset('SquareWhite', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.716, scaleY: 2.716, tint: square.LightType === 'on3' ? 0xEDF8FF : square.LightType === 'on2' ? 0xA2AABA : square.LightType === 'on1' ? 0x5D637A : 0x121636 }); } function SequenceShow() { sequenceLength = MainSequence.length; if (MainSequence.length > 0) { var _showNextNumber = function showNextNumber(index) { if (index < sequenceLength) { var squarePosition = MainSequence[index]; var square = grid.find(function (sq) { return sq.squarePosition === squarePosition; }); if (square) { // Update light types of previous numbers grid.forEach(function (sq) { if (sq.LightType === 'on3') { sq.LightType = 'on2'; } else if (sq.LightType === 'on2') { sq.LightType = 'on1'; } else if (sq.LightType === 'on1') { sq.LightType = 'off'; attachSquareWhiteAsset(sq); debugTxt.setText(sequenceCurrentLength.toString()); } ; if (sq.LightType !== 'off') { attachSquareWhiteAsset(sq); } }); square.LightType = 'on3'; sequenceCurrentLength += 1; attachSquareWhiteAsset(square); } LK.setTimeout(function () { _showNextNumber(index + 1); }, sequenceDelay); } }; debugTxt.setText(sequenceLength.toString()); _showNextNumber(0); } } // Start SequenceShow 1.5 seconds after the game starts LK.setTimeout(SequenceShow, 1500); var painterBackground = LK.getAsset('PainterBackground', { anchorX: 0.5, anchorY: 1, x: 1024, y: 3082, width: 1751, height: 1560 }); game.addChild(painterBackground); var randomNumberTexts = []; for (var i = 0; i < 50; i++) { var randomNumberText = new Text2(Math.floor(Math.random() * 10).toString(), { size: 40, fill: 0x4A73B5, font: "Courier New" }); randomNumberText.anchor.set(0.5, 0.5); randomNumberText.x = 40.96 * i; randomNumberText.y = 2290; game.addChild(randomNumberText); randomNumberTexts.push(randomNumberText); } // Add an update function to the game to move the numbers to the left game.update = function () { for (var i = 0; i < randomNumberTexts.length; i++) { randomNumberTexts[i].x -= 5; if (randomNumberTexts[i].x < 0) { randomNumberTexts[i].x = 2048; } } if (sequenceCurrentLength === sequenceLength) { LK.setTimeout(function () { grid.forEach(function (square) { square.LightType = 'off'; if (square.LightType !== 'off') { attachSquareWhiteAsset(square); } }); }, 1000); return; } debugTxt.setText(sequenceCurrentLength.toString()); }; // Add Concrete as a background to all other items var concreteBackground = LK.getAsset('Concrete', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, width: 2048, height: 2732, tint: 0x98bee3 }); game.addChildAt(concreteBackground, 0); // Add ScoreBack behind the score var scoreTxt = new Text2('0', { size: 135, fill: 0xFFFFFF, font: "Helvetica" }); var scoreBack = LK.getAsset('ScoreBack', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 120, width: 846.376, height: 969 }); game.addChild(scoreBack); // Add brown board to the game var brownBoardWidth = 400; var brownBoardHeight = 400; var brownBoard = LK.getAsset('BrownBoard', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1336, scaleX: 2048 / brownBoardWidth, scaleY: (4.6 * brownBoardHeight + 30) / brownBoardHeight }); // Add main background to the game var background = LK.getAsset('Background', { anchorX: 0.5, anchorY: 0.5, x: 1044, y: 1366, width: 2171.4, height: 2000 }); game.addChild(brownBoard); game.addChild(background); // Add gridBack var gridBack = LK.getAsset('GridBack', { anchorX: 0.5, anchorY: 0.5, x: 1019, y: 1346, width: 1685, height: 1697 }); game.addChild(gridBack); // Initialize a 6x6 grid of SquareWhite in the middle of the screen var sequenceDelay = 600; var sequenceCurrentLength = 0; var sequenceLength = 1; var MainSequence = []; function setFirstSquareWhiteToOn3() { if (MainSequence.length > 0) { var firstSquarePosition = MainSequence[0]; var firstSquare = grid.find(function (square) { return square.positionInGrid === firstSquarePosition; }); if (firstSquare) { firstSquare.LightType = 'on3'; attachSquareWhiteAsset(firstSquare); } } } setFirstSquareWhiteToOn3(); var grid = []; var gridSize = 6; var squareSize = 275.9; var startX = (2048 - gridSize * squareSize) / 2 + 130; var startY = (2732 - gridSize * squareSize) / 2 + 115; for (var i = 0; i < gridSize; i++) { for (var j = 0; j < gridSize; j++) { var square = new SquareWhite(); square.x = startX + i * squareSize; square.y = startY + j * squareSize; square.squarePosition = j * gridSize + i + 1; game.addChild(square); grid.push(square); if (i === 0 && j === 0) { MainSequence.push(1, 2, 3, 9, 10, 16, 22); } } } // Create 6 WhiteCircle instances and stack them on top of each other in the middle of the screen for (var i = 0; i < 6; i++) { var whiteCircle = LK.getAsset('WhiteCircle', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2 - 910, y: 2732 / 2 + i * 300 - 755, width: 31.5, height: 31.5, tint: 0x34dbeb }); game.addChild(whiteCircle); (function (whiteCircle) { var _changeBrightness = function changeBrightness() { var randomTime = Math.random() * 5000; whiteCircle.alpha = 0.2; LK.setTimeout(function () { whiteCircle.alpha = 1; LK.setTimeout(_changeBrightness, randomTime); }, randomTime); }; _changeBrightness(); // Start changing brightness })(whiteCircle); } // Add score on top of the screen var scoreTxt = new Text2('0', { size: 160, fill: 0x67BAEB, font: "Courier New" }); LK.setScore(0); scoreTxt.setText(LK.getScore()); scoreTxt.anchor.set(0.5, 0); scoreTxt.y += 9; LK.gui.top.addChild(scoreTxt); // Add LevelCounter text var levelCounterTxt = new Text2('Text here', { size: 65, fill: 0xb6bcd6, font: "Courier New" }); levelCounterTxt.anchor.set(0.5, 0); levelCounterTxt.y = scoreTxt.y + 170; LK.gui.top.addChild(levelCounterTxt); for (var i = 0; i < 6; i++) { var rectangle = game.addChild(new WhiteRectangle()); rectangle.x = 2048 - rectangle.width / 2 + 20 - 15; rectangle.y = i * (rectangle.height + 10) + 945; } // Add DebugText var debugTxt = new Text2(sequenceCurrentLength.toString(), { size: 80, fill: 0x888FA2, font: "Courier New" }); debugTxt.anchor.set(0.5, 0.5); debugTxt.x = 464; debugTxt.y = 136; LK.gui.top.addChild(debugTxt);
/****
* Classes
****/
var SquareWhite = Container.expand(function () {
var self = Container.call(this);
var lightTypes = ['off', 'on1', 'on2', 'on3'];
self.LightType = 'off';
self.squarePosition = 0;
var squareAsset = self.attachAsset('SquareWhite', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.716,
scaleY: 2.716,
tint: self.LightType === 'on3' ? 0xEDF8FF : self.LightType === 'on2' ? 0xA2AABA : self.LightType === 'on1' ? 0x5D637A : 0x121636
});
self.down = function (x, y, obj) {
LK.setScore(self.squarePosition);
scoreTxt.setText(LK.getScore());
};
});
var WhiteRectangle = Container.expand(function () {
var self = Container.call(this);
var rectangleAsset = self.attachAsset('WhiteRectangle', {
anchorX: 0.5,
anchorY: 0.5
});
rectangleAsset.scale.set(0.25, 0.7);
self.targetScale = Math.random() * 1.5;
self.update = function () {
rectangleAsset.scale.x += (self.targetScale - rectangleAsset.scale.x) * 0.02;
if (Math.abs(rectangleAsset.scale.x - self.targetScale) < 0.005) {
self.targetScale = Math.random() * 1.5;
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Assets
function attachSquareWhiteAsset(square) {
square.attachAsset('SquareWhite', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.716,
scaleY: 2.716,
tint: square.LightType === 'on3' ? 0xEDF8FF : square.LightType === 'on2' ? 0xA2AABA : square.LightType === 'on1' ? 0x5D637A : 0x121636
});
}
function SequenceShow() {
sequenceLength = MainSequence.length;
if (MainSequence.length > 0) {
var _showNextNumber = function showNextNumber(index) {
if (index < sequenceLength) {
var squarePosition = MainSequence[index];
var square = grid.find(function (sq) {
return sq.squarePosition === squarePosition;
});
if (square) {
// Update light types of previous numbers
grid.forEach(function (sq) {
if (sq.LightType === 'on3') {
sq.LightType = 'on2';
} else if (sq.LightType === 'on2') {
sq.LightType = 'on1';
} else if (sq.LightType === 'on1') {
sq.LightType = 'off';
attachSquareWhiteAsset(sq);
debugTxt.setText(sequenceCurrentLength.toString());
}
;
if (sq.LightType !== 'off') {
attachSquareWhiteAsset(sq);
}
});
square.LightType = 'on3';
sequenceCurrentLength += 1;
attachSquareWhiteAsset(square);
}
LK.setTimeout(function () {
_showNextNumber(index + 1);
}, sequenceDelay);
}
};
debugTxt.setText(sequenceLength.toString());
_showNextNumber(0);
}
}
// Start SequenceShow 1.5 seconds after the game starts
LK.setTimeout(SequenceShow, 1500);
var painterBackground = LK.getAsset('PainterBackground', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 3082,
width: 1751,
height: 1560
});
game.addChild(painterBackground);
var randomNumberTexts = [];
for (var i = 0; i < 50; i++) {
var randomNumberText = new Text2(Math.floor(Math.random() * 10).toString(), {
size: 40,
fill: 0x4A73B5,
font: "Courier New"
});
randomNumberText.anchor.set(0.5, 0.5);
randomNumberText.x = 40.96 * i;
randomNumberText.y = 2290;
game.addChild(randomNumberText);
randomNumberTexts.push(randomNumberText);
}
// Add an update function to the game to move the numbers to the left
game.update = function () {
for (var i = 0; i < randomNumberTexts.length; i++) {
randomNumberTexts[i].x -= 5;
if (randomNumberTexts[i].x < 0) {
randomNumberTexts[i].x = 2048;
}
}
if (sequenceCurrentLength === sequenceLength) {
LK.setTimeout(function () {
grid.forEach(function (square) {
square.LightType = 'off';
if (square.LightType !== 'off') {
attachSquareWhiteAsset(square);
}
});
}, 1000);
return;
}
debugTxt.setText(sequenceCurrentLength.toString());
};
// Add Concrete as a background to all other items
var concreteBackground = LK.getAsset('Concrete', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
width: 2048,
height: 2732,
tint: 0x98bee3
});
game.addChildAt(concreteBackground, 0);
// Add ScoreBack behind the score
var scoreTxt = new Text2('0', {
size: 135,
fill: 0xFFFFFF,
font: "Helvetica"
});
var scoreBack = LK.getAsset('ScoreBack', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 120,
width: 846.376,
height: 969
});
game.addChild(scoreBack);
// Add brown board to the game
var brownBoardWidth = 400;
var brownBoardHeight = 400;
var brownBoard = LK.getAsset('BrownBoard', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1336,
scaleX: 2048 / brownBoardWidth,
scaleY: (4.6 * brownBoardHeight + 30) / brownBoardHeight
});
// Add main background to the game
var background = LK.getAsset('Background', {
anchorX: 0.5,
anchorY: 0.5,
x: 1044,
y: 1366,
width: 2171.4,
height: 2000
});
game.addChild(brownBoard);
game.addChild(background);
// Add gridBack
var gridBack = LK.getAsset('GridBack', {
anchorX: 0.5,
anchorY: 0.5,
x: 1019,
y: 1346,
width: 1685,
height: 1697
});
game.addChild(gridBack);
// Initialize a 6x6 grid of SquareWhite in the middle of the screen
var sequenceDelay = 600;
var sequenceCurrentLength = 0;
var sequenceLength = 1;
var MainSequence = [];
function setFirstSquareWhiteToOn3() {
if (MainSequence.length > 0) {
var firstSquarePosition = MainSequence[0];
var firstSquare = grid.find(function (square) {
return square.positionInGrid === firstSquarePosition;
});
if (firstSquare) {
firstSquare.LightType = 'on3';
attachSquareWhiteAsset(firstSquare);
}
}
}
setFirstSquareWhiteToOn3();
var grid = [];
var gridSize = 6;
var squareSize = 275.9;
var startX = (2048 - gridSize * squareSize) / 2 + 130;
var startY = (2732 - gridSize * squareSize) / 2 + 115;
for (var i = 0; i < gridSize; i++) {
for (var j = 0; j < gridSize; j++) {
var square = new SquareWhite();
square.x = startX + i * squareSize;
square.y = startY + j * squareSize;
square.squarePosition = j * gridSize + i + 1;
game.addChild(square);
grid.push(square);
if (i === 0 && j === 0) {
MainSequence.push(1, 2, 3, 9, 10, 16, 22);
}
}
}
// Create 6 WhiteCircle instances and stack them on top of each other in the middle of the screen
for (var i = 0; i < 6; i++) {
var whiteCircle = LK.getAsset('WhiteCircle', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 - 910,
y: 2732 / 2 + i * 300 - 755,
width: 31.5,
height: 31.5,
tint: 0x34dbeb
});
game.addChild(whiteCircle);
(function (whiteCircle) {
var _changeBrightness = function changeBrightness() {
var randomTime = Math.random() * 5000;
whiteCircle.alpha = 0.2;
LK.setTimeout(function () {
whiteCircle.alpha = 1;
LK.setTimeout(_changeBrightness, randomTime);
}, randomTime);
};
_changeBrightness(); // Start changing brightness
})(whiteCircle);
}
// Add score on top of the screen
var scoreTxt = new Text2('0', {
size: 160,
fill: 0x67BAEB,
font: "Courier New"
});
LK.setScore(0);
scoreTxt.setText(LK.getScore());
scoreTxt.anchor.set(0.5, 0);
scoreTxt.y += 9;
LK.gui.top.addChild(scoreTxt);
// Add LevelCounter text
var levelCounterTxt = new Text2('Text here', {
size: 65,
fill: 0xb6bcd6,
font: "Courier New"
});
levelCounterTxt.anchor.set(0.5, 0);
levelCounterTxt.y = scoreTxt.y + 170;
LK.gui.top.addChild(levelCounterTxt);
for (var i = 0; i < 6; i++) {
var rectangle = game.addChild(new WhiteRectangle());
rectangle.x = 2048 - rectangle.width / 2 + 20 - 15;
rectangle.y = i * (rectangle.height + 10) + 945;
}
// Add DebugText
var debugTxt = new Text2(sequenceCurrentLength.toString(), {
size: 80,
fill: 0x888FA2,
font: "Courier New"
});
debugTxt.anchor.set(0.5, 0.5);
debugTxt.x = 464;
debugTxt.y = 136;
LK.gui.top.addChild(debugTxt);
square with Neon dark blue borders, simple, futuristic, 2d. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Sci-fi Vault dark Concrete wall texture 2d. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Scifi Square with thin, rounded corners. Dark grey. 2d. Single Game Texture. Little blue outline
Smooth white circle, 2d, simple. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Rounded white square. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.