===================================================================
--- original.js
+++ change.js
@@ -1,80 +1,80 @@
-/****
+/****
* Classes
-****/
+****/
// Obstacle class
var Obstacle = Container.expand(function () {
- var self = Container.call(this);
- var obstacleGraphics = self.attachAsset('obstacle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 7;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.y = -100;
- self.x = Math.random() * 2048;
- }
- };
+ var self = Container.call(this);
+ var obstacleGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 7;
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > 2732) {
+ self.y = -100;
+ self.x = Math.random() * 2048;
+ }
+ };
});
// PowerUp class
var PowerUp = Container.expand(function () {
- var self = Container.call(this);
- var powerUpGraphics = self.attachAsset('powerUp', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.y = -100;
- self.x = Math.random() * 2048;
- }
- };
+ var self = Container.call(this);
+ var powerUpGraphics = self.attachAsset('powerUp', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > 2732) {
+ self.y = -100;
+ self.x = Math.random() * 2048;
+ }
+ };
});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
// Superman class
var Superman = Container.expand(function () {
- var self = Container.call(this);
- var supermanGraphics = self.attachAsset('superman', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 10;
- self.update = function () {
- // Superman's update logic
- };
+ var self = Container.call(this);
+ var supermanGraphics = self.attachAsset('superman', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 10;
+ self.update = function () {
+ // Superman's update logic
+ };
});
// Villain class
var Villain = Container.expand(function () {
- var self = Container.call(this);
- var villainGraphics = self.attachAsset('villain', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.y = -100;
- self.x = Math.random() * 2048;
- }
- };
+ var self = Container.call(this);
+ var villainGraphics = self.attachAsset('villain', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > 2732) {
+ self.y = -100;
+ self.x = Math.random() * 2048;
+ }
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize game elements
var superman = game.addChild(new Superman());
superman.x = 1024;
superman.y = 2400;
@@ -82,66 +82,66 @@
var obstacles = [];
var powerUps = [];
// Create villains
for (var i = 0; i < 5; i++) {
- var villain = new Villain();
- villain.x = Math.random() * 2048;
- villain.y = Math.random() * -2732;
- villains.push(villain);
- game.addChild(villain);
+ var villain = new Villain();
+ villain.x = Math.random() * 2048;
+ villain.y = Math.random() * -2732;
+ villains.push(villain);
+ game.addChild(villain);
}
// Create obstacles
for (var i = 0; i < 5; i++) {
- var obstacle = new Obstacle();
- obstacle.x = Math.random() * 2048;
- obstacle.y = Math.random() * -2732;
- obstacles.push(obstacle);
- game.addChild(obstacle);
+ var obstacle = new Obstacle();
+ obstacle.x = Math.random() * 2048;
+ obstacle.y = Math.random() * -2732;
+ obstacles.push(obstacle);
+ game.addChild(obstacle);
}
// Create power-ups
for (var i = 0; i < 3; i++) {
- var powerUp = new PowerUp();
- powerUp.x = Math.random() * 2048;
- powerUp.y = Math.random() * -2732;
- powerUps.push(powerUp);
- game.addChild(powerUp);
+ var powerUp = new PowerUp();
+ powerUp.x = Math.random() * 2048;
+ powerUp.y = Math.random() * -2732;
+ powerUps.push(powerUp);
+ game.addChild(powerUp);
}
// Handle game move events
game.move = function (x, y, obj) {
- superman.x = x;
- superman.y = y;
+ superman.x = x;
+ superman.y = y;
};
// Update game logic
game.update = function () {
- // Update villains
- villains.forEach(function (villain) {
- villain.update();
- if (superman.intersects(villain)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- });
- // Update obstacles
- obstacles.forEach(function (obstacle) {
- obstacle.update();
- if (superman.intersects(obstacle)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- });
- // Update power-ups
- powerUps.forEach(function (powerUp) {
- powerUp.update();
- if (superman.intersects(powerUp)) {
- LK.setScore(LK.getScore() + 10);
- powerUp.destroy();
- }
- });
+ // Update villains
+ villains.forEach(function (villain) {
+ villain.update();
+ if (superman.intersects(villain)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ });
+ // Update obstacles
+ obstacles.forEach(function (obstacle) {
+ obstacle.update();
+ if (superman.intersects(obstacle)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ });
+ // Update power-ups
+ powerUps.forEach(function (powerUp) {
+ powerUp.update();
+ if (superman.intersects(powerUp)) {
+ LK.setScore(LK.getScore() + 1);
+ powerUp.destroy();
+ }
+ });
};
// Display score
var scoreTxt = new Text2('0', {
- size: 150,
- fill: 0xFFFFFF
+ size: 150,
+ fill: 0xFFFFFF
});
scoreTxt.setText(LK.getScore());
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
\ No newline at end of file
Gold. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Superman. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Zombie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Canavar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows