User prompt
make a wall on the sides
User prompt
if you keep clicing you get out makewal to
User prompt
make th game more detailed
User prompt
make it wayyyy harder
User prompt
make the screen follow me
User prompt
make me keep move side ways
User prompt
make gravity and the player jumps when you click
User prompt
make a ground
User prompt
make the player go side ways continuasly and change the background to mach the playr
Initial prompt
geometry crash
/**** * Classes ****/ // 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, scaleX: 1.5, scaleY: 1.5, tint: 0xFFFF00 }); self.speed = -30; 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, scaleX: 1.5, scaleY: 1.5, tint: 0xFF0000 }); self.speed = 10; self.update = function () { self.y += self.speed; if (self.y > 2732) { self.y = 0; self.x = Math.random() * 2048; } }; }); // Define a class for the ground var Ground = Container.expand(function () { var self = Container.call(this); var groundGraphics = self.attachAsset('ground', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5, tint: 0x008000 }); self.update = function () { // Ground update logic }; }); //<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, scaleX: 1.5, scaleY: 1.5, tint: 0x0000FF }); self.speed = 10; self.update = function () { // Player update logic self.x += self.speed; if (self.x > 2048) { self.x = 0; } }; }); // Define a class for the wall var Wall = Container.expand(function () { var self = Container.call(this); var wallGraphics = self.attachAsset('wall', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5, tint: 0x0000FF }); self.update = function () { // Wall update logic }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x92eabd //Init game with green background }); /**** * Game Code ****/ // Initialize player var player = game.addChild(new Player()); player.x = 1024; player.y = 2500; // Initialize walls on the sides var leftWall = game.addChild(new Wall()); leftWall.x = 0; leftWall.y = 1366; var rightWall = game.addChild(new Wall()); rightWall.x = 2048; rightWall.y = 1366; // Initialize ground var ground = game.addChild(new Ground()); ground.x = 1024; ground.y = 2732 - ground.height / 2; // Initialize enemies var enemies = []; for (var i = 0; i < 20; 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.down = function (x, y, obj) { player.speed = -30; }; // Handle shooting game.up = function (x, y, obj) { player.speed = 10; }; // Game update loop game.update = function () { // Update player player.update(); // Check for collision between player and the walls if (player.intersects(leftWall) || player.intersects(rightWall)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } // Make the screen follow the player game.x = -player.x + 1024; game.y = -player.y + 1366; // Update enemies for (var i = 0; i < enemies.length; i++) { enemies[i].update(); if (player.intersects(enemies[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Update bullets for (var j = bullets.length - 1; j >= 0; j--) { bullets[j].update(); for (var k = enemies.length - 1; k >= 0; k--) { if (bullets[j].intersects(enemies[k])) { bullets[j].destroy(); bullets.splice(j, 1); enemies[k].destroy(); enemies.splice(k, 1); break; } } } };
===================================================================
--- original.js
+++ change.js
@@ -101,12 +101,15 @@
// Initialize player
var player = game.addChild(new Player());
player.x = 1024;
player.y = 2500;
-// Initialize wall
-var wall = game.addChild(new Wall());
-wall.x = 1024;
-wall.y = 1500;
+// Initialize walls on the sides
+var leftWall = game.addChild(new Wall());
+leftWall.x = 0;
+leftWall.y = 1366;
+var rightWall = game.addChild(new Wall());
+rightWall.x = 2048;
+rightWall.y = 1366;
// Initialize ground
var ground = game.addChild(new Ground());
ground.x = 1024;
ground.y = 2732 - ground.height / 2;
@@ -132,10 +135,10 @@
// Game update loop
game.update = function () {
// Update player
player.update();
- // Check for collision between player and wall
- if (player.intersects(wall)) {
+ // Check for collision between player and the walls
+ if (player.intersects(leftWall) || player.intersects(rightWall)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
// Make the screen follow the player