/**** * Classes ****/ var Boss = Container.expand(function () { var self = Container.call(this); self.heal = function () { var healAmount = Math.floor(Math.random() * (30 - 15 + 1)) + 15; self.health += healAmount; LK.effects.flashObject(self, 0x00ff00, 1000); if (self.health <= 0) { LK.showGameOver(); return; } }; self.attack = function (target) { target.health -= 20; LK.effects.flashObject(target, 0xff0000, 1000); }; self.applyPoison = function (target) { target.poisoned++; LK.effects.flashObject(target, 0x800080, 1000); }; self.health = 300; self.poisoned = 0; self.attachAsset('boss', { anchorX: 0.5, anchorY: 0.5 }); self.takeDamage = function (amount) { self.health -= amount * (1 + 0.1 * self.poisoned); LK.effects.flashObject(self, 0xff0000, 1000); }; }); var HealthPotion = Container.expand(function () { var self = Container.call(this); self.attachAsset('healthPotion', { anchorX: 0.5, anchorY: 0.5 }); }); var Hero = Container.expand(function () { var self = Container.call(this); self.health = 100; self.poisoned = 0; self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.attack = function (target) { target.takeDamage(60); LK.effects.flashObject(target, 0xff0000, 1000); }; self.heal = function () { var healAmount = Math.floor(Math.random() * (30 - 15 + 1)) + 15; self.health += healAmount; LK.effects.flashObject(self, 0x00ff00, 1000); if (self.health <= 0) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }; self.applyPoison = function (target) { target.poisoned++; LK.effects.flashObject(target, 0x800080, 1000); }; }); var PoisonVial = Container.expand(function () { var self = Container.call(this); self.attachAsset('poisonVial', { anchorX: 0.5, anchorY: 0.5 }); }); var Sword = Container.expand(function () { var self = Container.call(this); self.attachAsset('sword', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game(); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 })); background.x = 1024; background.y = 1366; // Initialize assets for the game var poisonVialButton = game.addChild(new PoisonVial()); poisonVialButton.x = 1548; poisonVialButton.y = 2732 - 200; poisonVialButton.interactive = true; poisonVialButton.on('down', function () { if (!actionTaken) { hero.applyPoison(boss); bossHealthText.setText('Boss Health: ' + boss.health); actionTaken = true; endTurnButton.tint = 0x00ff00; } }); var healthPotionButton = game.addChild(new HealthPotion()); healthPotionButton.x = 1800; healthPotionButton.y = 2732 - 200; healthPotionButton.interactive = true; var actionTaken = false; healthPotionButton.on('down', function () { if (!actionTaken) { hero.heal(); heroHealthText.setText('Hero Health: ' + hero.health); actionTaken = true; endTurnButton.tint = 0x00ff00; } }); var swordButton = game.addChild(new Sword()); swordButton.x = 500; swordButton.y = 2732 - 200; swordButton.interactive = true; swordButton.on('down', function () { if (!actionTaken) { hero.attack(boss); bossHealthText.setText('Boss Health: ' + boss.health); actionTaken = true; endTurnButton.tint = 0x00ff00; } }); var endTurnButton = game.addChild(new LK.getAsset('endTurnButtonArrow', { anchorX: 0.5, anchorY: 0.5 })); LK.gui.right.addChild(endTurnButton); endTurnButton.y = 200; endTurnButton.x = -200; endTurnButton.interactive = true; endTurnButton.on('down', function () { turns++; turnText.setText('Turn: ' + turns); actionTaken = false; endTurnButton.tint = 0xffffff; if (turns >= 11 && boss.health > 0) { LK.effects.flashScreen(0xff0000, 1000); var youLose = game.addChild(LK.getAsset('youLose', { anchorX: 0.5, anchorY: 0.5 })); youLose.x = hero.x; youLose.y = hero.y; LK.showGameOver(); } if (boss.health <= 0 && turns < 11) { LK.effects.flashScreen(0x00ff00, 1000); var youWin = game.addChild(LK.getAsset('youWin', { anchorX: 0.5, anchorY: 0.5 })); youWin.x = hero.x; youWin.y = hero.y; LK.showGameOver('You Win'); } var bossAction = Math.floor(Math.random() * 3); switch (bossAction) { case 0: boss.heal(); bossHealthText.setText('Boss Health: ' + boss.health); break; case 1: boss.attack(hero); heroHealthText.setText('Hero Health: ' + hero.health); break; case 2: boss.applyPoison(hero); break; } }); var turnText = new Text2('Turn: 1', { size: 50, fill: '#ffffff', stroke: '#000000', strokeThickness: 10 }); LK.gui.top.addChild(turnText); turnText.x = 200; var heroHealthText = new Text2('Hero Health: 100', { size: 50, fill: '#00ff00', stroke: '#ffffff', strokeThickness: 10 }); LK.gui.left.addChild(heroHealthText); var bossHealthText = new Text2('Boss Health: 300', { size: 50, fill: '#ff0000', stroke: '#ffffff', strokeThickness: 10 }); LK.gui.left.addChild(bossHealthText); bossHealthText.y = heroHealthText.y - 150; var hero = game.addChild(new Hero()); hero.x = 1024; // Center horizontally hero.y = 2732 - 200; // Position at the bottom var boss = game.addChild(new Boss()); boss.x = 1024; // Center horizontally boss.y = 200; // Position at the top var turns = 1; var maxTurns = 10; // Game logic LK.on('tick', function () { // Game logic to be executed every frame // This example does not include the full game logic, which would handle turns, attacks, and game over conditions. }); // Example of handling a touch event to attack // This is a simplified example. The actual game would need more detailed logic for handling attacks, healing, poison effects, and determining the game's end.
/****
* Classes
****/
var Boss = Container.expand(function () {
var self = Container.call(this);
self.heal = function () {
var healAmount = Math.floor(Math.random() * (30 - 15 + 1)) + 15;
self.health += healAmount;
LK.effects.flashObject(self, 0x00ff00, 1000);
if (self.health <= 0) {
LK.showGameOver();
return;
}
};
self.attack = function (target) {
target.health -= 20;
LK.effects.flashObject(target, 0xff0000, 1000);
};
self.applyPoison = function (target) {
target.poisoned++;
LK.effects.flashObject(target, 0x800080, 1000);
};
self.health = 300;
self.poisoned = 0;
self.attachAsset('boss', {
anchorX: 0.5,
anchorY: 0.5
});
self.takeDamage = function (amount) {
self.health -= amount * (1 + 0.1 * self.poisoned);
LK.effects.flashObject(self, 0xff0000, 1000);
};
});
var HealthPotion = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('healthPotion', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Hero = Container.expand(function () {
var self = Container.call(this);
self.health = 100;
self.poisoned = 0;
self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
self.attack = function (target) {
target.takeDamage(60);
LK.effects.flashObject(target, 0xff0000, 1000);
};
self.heal = function () {
var healAmount = Math.floor(Math.random() * (30 - 15 + 1)) + 15;
self.health += healAmount;
LK.effects.flashObject(self, 0x00ff00, 1000);
if (self.health <= 0) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
};
self.applyPoison = function (target) {
target.poisoned++;
LK.effects.flashObject(target, 0x800080, 1000);
};
});
var PoisonVial = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('poisonVial', {
anchorX: 0.5,
anchorY: 0.5
});
});
var Sword = Container.expand(function () {
var self = Container.call(this);
self.attachAsset('sword', {
anchorX: 0.5,
anchorY: 0.5
});
});
/****
* Initialize Game
****/
var game = new LK.Game();
/****
* Game Code
****/
var background = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5
}));
background.x = 1024;
background.y = 1366;
// Initialize assets for the game
var poisonVialButton = game.addChild(new PoisonVial());
poisonVialButton.x = 1548;
poisonVialButton.y = 2732 - 200;
poisonVialButton.interactive = true;
poisonVialButton.on('down', function () {
if (!actionTaken) {
hero.applyPoison(boss);
bossHealthText.setText('Boss Health: ' + boss.health);
actionTaken = true;
endTurnButton.tint = 0x00ff00;
}
});
var healthPotionButton = game.addChild(new HealthPotion());
healthPotionButton.x = 1800;
healthPotionButton.y = 2732 - 200;
healthPotionButton.interactive = true;
var actionTaken = false;
healthPotionButton.on('down', function () {
if (!actionTaken) {
hero.heal();
heroHealthText.setText('Hero Health: ' + hero.health);
actionTaken = true;
endTurnButton.tint = 0x00ff00;
}
});
var swordButton = game.addChild(new Sword());
swordButton.x = 500;
swordButton.y = 2732 - 200;
swordButton.interactive = true;
swordButton.on('down', function () {
if (!actionTaken) {
hero.attack(boss);
bossHealthText.setText('Boss Health: ' + boss.health);
actionTaken = true;
endTurnButton.tint = 0x00ff00;
}
});
var endTurnButton = game.addChild(new LK.getAsset('endTurnButtonArrow', {
anchorX: 0.5,
anchorY: 0.5
}));
LK.gui.right.addChild(endTurnButton);
endTurnButton.y = 200;
endTurnButton.x = -200;
endTurnButton.interactive = true;
endTurnButton.on('down', function () {
turns++;
turnText.setText('Turn: ' + turns);
actionTaken = false;
endTurnButton.tint = 0xffffff;
if (turns >= 11 && boss.health > 0) {
LK.effects.flashScreen(0xff0000, 1000);
var youLose = game.addChild(LK.getAsset('youLose', {
anchorX: 0.5,
anchorY: 0.5
}));
youLose.x = hero.x;
youLose.y = hero.y;
LK.showGameOver();
}
if (boss.health <= 0 && turns < 11) {
LK.effects.flashScreen(0x00ff00, 1000);
var youWin = game.addChild(LK.getAsset('youWin', {
anchorX: 0.5,
anchorY: 0.5
}));
youWin.x = hero.x;
youWin.y = hero.y;
LK.showGameOver('You Win');
}
var bossAction = Math.floor(Math.random() * 3);
switch (bossAction) {
case 0:
boss.heal();
bossHealthText.setText('Boss Health: ' + boss.health);
break;
case 1:
boss.attack(hero);
heroHealthText.setText('Hero Health: ' + hero.health);
break;
case 2:
boss.applyPoison(hero);
break;
}
});
var turnText = new Text2('Turn: 1', {
size: 50,
fill: '#ffffff',
stroke: '#000000',
strokeThickness: 10
});
LK.gui.top.addChild(turnText);
turnText.x = 200;
var heroHealthText = new Text2('Hero Health: 100', {
size: 50,
fill: '#00ff00',
stroke: '#ffffff',
strokeThickness: 10
});
LK.gui.left.addChild(heroHealthText);
var bossHealthText = new Text2('Boss Health: 300', {
size: 50,
fill: '#ff0000',
stroke: '#ffffff',
strokeThickness: 10
});
LK.gui.left.addChild(bossHealthText);
bossHealthText.y = heroHealthText.y - 150;
var hero = game.addChild(new Hero());
hero.x = 1024; // Center horizontally
hero.y = 2732 - 200; // Position at the bottom
var boss = game.addChild(new Boss());
boss.x = 1024; // Center horizontally
boss.y = 200; // Position at the top
var turns = 1;
var maxTurns = 10;
// Game logic
LK.on('tick', function () {
// Game logic to be executed every frame
// This example does not include the full game logic, which would handle turns, attacks, and game over conditions.
});
// Example of handling a touch event to attack
// This is a simplified example. The actual game would need more detailed logic for handling attacks, healing, poison effects, and determining the game's end.
Heroic wizard knight wearing knight armor with a star pattern and wielding a sword.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Health potion button.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Poison vial button.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Golden glittery magic sword button.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Giant muscular evil wizard with purple skin and a menacing scowl sitting in a black throne.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A glowing horizontal arrow button that says "End Turn".. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Background seen from above showing the long vertical black throne room hallway of the dark wizard king.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"You Lose" written in blood.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"You Win" written in glittering holy golden light.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Empty futuristic black application window box.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.