/****
* Classes
****/
// Class for boss
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.direction = Math.random() * 2 * Math.PI; // Random direction in radians
self.update = function () {
// Calculate direction towards the player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the player
self.x += dx * self.speed;
self.y += dy * self.speed;
};
});
// 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 () {
// Calculate direction towards the enemy
if (enemies.length > 0) {
var dx = enemies[0].x - self.x;
var dy = enemies[0].y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the enemy
self.x += dx * self.speed;
self.y += dy * self.speed;
}
// Rotate the bullet
bulletGraphics.rotation += 0.1;
};
});
// Class for crafting bullets
var CraftBullet = Container.expand(function () {
var self = Container.call(this);
var stone = self.attachAsset('stone', {
anchorX: 0.5,
anchorY: 0.5
});
var stick = self.attachAsset('stick', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// CraftBullet update logic
};
});
// 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.direction = Math.random() * 2 * Math.PI; // Random direction in radians
self.update = function () {
// Calculate direction towards the player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the player
self.x += dx * self.speed;
self.y += dy * self.speed;
};
});
// Class for NPC 'A Kneeling Boss'
var KneelingBoss = Container.expand(function () {
var self = Container.call(this);
var kneelingBossGraphics = self.attachAsset('kneelingBoss', {
anchorX: 0.5,
anchorY: 0.5
});
// Additional properties or methods for the kneeling boss can be added here
});
// Class for ores
var Ore = Container.expand(function () {
var self = Container.call(this);
var oreGraphics = self.attachAsset('ore', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Ore update logic
};
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// 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
};
});
// Class for Resource Page
var ResourcePage = Container.expand(function () {
var self = Container.call(this);
var resourceGraphics = self.attachAsset('resource', {
anchorX: 0.5,
anchorY: 0.5
});
resourceGraphics.x = 2048 / 2;
resourceGraphics.y = 2732 / 2;
self.addChild(resourceGraphics);
self.interactive = true;
self.on('down', function () {
console.log("Resource selected");
self.destroy();
game.start();
});
});
// Class for Start Screen
var StartScreen = Container.expand(function () {
var self = Container.call(this);
var startScreenImage = self.attachAsset('startScreen', {
anchorX: 0.5,
anchorY: 0.5
});
startScreenImage.x = 2048 / 2;
startScreenImage.y = 2732 / 2;
self.addChild(startScreenImage);
self.interactive = true;
self.on('down', function () {
self.destroy();
game.start();
});
});
// Class for stick weapon
var Stick = Container.expand(function () {
var self = Container.call(this);
var stickGraphics = self.attachAsset('stick', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Stick update logic
// Make the stick surround the player
self.x = player.x;
self.y = player.y;
};
});
// Class for stones
var Stone = Container.expand(function () {
var self = Container.call(this);
var stoneGraphics = self.attachAsset('stone', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Stone update logic
};
});
// Class for sword bullets
var SwordBullet = Container.expand(function () {
var self = Container.call(this);
var swordGraphics = self.attachAsset('sword', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
// Calculate direction towards the boss
if (enemies.length > 0 && enemies[0] instanceof Boss) {
var dx = enemies[0].x - self.x;
var dy = enemies[0].y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the boss
self.x += dx * self.speed;
self.y += dy * self.speed;
}
// Rotate the sword bullet
swordGraphics.rotation += 0.1;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Add resource page
var resourcePage = new ResourcePage();
game.addChild(resourcePage);
// Ensure game does not start until start screen is dismissed
game.start = function () {
// game.resume(); // Removed as it is not a valid function
};
// Function to trigger two endings
function triggerEndings() {
// Display choices to the player
var choice = prompt("Choose your ending: 1 for Ending A, 2 for Ending B");
if (choice === "1") {
// Trigger Ending A
console.log("Ending A triggered");
// Add logic for Ending A
} else if (choice === "2") {
// Trigger Ending B
console.log("Ending B triggered");
// Add logic for Ending B
} else {
console.log("Invalid choice");
}
}
// Add background image to the game
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
background.x = 2048 / 2;
background.y = 2732 / 2;
game.addChild(background);
// Play background music
LK.playMusic('dee');
// Initialize bullets
var bullets = [];
// Initialize player
var player = game.addChild(new Player());
// Track if the sword has been fired
var swordFired = false;
player.x = 2048 / 2;
player.y = 2732 - 200;
// Initialize enemies
var enemies = [];
var bossDefeated = false;
for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
var side = Math.floor(Math.random() * 4); // Random side (0: top, 1: right, 2: bottom, 3: left)
switch (side) {
case 0:
enemy.x = Math.random() * 2048;
enemy.y = 0;
break;
case 1:
enemy.x = 2048;
enemy.y = Math.random() * 2732;
break;
case 2:
enemy.x = Math.random() * 2048;
enemy.y = 2732;
break;
case 3:
enemy.x = 0;
enemy.y = Math.random() * 2732;
break;
}
enemies.push(enemy);
game.addChild(enemy);
}
// Initialize stick weapons
var sticks = [];
for (var i = 0; i < 5; i++) {
var stick = new Stick();
do {
stick.x = Math.random() * 2048;
stick.y = Math.random() * 1000;
} while (sticks.some(function (s) {
return Math.abs(s.x - stick.x) < 100 && Math.abs(s.y - stick.y) < 100;
}) || stones && stones.some(function (s) {
return Math.abs(s.x - stick.x) < 100 && Math.abs(s.y - stick.y) < 100;
}));
sticks.push(stick);
game.addChild(stick);
}
// Initialize stones
var stones = [];
for (var i = 0; i < 10; i++) {
var stone = game.addChild(new Stone());
do {
stone.x = Math.random() * 2048;
stone.y = Math.random() * 2732;
} while (stones.some(function (s) {
return Math.abs(s.x - stone.x) < 100 && Math.abs(s.y - stone.y) < 100;
}) || sticks.some(function (s) {
return Math.abs(s.x - stone.x) < 100 && Math.abs(s.y - stone.y) < 100;
}));
stones.push(stone);
}
// Initialize ores
var ores = [];
for (var i = 0; i < 5; i++) {
var ore = game.addChild(new Ore());
do {
ore.x = Math.random() * 2048;
ore.y = Math.random() * 2732;
} while (ores.some(function (o) {
return Math.abs(o.x - ore.x) < 100 && Math.abs(o.y - ore.y) < 100;
}) || stones.some(function (s) {
return Math.abs(s.x - ore.x) < 100 && Math.abs(s.y - ore.y) < 100;
}) || sticks.some(function (s) {
return Math.abs(s.x - ore.x) < 100 && Math.abs(s.y - ore.y) < 100;
}));
ores.push(ore);
}
// Initialize crafting bullets
var craftBullets = [];
for (var i = 0; i < 5; i++) {
var craftBullet = game.addChild(new CraftBullet());
craftBullet.x = Math.random() * 2048;
craftBullet.y = Math.random() * 2732;
craftBullets.push(craftBullet);
}
// Handle player movement
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
};
// Game update loop
game.update = function () {
// Update enemies
for (var i = 0; i < enemies.length; i++) {
enemies[i].update();
if (player.intersects(enemies[i])) {
// Handle player collision with enemy
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
// Handle enemy collision with the weapon and bullets
for (var j = 0; j < sticks.length; j++) {
if (enemies[i] && sticks[j] && enemies[i].intersects(sticks[j])) {
// Enemy is damaged by the weapon
enemies[i].destroy();
enemies.splice(i, 1);
i--;
}
}
for (var j = 0; j < bullets.length; j++) {
if (enemies[i].intersects(bullets[j])) {
if (enemies[i] instanceof Boss && bullets[j] instanceof SwordBullet) {
// Remove the boss from the game when hit by a sword bullet
var bossX = enemies[i].x;
var bossY = enemies[i].y;
enemies[i].destroy();
enemies.splice(i, 1);
i--;
bullets[j].destroy();
bullets.splice(j, 1);
bossDefeated = true;
// Generate 'A Kneeling Boss' NPC at the boss's location
var kneelingBoss = new KneelingBoss();
kneelingBoss.x = bossX;
kneelingBoss.y = bossY;
game.addChild(kneelingBoss);
break;
} else if (enemies[i] instanceof Boss) {
// Destroy ordinary bullets when they hit the boss
bullets[j].destroy();
bullets.splice(j, 1);
j--;
} else {
// Destroy regular enemies when hit by any bullet
enemies[i].destroy();
enemies.splice(i, 1);
i--;
bullets[j].destroy();
bullets.splice(j, 1);
break;
}
}
}
}
// Create a new boss when all enemies are destroyed
if (enemies.length === 0 && !bossDefeated) {
var boss = new Boss();
boss.x = Math.random() * 2048;
boss.y = Math.random() * 2732;
enemies.push(boss);
game.addChild(boss);
}
// Check if the boss is defeated
if (bossDefeated) {
// Prevent new enemies from appearing
// Check interaction with kneeling boss
if (player.intersects(kneelingBoss)) {
// Trigger two choices for endings
triggerEndings();
}
// End the game and declare victory
console.log("Congratulations! You have defeated the boss and won the game!");
var winText = new Text2('You win', {
size: 200,
fill: "#00ff00"
});
winText.anchor.set(0.5, 0.5);
winText.x = 2048 / 2;
winText.y = 2732 / 2;
game.addChild(winText);
// LK.showGameOver(); // Removed to prevent game over screen when player wins
return;
}
// Update stick weapons
for (var i = 0; i < sticks.length; i++) {
sticks[i].update();
if (player.intersects(sticks[i])) {
// Handle player picking up a stick
sticks[i].destroy();
sticks.splice(i, 1);
i--;
}
}
// Update stone weapons
for (var i = 0; i < stones.length; i++) {
stones[i].update();
if (player.intersects(stones[i])) {
// Handle player picking up a stone
stones[i].destroy();
stones.splice(i, 1);
i--;
}
}
// Update ores
for (var i = 0; i < ores.length; i++) {
ores[i].update();
if (player.intersects(ores[i])) {
if (!ores[i].collectionStartTime) {
ores[i].collectionStartTime = Date.now();
} else if (Date.now() - ores[i].collectionStartTime >= 1500) {
// Handle player collecting ore after 1.5 seconds
ores[i].destroy();
ores.splice(i, 1);
i--;
}
} else {
ores[i].collectionStartTime = null; // Reset collection time if not intersecting
}
}
// Check if all ores are collected
if (ores.length === 0 && !bossDefeated) {
// Player fires a sword bullet only once
if (!swordFired) {
var swordBullet = new SwordBullet();
swordBullet.x = player.x;
swordBullet.y = player.y;
bullets.push(swordBullet);
game.addChild(swordBullet);
swordFired = true;
}
}
// Update crafting bullets
for (var i = 0; i < craftBullets.length; i++) {
craftBullets[i].update();
if (player.intersects(craftBullets[i])) {
// Handle player crafting a bullet
craftBullets[i].destroy();
craftBullets.splice(i, 1);
i--;
// Player fires a regular bullet
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
bullets.push(bullet);
game.addChild(bullet);
}
}
}; /****
* Classes
****/
// Class for boss
var Boss = Container.expand(function () {
var self = Container.call(this);
var bossGraphics = self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 2;
self.direction = Math.random() * 2 * Math.PI; // Random direction in radians
self.update = function () {
// Calculate direction towards the player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the player
self.x += dx * self.speed;
self.y += dy * self.speed;
};
});
// 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 () {
// Calculate direction towards the enemy
if (enemies.length > 0) {
var dx = enemies[0].x - self.x;
var dy = enemies[0].y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the enemy
self.x += dx * self.speed;
self.y += dy * self.speed;
}
// Rotate the bullet
bulletGraphics.rotation += 0.1;
};
});
// Class for crafting bullets
var CraftBullet = Container.expand(function () {
var self = Container.call(this);
var stone = self.attachAsset('stone', {
anchorX: 0.5,
anchorY: 0.5
});
var stick = self.attachAsset('stick', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// CraftBullet update logic
};
});
// 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.direction = Math.random() * 2 * Math.PI; // Random direction in radians
self.update = function () {
// Calculate direction towards the player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the player
self.x += dx * self.speed;
self.y += dy * self.speed;
};
});
// Class for NPC 'A Kneeling Boss'
var KneelingBoss = Container.expand(function () {
var self = Container.call(this);
var kneelingBossGraphics = self.attachAsset('kneelingBoss', {
anchorX: 0.5,
anchorY: 0.5
});
// Additional properties or methods for the kneeling boss can be added here
});
// Class for ores
var Ore = Container.expand(function () {
var self = Container.call(this);
var oreGraphics = self.attachAsset('ore', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Ore update logic
};
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// 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
};
});
// Class for Resource Page
var ResourcePage = Container.expand(function () {
var self = Container.call(this);
var resourceGraphics = self.attachAsset('resource', {
anchorX: 0.5,
anchorY: 0.5
});
resourceGraphics.x = 2048 / 2;
resourceGraphics.y = 2732 / 2;
self.addChild(resourceGraphics);
self.interactive = true;
self.on('down', function () {
console.log("Resource selected");
self.destroy();
game.start();
});
});
// Class for Start Screen
var StartScreen = Container.expand(function () {
var self = Container.call(this);
var startScreenImage = self.attachAsset('startScreen', {
anchorX: 0.5,
anchorY: 0.5
});
startScreenImage.x = 2048 / 2;
startScreenImage.y = 2732 / 2;
self.addChild(startScreenImage);
self.interactive = true;
self.on('down', function () {
self.destroy();
game.start();
});
});
// Class for stick weapon
var Stick = Container.expand(function () {
var self = Container.call(this);
var stickGraphics = self.attachAsset('stick', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Stick update logic
// Make the stick surround the player
self.x = player.x;
self.y = player.y;
};
});
// Class for stones
var Stone = Container.expand(function () {
var self = Container.call(this);
var stoneGraphics = self.attachAsset('stone', {
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
// Stone update logic
};
});
// Class for sword bullets
var SwordBullet = Container.expand(function () {
var self = Container.call(this);
var swordGraphics = self.attachAsset('sword', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
// Calculate direction towards the boss
if (enemies.length > 0 && enemies[0] instanceof Boss) {
var dx = enemies[0].x - self.x;
var dy = enemies[0].y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
// Normalize the direction vector (dx and dy)
dx /= distance;
dy /= distance;
// Move towards the boss
self.x += dx * self.speed;
self.y += dy * self.speed;
}
// Rotate the sword bullet
swordGraphics.rotation += 0.1;
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Add resource page
var resourcePage = new ResourcePage();
game.addChild(resourcePage);
// Ensure game does not start until start screen is dismissed
game.start = function () {
// game.resume(); // Removed as it is not a valid function
};
// Function to trigger two endings
function triggerEndings() {
// Display choices to the player
var choice = prompt("Choose your ending: 1 for Ending A, 2 for Ending B");
if (choice === "1") {
// Trigger Ending A
console.log("Ending A triggered");
// Add logic for Ending A
} else if (choice === "2") {
// Trigger Ending B
console.log("Ending B triggered");
// Add logic for Ending B
} else {
console.log("Invalid choice");
}
}
// Add background image to the game
var background = LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5
});
background.x = 2048 / 2;
background.y = 2732 / 2;
game.addChild(background);
// Play background music
LK.playMusic('dee');
// Initialize bullets
var bullets = [];
// Initialize player
var player = game.addChild(new Player());
// Track if the sword has been fired
var swordFired = false;
player.x = 2048 / 2;
player.y = 2732 - 200;
// Initialize enemies
var enemies = [];
var bossDefeated = false;
for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
var side = Math.floor(Math.random() * 4); // Random side (0: top, 1: right, 2: bottom, 3: left)
switch (side) {
case 0:
enemy.x = Math.random() * 2048;
enemy.y = 0;
break;
case 1:
enemy.x = 2048;
enemy.y = Math.random() * 2732;
break;
case 2:
enemy.x = Math.random() * 2048;
enemy.y = 2732;
break;
case 3:
enemy.x = 0;
enemy.y = Math.random() * 2732;
break;
}
enemies.push(enemy);
game.addChild(enemy);
}
// Initialize stick weapons
var sticks = [];
for (var i = 0; i < 5; i++) {
var stick = new Stick();
do {
stick.x = Math.random() * 2048;
stick.y = Math.random() * 1000;
} while (sticks.some(function (s) {
return Math.abs(s.x - stick.x) < 100 && Math.abs(s.y - stick.y) < 100;
}) || stones && stones.some(function (s) {
return Math.abs(s.x - stick.x) < 100 && Math.abs(s.y - stick.y) < 100;
}));
sticks.push(stick);
game.addChild(stick);
}
// Initialize stones
var stones = [];
for (var i = 0; i < 10; i++) {
var stone = game.addChild(new Stone());
do {
stone.x = Math.random() * 2048;
stone.y = Math.random() * 2732;
} while (stones.some(function (s) {
return Math.abs(s.x - stone.x) < 100 && Math.abs(s.y - stone.y) < 100;
}) || sticks.some(function (s) {
return Math.abs(s.x - stone.x) < 100 && Math.abs(s.y - stone.y) < 100;
}));
stones.push(stone);
}
// Initialize ores
var ores = [];
for (var i = 0; i < 5; i++) {
var ore = game.addChild(new Ore());
do {
ore.x = Math.random() * 2048;
ore.y = Math.random() * 2732;
} while (ores.some(function (o) {
return Math.abs(o.x - ore.x) < 100 && Math.abs(o.y - ore.y) < 100;
}) || stones.some(function (s) {
return Math.abs(s.x - ore.x) < 100 && Math.abs(s.y - ore.y) < 100;
}) || sticks.some(function (s) {
return Math.abs(s.x - ore.x) < 100 && Math.abs(s.y - ore.y) < 100;
}));
ores.push(ore);
}
// Initialize crafting bullets
var craftBullets = [];
for (var i = 0; i < 5; i++) {
var craftBullet = game.addChild(new CraftBullet());
craftBullet.x = Math.random() * 2048;
craftBullet.y = Math.random() * 2732;
craftBullets.push(craftBullet);
}
// Handle player movement
game.move = function (x, y, obj) {
player.x = x;
player.y = y;
};
// Game update loop
game.update = function () {
// Update enemies
for (var i = 0; i < enemies.length; i++) {
enemies[i].update();
if (player.intersects(enemies[i])) {
// Handle player collision with enemy
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
// Handle enemy collision with the weapon and bullets
for (var j = 0; j < sticks.length; j++) {
if (enemies[i] && sticks[j] && enemies[i].intersects(sticks[j])) {
// Enemy is damaged by the weapon
enemies[i].destroy();
enemies.splice(i, 1);
i--;
}
}
for (var j = 0; j < bullets.length; j++) {
if (enemies[i].intersects(bullets[j])) {
if (enemies[i] instanceof Boss && bullets[j] instanceof SwordBullet) {
// Remove the boss from the game when hit by a sword bullet
var bossX = enemies[i].x;
var bossY = enemies[i].y;
enemies[i].destroy();
enemies.splice(i, 1);
i--;
bullets[j].destroy();
bullets.splice(j, 1);
bossDefeated = true;
// Generate 'A Kneeling Boss' NPC at the boss's location
var kneelingBoss = new KneelingBoss();
kneelingBoss.x = bossX;
kneelingBoss.y = bossY;
game.addChild(kneelingBoss);
break;
} else if (enemies[i] instanceof Boss) {
// Destroy ordinary bullets when they hit the boss
bullets[j].destroy();
bullets.splice(j, 1);
j--;
} else {
// Destroy regular enemies when hit by any bullet
enemies[i].destroy();
enemies.splice(i, 1);
i--;
bullets[j].destroy();
bullets.splice(j, 1);
break;
}
}
}
}
// Create a new boss when all enemies are destroyed
if (enemies.length === 0 && !bossDefeated) {
var boss = new Boss();
boss.x = Math.random() * 2048;
boss.y = Math.random() * 2732;
enemies.push(boss);
game.addChild(boss);
}
// Check if the boss is defeated
if (bossDefeated) {
// Prevent new enemies from appearing
// Check interaction with kneeling boss
if (player.intersects(kneelingBoss)) {
// Trigger two choices for endings
triggerEndings();
}
// End the game and declare victory
console.log("Congratulations! You have defeated the boss and won the game!");
var winText = new Text2('You win', {
size: 200,
fill: "#00ff00"
});
winText.anchor.set(0.5, 0.5);
winText.x = 2048 / 2;
winText.y = 2732 / 2;
game.addChild(winText);
// LK.showGameOver(); // Removed to prevent game over screen when player wins
return;
}
// Update stick weapons
for (var i = 0; i < sticks.length; i++) {
sticks[i].update();
if (player.intersects(sticks[i])) {
// Handle player picking up a stick
sticks[i].destroy();
sticks.splice(i, 1);
i--;
}
}
// Update stone weapons
for (var i = 0; i < stones.length; i++) {
stones[i].update();
if (player.intersects(stones[i])) {
// Handle player picking up a stone
stones[i].destroy();
stones.splice(i, 1);
i--;
}
}
// Update ores
for (var i = 0; i < ores.length; i++) {
ores[i].update();
if (player.intersects(ores[i])) {
if (!ores[i].collectionStartTime) {
ores[i].collectionStartTime = Date.now();
} else if (Date.now() - ores[i].collectionStartTime >= 1500) {
// Handle player collecting ore after 1.5 seconds
ores[i].destroy();
ores.splice(i, 1);
i--;
}
} else {
ores[i].collectionStartTime = null; // Reset collection time if not intersecting
}
}
// Check if all ores are collected
if (ores.length === 0 && !bossDefeated) {
// Player fires a sword bullet only once
if (!swordFired) {
var swordBullet = new SwordBullet();
swordBullet.x = player.x;
swordBullet.y = player.y;
bullets.push(swordBullet);
game.addChild(swordBullet);
swordFired = true;
}
}
// Update crafting bullets
for (var i = 0; i < craftBullets.length; i++) {
craftBullets[i].update();
if (player.intersects(craftBullets[i])) {
// Handle player crafting a bullet
craftBullets[i].destroy();
craftBullets.splice(i, 1);
i--;
// Player fires a regular bullet
var bullet = new Bullet();
bullet.x = player.x;
bullet.y = player.y;
bullets.push(bullet);
game.addChild(bullet);
}
}
};
one wooden sticks. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.amazon.eg%2F-%2Fen%2FOutdoor-Essentials-Faux-Rock-Small%2Fdp%2FB00NOP1MVO&psig=AOvVaw2V1WQg1qj9oUmhvM4bQiYI&ust=1732068079014000&source=images&cd=vfe&opi=89978449&ved=0CBQQjRxqFwoTCPCXssam54kDFQAAAAAdAAAAABAJ. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
https://www.google.com/url?sa=i&url=https%3A%2F%2Fcryofall.fandom.com%2Fwiki%2FStone_Axe&psig=AOvVaw3xJUeebmFvEdpWSjI8cOsl&ust=1732068916220000&source=images&cd=vfe&opi=89978449&ved=0CBQQjRxqFwoTCJjY7NSp54kDFQAAAAAdAAAAABAE. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Powerful humanoid creature. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
One Creature is similar to humans. They live in places with nuclear radiation, have a primitive lifestyle, and have a certain degree of self-awareness. The appearance is not scary. Single Game Texture. In-Game asset. 2d.
One rare ore. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Make his body look destroyed, also make it cover with some green liquid
Red Blade Battle Axe. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
In a wasteland, there are some green plants and some animal bones around.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A humans who traveled through time came from World War 3. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.