User prompt
make backround city
User prompt
When game starts do not spawn aliens near the player
User prompt
Import of sound asset
User prompt
when player spawns don't let aliens follow player untill 3 seconds in game
User prompt
Make alien following player slower
User prompt
make alien following player slower
User prompt
If player not in wall closest alien chase it
User prompt
Once aliens are dystoyed end game
User prompt
once all bomb shards are collected blow aliens up
User prompt
add bomb shards around the map
User prompt
make it so if player is in a wall the aliens cannot kill them
User prompt
add to more aliens
User prompt
make the aliens faster
User prompt
make the enemys go strait in a different direction untill the hit a wall and then go a different direction
User prompt
make the alien move around the map
Initial prompt
Predator: The game
/**** * Classes ****/ // Define the Alien class var Alien = Container.expand(function () { var self = Container.call(this); var alienGraphics = self.attachAsset('alien', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4; self.update = function () { // Alien moves in a straight line until it hits a wall if (self.direction === undefined) { self.direction = Math.floor(Math.random() * 4); } switch (self.direction) { case 0: // Move up if (self.y - self.speed < 0) { self.direction = 1; // Change direction to down } else { self.y -= self.speed; } break; case 1: // Move down if (self.y + self.speed > 2732) { self.direction = 0; // Change direction to up } else { self.y += self.speed; } break; case 2: // Move left if (self.x - self.speed < 0) { self.direction = 3; // Change direction to right } else { self.x -= self.speed; } break; case 3: // Move right if (self.x + self.speed > 2048) { self.direction = 2; // Change direction to left } else { self.x += self.speed; } break; } }; }); var BombShard = Container.expand(function () { var self = Container.call(this); var bombShardGraphics = self.attachAsset('bombShard', { anchorX: 0.5, anchorY: 0.5 }); }); // Define the Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); }); //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Define the Player class 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, aliens, obstacles and bomb shards var player = game.addChild(new Player()); player.x = 1024; player.y = 1366; var aliens = []; for (var i = 0; i < 7; i++) { var alien = new Alien(); alien.x = Math.random() * 2048; alien.y = Math.random() * 2732; aliens.push(alien); game.addChild(alien); } var obstacles = []; for (var j = 0; j < 10; j++) { var obstacle = new Obstacle(); obstacle.x = Math.random() * 2048; obstacle.y = Math.random() * 2732; obstacles.push(obstacle); game.addChild(obstacle); } var bombShards = []; var bombShardsCollected = 0; // Initialize bombShardsCollected to 0 for (var k = 0; k < 20; k++) { var bombShard = new BombShard(); bombShard.x = Math.random() * 2048; bombShard.y = Math.random() * 2732; bombShards.push(bombShard); game.addChild(bombShard); } // Handle player movement game.move = function (x, y, obj) { player.x = x; player.y = y; }; // Update game logic game.update = function () { // Update player player.update(); // Update aliens for (var i = 0; i < aliens.length; i++) { aliens[i].update(); // Check for collision with player if (player.intersects(aliens[i])) { // Check if player is hiding behind an obstacle var isHiding = false; for (var j = 0; j < obstacles.length; j++) { if (player.intersects(obstacles[j])) { isHiding = true; break; } } // If player is not hiding, game over if (!isHiding) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } } // Check for player intersecting with bomb shards for (var k = 0; k < bombShards.length; k++) { if (player.intersects(bombShards[k])) { // Player has collected a bomb shard bombShardsCollected++; bombShards[k].destroy(); // Destroy the collected bomb shard bombShards.splice(k, 1); // Remove the collected bomb shard from the array k--; // Decrement k to account for the removed bomb shard } } // If all bomb shards are collected, destroy all aliens if (bombShardsCollected === 20) { for (var i = 0; i < aliens.length; i++) { aliens[i].destroy(); } aliens = []; // Clear the aliens array } };
===================================================================
--- original.js
+++ change.js
@@ -110,8 +110,9 @@
obstacles.push(obstacle);
game.addChild(obstacle);
}
var bombShards = [];
+var bombShardsCollected = 0; // Initialize bombShardsCollected to 0
for (var k = 0; k < 20; k++) {
var bombShard = new BombShard();
bombShard.x = Math.random() * 2048;
bombShard.y = Math.random() * 2732;
@@ -146,11 +147,22 @@
LK.showGameOver();
}
}
}
- // Check for player hiding behind obstacles
- for (var j = 0; j < obstacles.length; j++) {
- if (player.intersects(obstacles[j])) {
- // Player is hiding
+ // Check for player intersecting with bomb shards
+ for (var k = 0; k < bombShards.length; k++) {
+ if (player.intersects(bombShards[k])) {
+ // Player has collected a bomb shard
+ bombShardsCollected++;
+ bombShards[k].destroy(); // Destroy the collected bomb shard
+ bombShards.splice(k, 1); // Remove the collected bomb shard from the array
+ k--; // Decrement k to account for the removed bomb shard
}
}
+ // If all bomb shards are collected, destroy all aliens
+ if (bombShardsCollected === 20) {
+ for (var i = 0; i < aliens.length; i++) {
+ aliens[i].destroy();
+ }
+ aliens = []; // Clear the aliens array
+ }
};
\ No newline at end of file
An alien with high tec weaponry and armory. Single Game Texture. In-Game asset. 2d. Blank background. High contrast
A barier wall with vines on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
A man in the army suited with weapons. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
peice of a hi tech bomb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows