/**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background });
===================================================================
--- original.js
+++ change.js
@@ -1,107 +1,8 @@
/****
-* Classes
+* Initialize Game
****/
-// Define a class for bullets
-var Bullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('bullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -10;
- self.update = function () {
- self.y += self.speed;
- if (self.y < 0) {
- self.destroy();
- }
- };
-});
-// Define a class for enemies
-var Enemy = Container.expand(function () {
- var self = Container.call(this);
- var enemyGraphics = self.attachAsset('enemy', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 3;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.y = 0;
- self.x = Math.random() * 2048;
- }
- };
-});
//<Assets used in the game will automatically appear here>
//<Write imports for supported plugins here>
-// Define a class for the player character
-var Player = Container.expand(function () {
- var self = Container.call(this);
- var playerGraphics = self.attachAsset('player', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- // Player update logic
- };
-});
-
-/****
-* Initialize Game
-****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
-});
-
-/****
-* Game Code
-****/
-// Initialize player
-var player = game.addChild(new Player());
-player.x = 1024;
-player.y = 2500;
-// Initialize enemies
-var enemies = [];
-for (var i = 0; i < 5; i++) {
- var enemy = new Enemy();
- enemy.x = Math.random() * 2048;
- enemy.y = Math.random() * 1000;
- enemies.push(enemy);
- game.addChild(enemy);
-}
-// Initialize bullets
-var bullets = [];
-// Handle player movement
-game.move = function (x, y, obj) {
- player.x = x;
- player.y = y;
-};
-// Handle shooting
-game.down = function (x, y, obj) {
- var bullet = new Bullet();
- bullet.x = player.x;
- bullet.y = player.y;
- bullets.push(bullet);
- game.addChild(bullet);
-};
-// Update game state
-game.update = function () {
- // Update bullets
- for (var i = bullets.length - 1; i >= 0; i--) {
- var bullet = bullets[i];
- bullet.update();
- if (bullet.y < 0) {
- bullets.splice(i, 1);
- }
- }
- // Update enemies
- for (var j = 0; j < enemies.length; j++) {
- var enemy = enemies[j];
- enemy.update();
- if (player.intersects(enemy)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- }
-};
\ No newline at end of file
+ backgroundColor: 0x000000 //Init game with black background
+});
\ No newline at end of file
rock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A sunset beach background with waves and palm trees.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
a robotic basket with high contrast. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
robotic and shiny balls. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows