/**** * Classes ****/ var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.attachAsset('heart', { anchorX: 0.5, anchorY: 0.5 }); }); //<Write imports for supported plugins here> //<Write entity 'classes' with empty functions for important behavior here> var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.lives = 3; self.update = function () { // Hero update logic if needed }; }); var Rocket = Container.expand(function () { var self = Container.call(this); var rocketGraphics = self.attachAsset('rocket', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ //<Assets used in the game will automatically appear here> //<Write game logic code here, including initializing arrays and variables> var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 150; var rockets = []; var score = 0; var scoreTxt = new Text2('Score: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var heart1 = game.addChild(new Heart()); heart1.x = 2048 - 150; heart1.y = 50; var heart2 = game.addChild(new Heart()); heart2.x = 2048 - 200; heart2.y = 50; var heart3 = game.addChild(new Heart()); heart3.x = 2048 - 250; heart3.y = 50; game.down = function (x, y, obj) { hero.x = x; }; game.update = function () { if (LK.ticks % 60 == 0) { var newRocket = new Rocket(); newRocket.x = Math.random() * 2048; newRocket.y = -50; rockets.push(newRocket); game.addChild(newRocket); } for (var i = rockets.length - 1; i >= 0; i--) { if (rockets[i].intersects(hero)) { hero.lives -= 1; livesTxt.setText('Lives: ' + hero.lives); rockets[i].destroy(); rockets.splice(i, 1); if (hero.lives <= 0) { LK.showGameOver(); } } } score += 1; scoreTxt.setText('Score: ' + score); };
===================================================================
--- original.js
+++ change.js
@@ -1,85 +1,95 @@
-/****
+/****
* Classes
-****/
+****/
+var Heart = Container.expand(function () {
+ var self = Container.call(this);
+ var heartGraphics = self.attachAsset('heart', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+});
//<Write imports for supported plugins here>
//<Write entity 'classes' with empty functions for important behavior here>
var Hero = Container.expand(function () {
- var self = Container.call(this);
- var heroGraphics = self.attachAsset('hero', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.lives = 3;
- self.update = function () {
- // Hero update logic if needed
- };
+ var self = Container.call(this);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.lives = 3;
+ self.update = function () {
+ // Hero update logic if needed
+ };
});
var Rocket = Container.expand(function () {
- var self = Container.call(this);
- var rocketGraphics = self.attachAsset('rocket', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.destroy();
- }
- };
+ var self = Container.call(this);
+ var rocketGraphics = self.attachAsset('rocket', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 5;
+ self.update = function () {
+ self.y += self.speed;
+ if (self.y > 2732) {
+ self.destroy();
+ }
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
-//<Write game logic code here, including initializing arrays and variables>
+****/
//<Assets used in the game will automatically appear here>
+//<Write game logic code here, including initializing arrays and variables>
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 - 150;
var rockets = [];
var score = 0;
var scoreTxt = new Text2('Score: 0', {
- size: 100,
- fill: 0xFFFFFF
+ size: 100,
+ fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
-var livesTxt = new Text2('Lives: 3', {
- size: 100,
- fill: 0xFFFFFF
-});
-livesTxt.anchor.set(0.5, 0);
-LK.gui.topRight.addChild(livesTxt);
+var heart1 = game.addChild(new Heart());
+heart1.x = 2048 - 150;
+heart1.y = 50;
+var heart2 = game.addChild(new Heart());
+heart2.x = 2048 - 200;
+heart2.y = 50;
+var heart3 = game.addChild(new Heart());
+heart3.x = 2048 - 250;
+heart3.y = 50;
game.down = function (x, y, obj) {
- hero.x = x;
+ hero.x = x;
};
game.update = function () {
- if (LK.ticks % 60 == 0) {
- var newRocket = new Rocket();
- newRocket.x = Math.random() * 2048;
- newRocket.y = -50;
- rockets.push(newRocket);
- game.addChild(newRocket);
- }
- for (var i = rockets.length - 1; i >= 0; i--) {
- if (rockets[i].intersects(hero)) {
- hero.lives -= 1;
- livesTxt.setText('Lives: ' + hero.lives);
- rockets[i].destroy();
- rockets.splice(i, 1);
- if (hero.lives <= 0) {
- LK.showGameOver();
- }
- }
- }
- score += 1;
- scoreTxt.setText('Score: ' + score);
+ if (LK.ticks % 60 == 0) {
+ var newRocket = new Rocket();
+ newRocket.x = Math.random() * 2048;
+ newRocket.y = -50;
+ rockets.push(newRocket);
+ game.addChild(newRocket);
+ }
+ for (var i = rockets.length - 1; i >= 0; i--) {
+ if (rockets[i].intersects(hero)) {
+ hero.lives -= 1;
+ livesTxt.setText('Lives: ' + hero.lives);
+ rockets[i].destroy();
+ rockets.splice(i, 1);
+ if (hero.lives <= 0) {
+ LK.showGameOver();
+ }
+ }
+ }
+ score += 1;
+ scoreTxt.setText('Score: ' + score);
};
\ No newline at end of file
Bildiğin roket yap. Bir tane Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Kalp yap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Arkaplan olarak uzay yap. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
İnsan. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.