/****
* Classes
****/
// Create a Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
// Attach the 'bullet' asset to the Bullet class
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the speed of the Bullet class
self.speed = -5;
// This is automatically called every game tick, if the Bullet class is attached!
self.update = function () {
self.y += self.speed;
// If the Bullet class reaches the top of the screen, destroy it
if (self.y < 0) {
self.destroy();
}
};
});
// Create a Monedita class
var Monedita = Container.expand(function () {
var self = Container.call(this);
// Attach the 'Monedita' asset to the Monedita class
var moneditaGraphics = self.attachAsset('Monedita', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the speed of the Monedita class
self.speed = 5;
// This is automatically called every game tick, if the Monedita class is attached!
self.update = function () {
self.y += self.speed;
// If the Monedita class reaches the bottom of the screen, destroy it
if (self.y > 2732) {
self.destroy();
}
// If 'fueguito' intersects with 'monedita', trigger game over
if (self.intersects(fueguito)) {
LK.showGameOver();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFFFFF
});
/****
* Game Code
****/
// Mouse or touch down on game object
game.down = function (x, y, obj) {
// Create a Bullet instance
var bullet = new Bullet();
bullet.x = x; // Start at the current mouse position
bullet.y = y;
game.addChild(bullet);
};
game.move = function (x, y, obj) {
// Make the 'fueguito' asset follow the mouse
fueguito.x = x;
fueguito.y = y;
};
var fueguito = LK.getAsset('fueguito', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 2,
scaleY: 2
});
// Add the 'fueguito' asset to the game
game.addChild(fueguito);
// Create a Monedita instance every second
var moneditaSpeed = 5;
var moneditaCount = 1;
LK.setInterval(function () {
for (var i = 0; i < moneditaCount; i++) {
var monedita = new Monedita();
monedita.x = Math.random() * 2048; // Random x position
monedita.y = 0; // Start at the top of the screen
monedita.speed = moneditaSpeed;
game.addChild(monedita);
}
}, 1000);
// Increase the speed of 'monedita' and add 1 to the score every 10 seconds
// If the game has been running for 300 seconds, show the win screen and the score
LK.setInterval(function () {
moneditaSpeed += 1;
moneditaCount += 1;
LK.setScore(LK.getScore() + 1);
if (LK.getScore() >= 30) {
LK.showYouWin();
LK.setScore(LK.getScore());
}
}, 10000);
; /****
* Classes
****/
// Create a Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
// Attach the 'bullet' asset to the Bullet class
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the speed of the Bullet class
self.speed = -5;
// This is automatically called every game tick, if the Bullet class is attached!
self.update = function () {
self.y += self.speed;
// If the Bullet class reaches the top of the screen, destroy it
if (self.y < 0) {
self.destroy();
}
};
});
// Create a Monedita class
var Monedita = Container.expand(function () {
var self = Container.call(this);
// Attach the 'Monedita' asset to the Monedita class
var moneditaGraphics = self.attachAsset('Monedita', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the speed of the Monedita class
self.speed = 5;
// This is automatically called every game tick, if the Monedita class is attached!
self.update = function () {
self.y += self.speed;
// If the Monedita class reaches the bottom of the screen, destroy it
if (self.y > 2732) {
self.destroy();
}
// If 'fueguito' intersects with 'monedita', trigger game over
if (self.intersects(fueguito)) {
LK.showGameOver();
}
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xFFFFFF
});
/****
* Game Code
****/
// Mouse or touch down on game object
game.down = function (x, y, obj) {
// Create a Bullet instance
var bullet = new Bullet();
bullet.x = x; // Start at the current mouse position
bullet.y = y;
game.addChild(bullet);
};
game.move = function (x, y, obj) {
// Make the 'fueguito' asset follow the mouse
fueguito.x = x;
fueguito.y = y;
};
var fueguito = LK.getAsset('fueguito', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
scaleX: 2,
scaleY: 2
});
// Add the 'fueguito' asset to the game
game.addChild(fueguito);
// Create a Monedita instance every second
var moneditaSpeed = 5;
var moneditaCount = 1;
LK.setInterval(function () {
for (var i = 0; i < moneditaCount; i++) {
var monedita = new Monedita();
monedita.x = Math.random() * 2048; // Random x position
monedita.y = 0; // Start at the top of the screen
monedita.speed = moneditaSpeed;
game.addChild(monedita);
}
}, 1000);
// Increase the speed of 'monedita' and add 1 to the score every 10 seconds
// If the game has been running for 300 seconds, show the win screen and the score
LK.setInterval(function () {
moneditaSpeed += 1;
moneditaCount += 1;
LK.setScore(LK.getScore() + 1);
if (LK.getScore() >= 30) {
LK.showYouWin();
LK.setScore(LK.getScore());
}
}, 10000);
;