/****
* Classes
****/
var Button = Container.expand(function () {
var self = Container.call(this);
self.interactive = true;
self.buttonMode = true;
// Add a background graphic
var background = self.attachAsset('buttonBackground', {
anchorX: 0.5,
anchorY: 0.5
});
// Add a textfield
self.textfield = new Text2('1', {
size: 300,
fill: '#111111',
align: 'center',
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(self.textfield);
self.textfield.x = -80;
self.textfield.y = -180;
self.val = 0;
self.on('down', function () {
//console.log('Button pressed:', this.val);
if (this.val == count) {
//console.log('correct');
if (count < 10) {
count++;
randomNumbers();
} else {
// Won.
button1.destroy();
button2.destroy();
button3.destroy();
instructionsText.destroy();
var wonText = new Text2('Good job!\nYou counted to 10\nand averted the crisis.\nPeace and Love!', {
size: 100,
fill: "#000077",
align: 'center',
anchorX: 0.5,
anchorY: 0.0
});
wonText.x = 520;
wonText.y = 100;
game.addChild(wonText);
var winGraphics = game.addChildAt(new WinGraphics(), 1);
var p1Graphics = game.addChildAt(new People1Graphics(), 2);
var p2Graphics = game.addChildAt(new People2Graphics(), 3);
var p3Graphics = game.addChildAt(new People3Graphics(), 4);
var p4Graphics = game.addChildAt(new People4Graphics(), 5);
var p5Graphics = game.addChildAt(new People5Graphics(), 6);
var playAgainButton = game.addChild(new PlayAgainButton());
playAgainButton.x = 2048 / 2 + 600;
playAgainButton.y = 2732 / 2 + 900;
}
} else {
//console.log('incorrect');
var particleSystem = game.addChild(new ParticleSystem());
particleSystem.start();
button1.destroy();
button2.destroy();
button3.destroy();
instructionsText.destroy();
background1.destroy();
gameOver = true;
}
});
});
var ParticleSystem = Container.expand(function () {
var self = Container.call(this);
self.start = function () {
for (var i = 0; i < 100; i++) {
var particle = self.attachAsset('fireParticle', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 2732
});
particle.alpha = 0.7;
particle.scale.x = particle.scale.y = Math.random() * 2;
particles.push(particle);
}
};
});
var People1Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people1', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
});
var People2Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people2', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: 2732 / 2 + 300
});
});
var People3Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people3', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 150,
y: 2732 / 2 + 400
});
});
var People4Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people4', {
anchorX: 0.5,
anchorY: 0.5,
x: 600,
y: 2732 / 2 - 200
});
});
var People5Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people5', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 150,
y: 2732 / 2 - 250
});
});
var PlayAgainButton = Container.expand(function () {
var self = Container.call(this);
self.interactive = true;
self.buttonMode = true;
var background = self.attachAsset('button2Background', {
anchorX: 0.5,
anchorY: 0.5
});
self.textfield = new Text2('Play Again', {
size: 60,
fill: '#111111',
align: 'center',
anchorX: 0.5,
anchorY: 0.5
});
self.textfield.x = -130;
self.textfield.y = -70;
self.addChild(self.textfield);
self.on('down', function () {
LK.setScore(10);
LK.showGameOver();
});
});
var WinGraphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('wonBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001100 // Init game with black background
});
/****
* Game Code
****/
// Initialize game elements
// Initialize a simple circle asset for counting visualization
// Initialize a text asset for displaying the count number
var particles = [];
var background1 = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
alpha: 0.8
}));
var instructionsText = new Text2('Tensions run high at the border\nCount to 10', {
size: 100,
fill: "#ffffff",
align: 'center',
anchorX: 0.5,
anchorY: 0.0
});
instructionsText.x = 400;
instructionsText.y = 100;
game.addChild(instructionsText);
// Initialize count variable
var count = 1;
var gameOver = false;
// Function to update the count and display it
// Add event listener to increment count on touch
var button1 = game.addChild(new Button());
button1.x = 2048 / 2 - 500;
button1.y = 2732 / 2;
var button2 = game.addChild(new Button());
button2.x = 2048 / 2;
button2.y = 2732 / 2;
var button3 = game.addChild(new Button());
button3.x = 2048 / 2 + 500;
button3.y = 2732 / 2;
var buttonArr = [button1, button2, button3];
var randomNumbers = function randomNumbers() {
for (var i in buttonArr) {
var v = Math.ceil(Math.random() * 10);
if (v === 10) {
buttonArr[i].textfield.x = -180;
} else {
buttonArr[i].textfield.x = -80;
}
buttonArr[i].textfield.setText("" + v);
buttonArr[i].val = v;
}
var right = buttonArr[Math.floor(Math.random() * 3)];
right.textfield.setText("" + count);
right.val = count;
if (count === 10) {
right.textfield.x = -180;
} else {
right.textfield.x = -80;
}
};
randomNumbers();
// Main game tick function
LK.on('tick', function () {
// Game logic that needs to be executed every frame can be added here
// For this simple counting game, there's no need to update anything per tick
if (particles.length > 0) {
for (var i = particles.length - 1; i >= 0; i--) {
var factor = Math.random() * 0.25;
particles[i].scale.x += factor;
particles[i].scale.y += factor;
if (particles[i].scale.x > 10) {
particles[i].destroy();
particles.splice(i, 1);
//console.log('particles.length: ' + particles.length);
}
}
} else {
if (gameOver) {
LK.setScore(count - 1);
LK.showGameOver();
}
}
}); /****
* Classes
****/
var Button = Container.expand(function () {
var self = Container.call(this);
self.interactive = true;
self.buttonMode = true;
// Add a background graphic
var background = self.attachAsset('buttonBackground', {
anchorX: 0.5,
anchorY: 0.5
});
// Add a textfield
self.textfield = new Text2('1', {
size: 300,
fill: '#111111',
align: 'center',
anchorX: 0.5,
anchorY: 0.5
});
self.addChild(self.textfield);
self.textfield.x = -80;
self.textfield.y = -180;
self.val = 0;
self.on('down', function () {
//console.log('Button pressed:', this.val);
if (this.val == count) {
//console.log('correct');
if (count < 10) {
count++;
randomNumbers();
} else {
// Won.
button1.destroy();
button2.destroy();
button3.destroy();
instructionsText.destroy();
var wonText = new Text2('Good job!\nYou counted to 10\nand averted the crisis.\nPeace and Love!', {
size: 100,
fill: "#000077",
align: 'center',
anchorX: 0.5,
anchorY: 0.0
});
wonText.x = 520;
wonText.y = 100;
game.addChild(wonText);
var winGraphics = game.addChildAt(new WinGraphics(), 1);
var p1Graphics = game.addChildAt(new People1Graphics(), 2);
var p2Graphics = game.addChildAt(new People2Graphics(), 3);
var p3Graphics = game.addChildAt(new People3Graphics(), 4);
var p4Graphics = game.addChildAt(new People4Graphics(), 5);
var p5Graphics = game.addChildAt(new People5Graphics(), 6);
var playAgainButton = game.addChild(new PlayAgainButton());
playAgainButton.x = 2048 / 2 + 600;
playAgainButton.y = 2732 / 2 + 900;
}
} else {
//console.log('incorrect');
var particleSystem = game.addChild(new ParticleSystem());
particleSystem.start();
button1.destroy();
button2.destroy();
button3.destroy();
instructionsText.destroy();
background1.destroy();
gameOver = true;
}
});
});
var ParticleSystem = Container.expand(function () {
var self = Container.call(this);
self.start = function () {
for (var i = 0; i < 100; i++) {
var particle = self.attachAsset('fireParticle', {
anchorX: 0.5,
anchorY: 0.5,
x: Math.random() * 2048,
y: Math.random() * 2732
});
particle.alpha = 0.7;
particle.scale.x = particle.scale.y = Math.random() * 2;
particles.push(particle);
}
};
});
var People1Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people1', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
});
var People2Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people2', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: 2732 / 2 + 300
});
});
var People3Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people3', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 150,
y: 2732 / 2 + 400
});
});
var People4Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people4', {
anchorX: 0.5,
anchorY: 0.5,
x: 600,
y: 2732 / 2 - 200
});
});
var People5Graphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('people5', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2 + 150,
y: 2732 / 2 - 250
});
});
var PlayAgainButton = Container.expand(function () {
var self = Container.call(this);
self.interactive = true;
self.buttonMode = true;
var background = self.attachAsset('button2Background', {
anchorX: 0.5,
anchorY: 0.5
});
self.textfield = new Text2('Play Again', {
size: 60,
fill: '#111111',
align: 'center',
anchorX: 0.5,
anchorY: 0.5
});
self.textfield.x = -130;
self.textfield.y = -70;
self.addChild(self.textfield);
self.on('down', function () {
LK.setScore(10);
LK.showGameOver();
});
});
var WinGraphics = Container.expand(function () {
var self = Container.call(this);
var wonBackground = self.attachAsset('wonBackground', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x001100 // Init game with black background
});
/****
* Game Code
****/
// Initialize game elements
// Initialize a simple circle asset for counting visualization
// Initialize a text asset for displaying the count number
var particles = [];
var background1 = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2,
alpha: 0.8
}));
var instructionsText = new Text2('Tensions run high at the border\nCount to 10', {
size: 100,
fill: "#ffffff",
align: 'center',
anchorX: 0.5,
anchorY: 0.0
});
instructionsText.x = 400;
instructionsText.y = 100;
game.addChild(instructionsText);
// Initialize count variable
var count = 1;
var gameOver = false;
// Function to update the count and display it
// Add event listener to increment count on touch
var button1 = game.addChild(new Button());
button1.x = 2048 / 2 - 500;
button1.y = 2732 / 2;
var button2 = game.addChild(new Button());
button2.x = 2048 / 2;
button2.y = 2732 / 2;
var button3 = game.addChild(new Button());
button3.x = 2048 / 2 + 500;
button3.y = 2732 / 2;
var buttonArr = [button1, button2, button3];
var randomNumbers = function randomNumbers() {
for (var i in buttonArr) {
var v = Math.ceil(Math.random() * 10);
if (v === 10) {
buttonArr[i].textfield.x = -180;
} else {
buttonArr[i].textfield.x = -80;
}
buttonArr[i].textfield.setText("" + v);
buttonArr[i].val = v;
}
var right = buttonArr[Math.floor(Math.random() * 3)];
right.textfield.setText("" + count);
right.val = count;
if (count === 10) {
right.textfield.x = -180;
} else {
right.textfield.x = -80;
}
};
randomNumbers();
// Main game tick function
LK.on('tick', function () {
// Game logic that needs to be executed every frame can be added here
// For this simple counting game, there's no need to update anything per tick
if (particles.length > 0) {
for (var i = particles.length - 1; i >= 0; i--) {
var factor = Math.random() * 0.25;
particles[i].scale.x += factor;
particles[i].scale.y += factor;
if (particles[i].scale.x > 10) {
particles[i].destroy();
particles.splice(i, 1);
//console.log('particles.length: ' + particles.length);
}
}
} else {
if (gameOver) {
LK.setScore(count - 1);
LK.showGameOver();
}
}
});
A map of a fictional world, divided in the middle by a red dashed line, which is a country border. On each side of the border, a modern army is marched up and pointing weapons at the other side. Style should be detailed illustration.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast.
A blank scrabble tile, direct top down view.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A beautiful meadow in summer, seen in perspective from a low altitude plane.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A smiling family waving.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A smiling family waving.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A smiling family waving.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A smiling family waving.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A fiery explosion. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A rectangular green button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.