/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ActionButton = Container.expand(function (text, action) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('actionButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 24,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.action = action;
self.down = function (x, y, obj) {
if (self.action) {
self.action();
}
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.lastX = 0;
self.lastY = 0;
self.update = function () {
self.lastX = self.x;
self.lastY = self.y;
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('kris', {
anchorX: 0.5,
anchorY: 1.0
});
self.maxHP = 100;
self.currentHP = 100;
self.takeDamage = function (amount) {
self.currentHP = Math.max(0, self.currentHP - amount);
LK.effects.flashObject(characterGraphics, 0xff0000, 500);
LK.getSound('hit').play();
};
return self;
});
var DamageNumber = Container.expand(function (damage, color) {
var self = Container.call(this);
var damageText = new Text2(damage.toString(), {
size: 36,
fill: color
});
damageText.anchor.set(0.5, 0.5);
self.addChild(damageText);
// Animate damage number floating up and fading out
tween(self, {
y: self.y - 80,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
return self;
});
var GiantBall = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
ballGraphics.width = 80;
ballGraphics.height = 80;
ballGraphics.tint = 0x444444;
self.speedY = 0;
self.bouncing = false;
self.bounceCount = 0;
self.update = function () {
if (!self.bouncing) {
self.speedY += 0.5; // Gravity
self.y += self.speedY;
// Check if hit bottom of battle box
if (self.y >= battleBox.y + 180) {
self.y = battleBox.y + 180;
self.speedY = -self.speedY * 0.7; // Bounce with energy loss
self.bounceCount++;
self.bouncing = true;
LK.setTimeout(function () {
self.bouncing = false;
}, 100);
}
}
};
return self;
});
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heartGraphics.rotation = Math.PI / 4; // Diamond shape
heartGraphics.width = 40; // Make heart bigger
heartGraphics.height = 40;
// Add glow effect
LK.effects.flashObject(heartGraphics, 0xff0000, 100, true); // Continuous red glow
return self;
});
var LaserBeam = Container.expand(function () {
var self = Container.call(this);
var laserGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
laserGraphics.width = 600; // Full width of battle box
laserGraphics.height = 15;
laserGraphics.tint = 0xff0000; // Red laser
self.warned = false;
self.active = false;
self.warningTime = 0;
self.activeTime = 0;
self.update = function () {
if (!self.warned) {
// Warning phase - flash red
laserGraphics.alpha = 0.3 + Math.sin(LK.ticks * 0.3) * 0.2;
self.warningTime++;
if (self.warningTime >= 120) {
// 2 seconds warning
self.warned = true;
self.active = true;
laserGraphics.alpha = 1;
laserGraphics.tint = 0xffffff; // Bright white when active
}
} else if (self.active) {
self.activeTime++;
if (self.activeTime >= 60) {
// Active for 1 second
self.active = false;
laserGraphics.alpha = 0; // Make invisible but don't destroy yet
}
}
};
return self;
});
var Monster = Container.expand(function () {
var self = Container.call(this);
var monsterGraphics = self.attachAsset('monster', {
anchorX: 0.5,
anchorY: 1.0
});
self.maxHP = 8500;
self.currentHP = 8500;
self.takeDamage = function (amount) {
self.currentHP = Math.max(0, self.currentHP - amount);
LK.effects.flashObject(monsterGraphics, 0xff0000, 500);
LK.getSound('hit').play();
};
return self;
});
var Spell = Container.expand(function () {
var self = Container.call(this);
var spellGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
spellGraphics.width = 60;
spellGraphics.height = 60;
spellGraphics.tint = 0x9933ff;
self.warned = false;
self.exploded = false;
self.update = function () {
if (!self.warned) {
// Flash purple warning
spellGraphics.alpha = 0.5;
self.warned = true;
LK.setTimeout(function () {
if (!self.exploded) {
self.exploded = true;
spellGraphics.width = 120;
spellGraphics.height = 120;
spellGraphics.alpha = 1;
spellGraphics.tint = 0xff6600;
}
}, 1500);
}
};
return self;
});
var Sword = Container.expand(function () {
var self = Container.call(this);
var swordGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
swordGraphics.width = 40;
swordGraphics.height = 100;
swordGraphics.tint = 0xcccccc;
self.warned = false;
self.falling = false;
self.speed = 0;
self.update = function () {
if (!self.warned) {
// Flash red warning
swordGraphics.tint = 0xff0000;
self.warned = true;
LK.setTimeout(function () {
self.falling = true;
self.speed = 8;
swordGraphics.tint = 0xcccccc;
}, 1000);
}
if (self.falling) {
self.y += self.speed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Create stone wall background for menu
var stoneWallBackground = game.addChild(LK.getAsset('stoneWall', {
anchorX: 0,
anchorY: 0
}));
stoneWallBackground.x = 0;
stoneWallBackground.y = 0;
stoneWallBackground.alpha = 0.8;
// Add door to the stone wall
var doorBackground = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 1.0
}));
doorBackground.x = 1024;
doorBackground.y = 1800;
// Create blue stripe background pattern (behind stone wall) - hidden in menu
for (var stripe = 0; stripe < 20; stripe++) {
var blueStripe = game.addChild(LK.getAsset('blueStripe', {
anchorX: 0,
anchorY: 0
}));
blueStripe.x = 0;
blueStripe.y = stripe * 100;
blueStripe.alpha = 0.3;
blueStripe.visible = false; // Hidden in menu
}
// Start with menu music and dinosaur laugh
LK.playMusic('menuMusic');
LK.setTimeout(function () {
LK.getSound('dinosaurLaugh').play();
}, 2000); // Play dinosaur laugh after 2 seconds
// Game state
var gameState = 'menu'; // 'menu', 'playerTurn', 'enemyTurn', 'gameOver'
var turnTimer = 0;
var attackTimer = 0;
var bullets = [];
var dragHeart = false;
var forgivenessLevel = 0; // 0 to 100
var showingActMenu = false;
var showingDescription = false;
var currentTP = 0; // 0 to 100
var tpMultiplier = 1.0; // Can be increased by lucky clothes
var defending = false;
var showingItemMenu = false;
var inventory = [{
name: 'Hamburger',
heal: 25,
type: 'heal'
}, {
name: 'Lancer Cookie',
heal: 1,
type: 'heal'
}, {
name: 'Cake',
heal: 100,
type: 'heal'
}, {
name: 'Soul Essence',
tp: 35,
type: 'tp'
}, {
name: 'Lucky Clothes',
tpBoost: 10,
type: 'tpBoost'
}, {
name: 'Frozen Hotdog',
heal: 5,
type: 'heal'
}];
// Shuffle inventory order
for (var i = inventory.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = inventory[i];
inventory[i] = inventory[j];
inventory[j] = temp;
}
// Characters
var kris = game.addChild(new Character());
kris.x = 400;
kris.y = 2000;
var monster = game.addChild(new Monster());
monster.x = 1650;
monster.y = 2000;
var heart = game.addChild(new Heart());
heart.x = 1024;
heart.y = 1800;
// Battle box - move to back and make more visible
var battleBox = game.addChild(LK.getAsset('battleBox', {
anchorX: 0.5,
anchorY: 0.5
}));
battleBox.x = 1024;
battleBox.y = 1600;
battleBox.alpha = 0;
battleBox.tint = 0x000000; // Make battle box black
// Move battle box to back so it appears behind all other objects
game.setChildIndex(battleBox, 0);
// Battle box green corners
var cornerTopLeft = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 0,
anchorY: 0
}));
cornerTopLeft.x = battleBox.x - 300;
cornerTopLeft.y = battleBox.y - 200;
var cornerTopRight = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 1,
anchorY: 0
}));
cornerTopRight.x = battleBox.x + 300;
cornerTopRight.y = battleBox.y - 200;
var cornerBottomLeft = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 0,
anchorY: 1
}));
cornerBottomLeft.x = battleBox.x - 300;
cornerBottomLeft.y = battleBox.y + 200;
var cornerBottomRight = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 1,
anchorY: 1
}));
cornerBottomRight.x = battleBox.x + 300;
cornerBottomRight.y = battleBox.y + 200;
// Health bars - Kris health below battle box
var krisHealthBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
krisHealthBg.x = 750;
krisHealthBg.y = 1850;
krisHealthBg.width = 250;
var krisHealthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0
}));
krisHealthBar.x = 752;
krisHealthBar.y = 1852;
krisHealthBar.tint = 0x0066ff; // Blue color
// Add Kris head next to health bar
var krisHead = game.addChild(LK.getAsset('kris', {
anchorX: 0.5,
anchorY: 0.5
}));
krisHead.x = 680;
krisHead.y = 1862;
krisHead.width = 40;
krisHead.height = 40;
// Add Kris name
var krisNameText = new Text2('KRIS', {
size: 24,
fill: 0xFFFFFF
});
krisNameText.anchor.set(0, 0.5);
krisNameText.x = 610;
krisNameText.y = 1862;
game.addChild(krisNameText);
var monsterHealthBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
monsterHealthBg.x = 1640;
monsterHealthBg.y = 200;
var monsterHealthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0
}));
monsterHealthBar.x = 1642;
monsterHealthBar.y = 202;
// Action buttons
var attackButton = game.addChild(new ActionButton('ATTACK', function () {
if (gameState === 'playerTurn') {
performAttack();
}
}));
attackButton.x = 300;
attackButton.y = 2400;
var actButton = game.addChild(new ActionButton('ACT', function () {
if (gameState === 'playerTurn') {
performAct();
}
}));
actButton.x = 550;
actButton.y = 2400;
var itemButton = game.addChild(new ActionButton('ITEM', function () {
if (gameState === 'playerTurn') {
performItem();
}
}));
itemButton.x = 800;
itemButton.y = 2400;
var defendButton = game.addChild(new ActionButton('DEFEND', function () {
if (gameState === 'playerTurn') {
performDefend();
}
}));
defendButton.x = 1050;
defendButton.y = 2400;
var mercyButton = game.addChild(new ActionButton('MERCY', function () {
if (gameState === 'playerTurn') {
performMercy();
}
}));
mercyButton.x = 1300;
mercyButton.y = 2400;
// UI Text
var turnText = new Text2('Your Turn', {
size: 36,
fill: 0xFFFFFF
});
turnText.anchor.set(0.5, 0);
LK.gui.top.addChild(turnText);
var krisHPText = new Text2('HP: 100/100', {
size: 20,
fill: 0xFFFFFF
});
krisHPText.anchor.set(0, 0);
krisHPText.x = 750;
krisHPText.y = 1880;
game.addChild(krisHPText);
var monsterHPText = new Text2('MONSTER HP: 80/80', {
size: 24,
fill: 0xFFFFFF
});
monsterHPText.anchor.set(1, 0);
monsterHPText.x = 1850;
monsterHPText.y = 240;
game.addChild(monsterHPText);
// Menu screen elements
var menuTitle = new Text2('SELECT STARTING HEALTH', {
size: 48,
fill: 0xFFFFFF
});
menuTitle.anchor.set(0.5, 0.5);
menuTitle.x = 1024;
menuTitle.y = 1200;
game.addChild(menuTitle);
var startButton50 = game.addChild(new ActionButton('START WITH 50 HP', function () {
if (gameState === 'menu') {
startGameWithHealth(50);
}
}));
startButton50.x = 1024;
startButton50.y = 1350;
var startButton100 = game.addChild(new ActionButton('START WITH 100 HP', function () {
if (gameState === 'menu') {
startGameWithHealth(100);
}
}));
startButton100.x = 1024;
startButton100.y = 1450;
var startButton120 = game.addChild(new ActionButton('START WITH 120 HP', function () {
if (gameState === 'menu') {
startGameWithHealth(120);
}
}));
startButton120.x = 1024;
startButton120.y = 1550;
// Forgiveness bar
var forgivenessBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
forgivenessBg.x = 900;
forgivenessBg.y = 300;
forgivenessBg.width = 250;
var forgivenessBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0
}));
forgivenessBar.x = 902;
forgivenessBar.y = 302;
forgivenessBar.width = 0;
forgivenessBar.tint = 0xffff00; // Yellow color
var forgivenessText = new Text2('FORGIVENESS: 0%', {
size: 20,
fill: 0xFFFFFF
});
forgivenessText.anchor.set(0, 0);
forgivenessText.x = 900;
forgivenessText.y = 330;
game.addChild(forgivenessText);
// TP bar - positioned on the side
var tpBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
tpBg.x = 100;
tpBg.y = 1000;
tpBg.width = 30;
tpBg.height = 300;
var tpBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 1
}));
tpBar.x = 102;
tpBar.y = 1298;
tpBar.width = 26;
tpBar.height = 0;
tpBar.tint = 0xffff00; // Yellow color
var tpText = new Text2('TP', {
size: 20,
fill: 0xFFFFFF
});
tpText.anchor.set(0.5, 0);
tpText.x = 115;
tpText.y = 950;
game.addChild(tpText);
// Act menu buttons
var descriptionButton = game.addChild(new ActionButton('DESCRIPTION', function () {
if (gameState === 'playerTurn' && showingActMenu) {
showDescription();
}
}));
descriptionButton.x = 400;
descriptionButton.y = 2300;
descriptionButton.visible = false;
var calmButton = game.addChild(new ActionButton('TRY TO CALM', function () {
if (gameState === 'playerTurn' && showingActMenu) {
tryToCalm();
}
}));
calmButton.x = 650;
calmButton.y = 2300;
calmButton.visible = false;
var danceButton = game.addChild(new ActionButton('DANCE (25 TP)', function () {
if (gameState === 'playerTurn' && showingActMenu && currentTP >= 25) {
performDance();
}
}));
danceButton.x = 950;
danceButton.y = 2300;
danceButton.visible = false;
var backButton = game.addChild(new ActionButton('BACK', function () {
if (gameState === 'playerTurn' && (showingActMenu || showingDescription)) {
hideActMenu();
}
}));
backButton.x = 1200;
backButton.y = 2300;
backButton.visible = false;
// Description text
var descriptionTextBox = new Text2('', {
size: 24,
fill: 0xFFFFFF
});
descriptionTextBox.anchor.set(0.5, 0.5);
descriptionTextBox.x = 1024;
descriptionTextBox.y = 2100;
game.addChild(descriptionTextBox);
descriptionTextBox.visible = false;
// Calm attempt text
var calmText = new Text2('', {
size: 24,
fill: 0xFFFFFF
});
calmText.anchor.set(0.5, 0.5);
calmText.x = 1024;
calmText.y = 2150;
game.addChild(calmText);
calmText.visible = false;
// "Can be spared" indicator
var spareIndicator = new Text2('Can be spared', {
size: 20,
fill: 0xffff00
});
spareIndicator.anchor.set(0.5, 0);
spareIndicator.x = mercyButton.x;
spareIndicator.y = mercyButton.y - 40;
game.addChild(spareIndicator);
spareIndicator.visible = false;
// Initially hide action buttons and battle UI
attackButton.visible = false;
actButton.visible = false;
itemButton.visible = false;
defendButton.visible = false;
mercyButton.visible = false;
krisHealthBg.visible = false;
krisHealthBar.visible = false;
krisHead.visible = false;
krisNameText.visible = false;
krisHPText.visible = false;
tpBg.visible = false;
tpBar.visible = false;
tpText.visible = false;
forgivenessBg.visible = false;
forgivenessBar.visible = false;
forgivenessText.visible = false;
// Game functions
function startGameWithHealth(health) {
kris.maxHP = health;
kris.currentHP = health;
gameState = 'playerTurn';
turnText.setText('Your Turn');
menuTitle.visible = false;
startButton50.visible = false;
startButton100.visible = false;
startButton120.visible = false;
// Hide menu background elements
stoneWallBackground.visible = false;
doorBackground.visible = false;
// Show blue stripes in battle
for (var stripe = 0; stripe < 20; stripe++) {
game.children[stripe + 3].visible = true; // Blue stripes are children 3-22
}
// Show battle UI elements
krisHealthBg.visible = true;
krisHealthBar.visible = true;
krisHead.visible = true;
krisNameText.visible = true;
krisHPText.visible = true;
tpBg.visible = true;
tpBar.visible = true;
tpText.visible = true;
forgivenessBg.visible = true;
forgivenessBar.visible = true;
forgivenessText.visible = true;
// Switch to battle music
LK.playMusic('battleMusic');
attackButton.visible = true;
actButton.visible = true;
itemButton.visible = true;
defendButton.visible = true;
mercyButton.visible = true;
}
function performAttack() {
// Kris attack reaction - flash white and scale up briefly
tween(kris, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
LK.effects.flashObject(kris, 0xffffff, 300);
var damage = 25;
monster.takeDamage(damage);
// Show blue damage number
var damageNumber = game.addChild(new DamageNumber(damage, 0x0066ff));
damageNumber.x = monster.x;
damageNumber.y = monster.y - 100;
LK.getSound('attack').play();
if (monster.currentHP <= 0) {
gameState = 'gameOver';
turnText.setText('Victory!');
LK.showYouWin();
return;
}
switchToEnemyTurn();
}
function performAct() {
showActMenu();
}
function showActMenu() {
showingActMenu = true;
showingDescription = false;
// Hide main action buttons
attackButton.visible = false;
actButton.visible = false;
itemButton.visible = false;
defendButton.visible = false;
mercyButton.visible = false;
// Show act menu buttons
descriptionButton.visible = true;
calmButton.visible = true;
danceButton.visible = true;
// Update dance button color based on TP
if (currentTP >= 25) {
danceButton.tint = 0xffffff;
} else {
danceButton.tint = 0x666666;
}
backButton.visible = true;
// Hide any previous text
descriptionTextBox.visible = false;
calmText.visible = false;
}
function hideActMenu() {
showingActMenu = false;
showingDescription = false;
// Show main action buttons
attackButton.visible = true;
actButton.visible = true;
itemButton.visible = true;
defendButton.visible = true;
mercyButton.visible = true;
// Hide act menu buttons
descriptionButton.visible = false;
calmButton.visible = false;
danceButton.visible = false;
backButton.visible = false;
// Hide text
descriptionTextBox.visible = false;
calmText.visible = false;
}
function showDescription() {
showingDescription = true;
descriptionTextBox.setText('DINOSAUR Attack: 10 Defense: 5 HP: 8500\nA dinosaur seeking to no longer be used as a weapon');
descriptionTextBox.visible = true;
}
function tryToCalm() {
// Kris act reaction - subtle side step
tween(kris, {
x: kris.x + 30
}, {
duration: 250,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
x: 400
}, {
duration: 250,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0xffff00, 400);
// Increase forgiveness level
forgivenessLevel = Math.min(100, forgivenessLevel + 10);
updateForgivenessBar();
// Show calm attempt text
calmText.setText('Kris tried to calm Dinosaur. Didn\'t achieve much\nbut Dinosaur calmed down a little');
calmText.visible = true;
// Check if can be spared
if (forgivenessLevel >= 100) {
spareIndicator.visible = true;
mercyButton.tint = 0xffff00;
}
LK.setTimeout(function () {
hideActMenu();
switchToEnemyTurn();
}, 2000);
}
function performDance() {
if (currentTP < 25) return;
// Kris dance reaction - spin and bounce
tween(kris, {
rotation: Math.PI * 2,
y: kris.y - 40
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
rotation: 0,
y: 2000
}, {
duration: 400,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0xff00ff, 800);
// Consume TP
currentTP -= 25;
updateTPBar();
// Increase forgiveness level by 20%
forgivenessLevel = Math.min(100, forgivenessLevel + 20);
updateForgivenessBar();
// Show dance text
calmText.setText('Kris performed a beautiful dance!\nDinosaur was charmed and became much calmer');
calmText.visible = true;
// Check if can be spared
if (forgivenessLevel >= 100) {
spareIndicator.visible = true;
mercyButton.tint = 0xffff00;
}
LK.setTimeout(function () {
hideActMenu();
switchToEnemyTurn();
}, 2500);
}
function performItem() {
showItemMenu();
}
function showItemMenu() {
showingItemMenu = true;
// Hide main action buttons
attackButton.visible = false;
actButton.visible = false;
itemButton.visible = false;
defendButton.visible = false;
mercyButton.visible = false;
// Show item menu
showItemInventory();
}
function hideItemMenu() {
showingItemMenu = false;
// Show main action buttons
attackButton.visible = true;
actButton.visible = true;
itemButton.visible = true;
defendButton.visible = true;
mercyButton.visible = true;
// Hide item buttons
hideItemInventory();
}
function showItemInventory() {
// Create item buttons dynamically
for (var i = 0; i < inventory.length; i++) {
var item = inventory[i];
var itemButton = game.addChild(new ActionButton(item.name, createItemUseFunction(i)));
itemButton.x = 300 + i % 3 * 250;
itemButton.y = 2200 + Math.floor(i / 3) * 80;
itemButton.itemIndex = i;
}
// Add back button
var itemBackButton = game.addChild(new ActionButton('BACK', function () {
hideItemMenu();
}));
itemBackButton.x = 1200;
itemBackButton.y = 2400;
itemBackButton.isItemBack = true;
}
function hideItemInventory() {
// Remove all item buttons
var children = game.children.slice();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.itemIndex !== undefined || child.isItemBack) {
child.destroy();
}
}
}
function createItemUseFunction(itemIndex) {
return function () {
if (gameState === 'playerTurn' && showingItemMenu) {
useItem(itemIndex);
}
};
}
function useItem(itemIndex) {
var item = inventory[itemIndex];
// Kris item reaction - gentle bounce and green flash
tween(kris, {
y: kris.y - 20
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
y: 2000
}, {
duration: 300,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0x00ff00, 500);
if (item.type === 'heal') {
var healAmount = Math.floor(kris.maxHP * item.heal / 100);
kris.currentHP = Math.min(kris.maxHP, kris.currentHP + healAmount);
// Show green healing number
var healNumber = game.addChild(new DamageNumber('+' + healAmount, 0x00ff00));
healNumber.x = kris.x;
healNumber.y = kris.y - 100;
} else if (item.type === 'tp') {
currentTP = Math.min(100, currentTP + item.tp);
updateTPBar();
// Show green TP number
var tpNumber = game.addChild(new DamageNumber('+' + item.tp + ' TP', 0x00ff00));
tpNumber.x = kris.x;
tpNumber.y = kris.y - 100;
} else if (item.type === 'tpBoost') {
tpMultiplier += item.tpBoost / 100;
// Show green boost number
var boostNumber = game.addChild(new DamageNumber('TP Boost +' + item.tpBoost + '%', 0x00ff00));
boostNumber.x = kris.x;
boostNumber.y = kris.y - 100;
}
// Remove item from inventory
inventory.splice(itemIndex, 1);
hideItemMenu();
switchToEnemyTurn();
}
function performDefend() {
// Kris defend reaction - crouch down slightly
tween(kris, {
scaleY: 0.8,
y: kris.y + 20
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
scaleY: 1.0,
y: 2000
}, {
duration: 300,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0x0066ff, 400);
// Set defending flag and gain TP
defending = true;
var tpGain = Math.floor(15 * tpMultiplier);
currentTP = Math.min(100, currentTP + tpGain);
updateTPBar();
// Show green TP gain number
var tpNumber = game.addChild(new DamageNumber('+' + tpGain + ' TP', 0x00ff00));
tpNumber.x = kris.x;
tpNumber.y = kris.y - 100;
switchToEnemyTurn();
}
function performMercy() {
if (forgivenessLevel >= 100) {
gameState = 'gameOver';
turnText.setText('You spared the monster!');
LK.showYouWin();
} else {
switchToEnemyTurn();
}
}
function switchToEnemyTurn() {
gameState = 'enemyTurn';
turnText.setText('Enemy Turn - Dodge!');
turnTimer = 0;
attackTimer = 0;
// Show battle box with high visibility
battleBox.alpha = 0.95;
// Add subtle glow effect to make battle box more visible
LK.effects.flashObject(battleBox, 0x00ff00, 200, true);
// Heart emerges from Kris's chest and moves to battle box
heart.x = kris.x;
heart.y = kris.y - 60; // Start from chest area
tween(heart, {
x: battleBox.x,
y: battleBox.y
}, {
duration: 800,
easing: tween.easeOut
});
}
function switchToPlayerTurn() {
gameState = 'playerTurn';
turnText.setText('Your Turn');
defending = false; // Reset defending flag
// Hide battle box
battleBox.alpha = 0;
// Clear bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].destroy();
bullets.splice(i, 1);
}
// Heart returns to Kris's chest area with animation
tween(heart, {
x: kris.x,
y: kris.y - 60
}, {
duration: 600,
easing: tween.easeIn
});
}
function spawnAttack() {
var attackType = Math.floor(Math.random() * 6) + 1; // Added laser beam attack
var boxLeft = battleBox.x - 300;
var boxRight = battleBox.x + 300;
var boxTop = battleBox.y - 200;
var boxBottom = battleBox.y + 200;
switch (attackType) {
case 1:
// Falling swords
for (var i = 0; i < 3; i++) {
var sword = new Sword();
sword.x = boxLeft + Math.random() * 600;
sword.y = boxTop - 100;
bullets.push(sword);
game.addChild(sword);
}
break;
case 2:
// Random spell explosion
var spell = new Spell();
spell.x = boxLeft + Math.random() * 600;
spell.y = boxTop + Math.random() * 400;
bullets.push(spell);
game.addChild(spell);
break;
case 3:
// White bullets from multiple points
for (var j = 0; j < 6; j++) {
var bullet = new Bullet();
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
bullet.x = boxLeft + Math.random() * 600;
bullet.y = boxTop - 50;
bullet.speedX = (Math.random() - 0.5) * 2;
bullet.speedY = 3 + Math.random() * 2;
break;
case 1:
// Right
bullet.x = boxRight + 50;
bullet.y = boxTop + Math.random() * 400;
bullet.speedX = -3 - Math.random() * 2;
bullet.speedY = (Math.random() - 0.5) * 2;
break;
case 2:
// Bottom
bullet.x = boxLeft + Math.random() * 600;
bullet.y = boxBottom + 50;
bullet.speedX = (Math.random() - 0.5) * 2;
bullet.speedY = -3 - Math.random() * 2;
break;
case 3:
// Left
bullet.x = boxLeft - 50;
bullet.y = boxTop + Math.random() * 400;
bullet.speedX = 3 + Math.random() * 2;
bullet.speedY = (Math.random() - 0.5) * 2;
break;
}
bullets.push(bullet);
game.addChild(bullet);
}
break;
case 4:
// More white bullets
for (var k = 0; k < 8; k++) {
var bullet2 = new Bullet();
bullet2.x = boxLeft + Math.random() * 600;
bullet2.y = boxTop + Math.random() * 400;
var angle = Math.random() * Math.PI * 2;
var speed = 2 + Math.random() * 3;
bullet2.speedX = Math.cos(angle) * speed;
bullet2.speedY = Math.sin(angle) * speed;
bullets.push(bullet2);
game.addChild(bullet2);
}
break;
case 5:
// Giant bouncing ball
var giantBall = new GiantBall();
giantBall.x = boxLeft + Math.random() * 600;
giantBall.y = boxTop - 100;
bullets.push(giantBall);
game.addChild(giantBall);
break;
case 6:
// Laser beam attack
var laserBeam = new LaserBeam();
laserBeam.x = battleBox.x;
laserBeam.y = boxTop + Math.random() * 400; // Random Y position
bullets.push(laserBeam);
game.addChild(laserBeam);
break;
}
}
function updateHealthBars() {
// Update Kris health bar
var krisHealthRatio = kris.currentHP / kris.maxHP;
krisHealthBar.width = 246 * krisHealthRatio;
krisHPText.setText('HP: ' + kris.currentHP + '/' + kris.maxHP);
// Update monster health bar
var monsterHealthRatio = monster.currentHP / monster.maxHP;
monsterHealthBar.width = 200 * monsterHealthRatio;
monsterHPText.setText('MONSTER HP: ' + monster.currentHP + '/' + monster.maxHP);
}
function updateForgivenessBar() {
var forgivenessRatio = forgivenessLevel / 100;
forgivenessBar.width = 246 * forgivenessRatio;
forgivenessText.setText('FORGIVENESS: ' + forgivenessLevel + '%');
}
function updateTPBar() {
var tpRatio = currentTP / 100;
tpBar.height = 296 * tpRatio;
// No need to update text as it just says "TP"
}
// Heart movement
game.move = function (x, y, obj) {
if (gameState === 'enemyTurn' && dragHeart) {
// Constrain heart to battle box
var boxLeft = battleBox.x - 285;
var boxRight = battleBox.x + 285;
var boxTop = battleBox.y - 185;
var boxBottom = battleBox.y + 185;
heart.x = Math.max(boxLeft, Math.min(boxRight, x));
heart.y = Math.max(boxTop, Math.min(boxBottom, y));
}
};
game.down = function (x, y, obj) {
if (gameState === 'enemyTurn') {
dragHeart = true;
heart.x = Math.max(battleBox.x - 285, Math.min(battleBox.x + 285, x));
heart.y = Math.max(battleBox.y - 185, Math.min(battleBox.y + 185, y));
}
};
game.up = function (x, y, obj) {
dragHeart = false;
};
game.update = function () {
updateHealthBars();
updateForgivenessBar();
updateTPBar();
if (gameState === 'enemyTurn') {
turnTimer++;
attackTimer++;
// Spawn attacks periodically
if (attackTimer % 90 === 0) {
spawnAttack();
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Check if bullet is off screen
if (bullet.x < -100 || bullet.x > 2148 || bullet.y < -100 || bullet.y > 2832) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check collision with heart
if (bullet.intersects(heart)) {
var damage = 10;
if (defending) {
damage = Math.floor(damage * 0.5); // Reduce damage by 50% when defending
}
kris.takeDamage(damage);
// Show red damage number
var damageNumber = game.addChild(new DamageNumber(damage, 0xff0000));
damageNumber.x = kris.x;
damageNumber.y = kris.y - 100;
bullet.destroy();
bullets.splice(i, 1);
if (kris.currentHP <= 0) {
gameState = 'gameOver';
turnText.setText('Game Over');
LK.showGameOver();
return;
}
continue;
}
// Check for grazing (near miss) - distance between 25-50 pixels
var distance = Math.sqrt(Math.pow(bullet.x - heart.x, 2) + Math.pow(bullet.y - heart.y, 2));
if (distance >= 25 && distance <= 50 && !bullet.grazed) {
bullet.grazed = true; // Mark as grazed to prevent multiple TP gains
var tpGain = Math.floor(1 * tpMultiplier);
currentTP = Math.min(100, currentTP + tpGain);
updateTPBar();
// Show heart silhouette effect
var heartSilhouette = game.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
}));
heartSilhouette.x = heart.x;
heartSilhouette.y = heart.y;
heartSilhouette.alpha = 0.5;
heartSilhouette.tint = 0xff0000;
heartSilhouette.width = 50;
heartSilhouette.height = 50;
// Animate silhouette fading out
tween(heartSilhouette, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
heartSilhouette.destroy();
}
});
// Play graze sound
LK.getSound('hit').play();
}
}
// End enemy turn after 7 seconds
if (turnTimer >= 420) {
switchToPlayerTurn();
}
}
}; /****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ActionButton = Container.expand(function (text, action) {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('actionButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 24,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.action = action;
self.down = function (x, y, obj) {
if (self.action) {
self.action();
}
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = 0;
self.speedY = 0;
self.lastX = 0;
self.lastY = 0;
self.update = function () {
self.lastX = self.x;
self.lastY = self.y;
self.x += self.speedX;
self.y += self.speedY;
};
return self;
});
var Character = Container.expand(function () {
var self = Container.call(this);
var characterGraphics = self.attachAsset('kris', {
anchorX: 0.5,
anchorY: 1.0
});
self.maxHP = 100;
self.currentHP = 100;
self.takeDamage = function (amount) {
self.currentHP = Math.max(0, self.currentHP - amount);
LK.effects.flashObject(characterGraphics, 0xff0000, 500);
LK.getSound('hit').play();
};
return self;
});
var DamageNumber = Container.expand(function (damage, color) {
var self = Container.call(this);
var damageText = new Text2(damage.toString(), {
size: 36,
fill: color
});
damageText.anchor.set(0.5, 0.5);
self.addChild(damageText);
// Animate damage number floating up and fading out
tween(self, {
y: self.y - 80,
alpha: 0
}, {
duration: 1500,
easing: tween.easeOut,
onFinish: function onFinish() {
self.destroy();
}
});
return self;
});
var GiantBall = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
ballGraphics.width = 80;
ballGraphics.height = 80;
ballGraphics.tint = 0x444444;
self.speedY = 0;
self.bouncing = false;
self.bounceCount = 0;
self.update = function () {
if (!self.bouncing) {
self.speedY += 0.5; // Gravity
self.y += self.speedY;
// Check if hit bottom of battle box
if (self.y >= battleBox.y + 180) {
self.y = battleBox.y + 180;
self.speedY = -self.speedY * 0.7; // Bounce with energy loss
self.bounceCount++;
self.bouncing = true;
LK.setTimeout(function () {
self.bouncing = false;
}, 100);
}
}
};
return self;
});
var Heart = Container.expand(function () {
var self = Container.call(this);
var heartGraphics = self.attachAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
});
heartGraphics.rotation = Math.PI / 4; // Diamond shape
heartGraphics.width = 40; // Make heart bigger
heartGraphics.height = 40;
// Add glow effect
LK.effects.flashObject(heartGraphics, 0xff0000, 100, true); // Continuous red glow
return self;
});
var LaserBeam = Container.expand(function () {
var self = Container.call(this);
var laserGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
laserGraphics.width = 600; // Full width of battle box
laserGraphics.height = 15;
laserGraphics.tint = 0xff0000; // Red laser
self.warned = false;
self.active = false;
self.warningTime = 0;
self.activeTime = 0;
self.update = function () {
if (!self.warned) {
// Warning phase - flash red
laserGraphics.alpha = 0.3 + Math.sin(LK.ticks * 0.3) * 0.2;
self.warningTime++;
if (self.warningTime >= 120) {
// 2 seconds warning
self.warned = true;
self.active = true;
laserGraphics.alpha = 1;
laserGraphics.tint = 0xffffff; // Bright white when active
}
} else if (self.active) {
self.activeTime++;
if (self.activeTime >= 60) {
// Active for 1 second
self.active = false;
laserGraphics.alpha = 0; // Make invisible but don't destroy yet
}
}
};
return self;
});
var Monster = Container.expand(function () {
var self = Container.call(this);
var monsterGraphics = self.attachAsset('monster', {
anchorX: 0.5,
anchorY: 1.0
});
self.maxHP = 8500;
self.currentHP = 8500;
self.takeDamage = function (amount) {
self.currentHP = Math.max(0, self.currentHP - amount);
LK.effects.flashObject(monsterGraphics, 0xff0000, 500);
LK.getSound('hit').play();
};
return self;
});
var Spell = Container.expand(function () {
var self = Container.call(this);
var spellGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
spellGraphics.width = 60;
spellGraphics.height = 60;
spellGraphics.tint = 0x9933ff;
self.warned = false;
self.exploded = false;
self.update = function () {
if (!self.warned) {
// Flash purple warning
spellGraphics.alpha = 0.5;
self.warned = true;
LK.setTimeout(function () {
if (!self.exploded) {
self.exploded = true;
spellGraphics.width = 120;
spellGraphics.height = 120;
spellGraphics.alpha = 1;
spellGraphics.tint = 0xff6600;
}
}, 1500);
}
};
return self;
});
var Sword = Container.expand(function () {
var self = Container.call(this);
var swordGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
swordGraphics.width = 40;
swordGraphics.height = 100;
swordGraphics.tint = 0xcccccc;
self.warned = false;
self.falling = false;
self.speed = 0;
self.update = function () {
if (!self.warned) {
// Flash red warning
swordGraphics.tint = 0xff0000;
self.warned = true;
LK.setTimeout(function () {
self.falling = true;
self.speed = 8;
swordGraphics.tint = 0xcccccc;
}, 1000);
}
if (self.falling) {
self.y += self.speed;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Create stone wall background for menu
var stoneWallBackground = game.addChild(LK.getAsset('stoneWall', {
anchorX: 0,
anchorY: 0
}));
stoneWallBackground.x = 0;
stoneWallBackground.y = 0;
stoneWallBackground.alpha = 0.8;
// Add door to the stone wall
var doorBackground = game.addChild(LK.getAsset('door', {
anchorX: 0.5,
anchorY: 1.0
}));
doorBackground.x = 1024;
doorBackground.y = 1800;
// Create blue stripe background pattern (behind stone wall) - hidden in menu
for (var stripe = 0; stripe < 20; stripe++) {
var blueStripe = game.addChild(LK.getAsset('blueStripe', {
anchorX: 0,
anchorY: 0
}));
blueStripe.x = 0;
blueStripe.y = stripe * 100;
blueStripe.alpha = 0.3;
blueStripe.visible = false; // Hidden in menu
}
// Start with menu music and dinosaur laugh
LK.playMusic('menuMusic');
LK.setTimeout(function () {
LK.getSound('dinosaurLaugh').play();
}, 2000); // Play dinosaur laugh after 2 seconds
// Game state
var gameState = 'menu'; // 'menu', 'playerTurn', 'enemyTurn', 'gameOver'
var turnTimer = 0;
var attackTimer = 0;
var bullets = [];
var dragHeart = false;
var forgivenessLevel = 0; // 0 to 100
var showingActMenu = false;
var showingDescription = false;
var currentTP = 0; // 0 to 100
var tpMultiplier = 1.0; // Can be increased by lucky clothes
var defending = false;
var showingItemMenu = false;
var inventory = [{
name: 'Hamburger',
heal: 25,
type: 'heal'
}, {
name: 'Lancer Cookie',
heal: 1,
type: 'heal'
}, {
name: 'Cake',
heal: 100,
type: 'heal'
}, {
name: 'Soul Essence',
tp: 35,
type: 'tp'
}, {
name: 'Lucky Clothes',
tpBoost: 10,
type: 'tpBoost'
}, {
name: 'Frozen Hotdog',
heal: 5,
type: 'heal'
}];
// Shuffle inventory order
for (var i = inventory.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = inventory[i];
inventory[i] = inventory[j];
inventory[j] = temp;
}
// Characters
var kris = game.addChild(new Character());
kris.x = 400;
kris.y = 2000;
var monster = game.addChild(new Monster());
monster.x = 1650;
monster.y = 2000;
var heart = game.addChild(new Heart());
heart.x = 1024;
heart.y = 1800;
// Battle box - move to back and make more visible
var battleBox = game.addChild(LK.getAsset('battleBox', {
anchorX: 0.5,
anchorY: 0.5
}));
battleBox.x = 1024;
battleBox.y = 1600;
battleBox.alpha = 0;
battleBox.tint = 0x000000; // Make battle box black
// Move battle box to back so it appears behind all other objects
game.setChildIndex(battleBox, 0);
// Battle box green corners
var cornerTopLeft = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 0,
anchorY: 0
}));
cornerTopLeft.x = battleBox.x - 300;
cornerTopLeft.y = battleBox.y - 200;
var cornerTopRight = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 1,
anchorY: 0
}));
cornerTopRight.x = battleBox.x + 300;
cornerTopRight.y = battleBox.y - 200;
var cornerBottomLeft = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 0,
anchorY: 1
}));
cornerBottomLeft.x = battleBox.x - 300;
cornerBottomLeft.y = battleBox.y + 200;
var cornerBottomRight = game.addChild(LK.getAsset('battleBoxCorner', {
anchorX: 1,
anchorY: 1
}));
cornerBottomRight.x = battleBox.x + 300;
cornerBottomRight.y = battleBox.y + 200;
// Health bars - Kris health below battle box
var krisHealthBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
krisHealthBg.x = 750;
krisHealthBg.y = 1850;
krisHealthBg.width = 250;
var krisHealthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0
}));
krisHealthBar.x = 752;
krisHealthBar.y = 1852;
krisHealthBar.tint = 0x0066ff; // Blue color
// Add Kris head next to health bar
var krisHead = game.addChild(LK.getAsset('kris', {
anchorX: 0.5,
anchorY: 0.5
}));
krisHead.x = 680;
krisHead.y = 1862;
krisHead.width = 40;
krisHead.height = 40;
// Add Kris name
var krisNameText = new Text2('KRIS', {
size: 24,
fill: 0xFFFFFF
});
krisNameText.anchor.set(0, 0.5);
krisNameText.x = 610;
krisNameText.y = 1862;
game.addChild(krisNameText);
var monsterHealthBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
monsterHealthBg.x = 1640;
monsterHealthBg.y = 200;
var monsterHealthBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0
}));
monsterHealthBar.x = 1642;
monsterHealthBar.y = 202;
// Action buttons
var attackButton = game.addChild(new ActionButton('ATTACK', function () {
if (gameState === 'playerTurn') {
performAttack();
}
}));
attackButton.x = 300;
attackButton.y = 2400;
var actButton = game.addChild(new ActionButton('ACT', function () {
if (gameState === 'playerTurn') {
performAct();
}
}));
actButton.x = 550;
actButton.y = 2400;
var itemButton = game.addChild(new ActionButton('ITEM', function () {
if (gameState === 'playerTurn') {
performItem();
}
}));
itemButton.x = 800;
itemButton.y = 2400;
var defendButton = game.addChild(new ActionButton('DEFEND', function () {
if (gameState === 'playerTurn') {
performDefend();
}
}));
defendButton.x = 1050;
defendButton.y = 2400;
var mercyButton = game.addChild(new ActionButton('MERCY', function () {
if (gameState === 'playerTurn') {
performMercy();
}
}));
mercyButton.x = 1300;
mercyButton.y = 2400;
// UI Text
var turnText = new Text2('Your Turn', {
size: 36,
fill: 0xFFFFFF
});
turnText.anchor.set(0.5, 0);
LK.gui.top.addChild(turnText);
var krisHPText = new Text2('HP: 100/100', {
size: 20,
fill: 0xFFFFFF
});
krisHPText.anchor.set(0, 0);
krisHPText.x = 750;
krisHPText.y = 1880;
game.addChild(krisHPText);
var monsterHPText = new Text2('MONSTER HP: 80/80', {
size: 24,
fill: 0xFFFFFF
});
monsterHPText.anchor.set(1, 0);
monsterHPText.x = 1850;
monsterHPText.y = 240;
game.addChild(monsterHPText);
// Menu screen elements
var menuTitle = new Text2('SELECT STARTING HEALTH', {
size: 48,
fill: 0xFFFFFF
});
menuTitle.anchor.set(0.5, 0.5);
menuTitle.x = 1024;
menuTitle.y = 1200;
game.addChild(menuTitle);
var startButton50 = game.addChild(new ActionButton('START WITH 50 HP', function () {
if (gameState === 'menu') {
startGameWithHealth(50);
}
}));
startButton50.x = 1024;
startButton50.y = 1350;
var startButton100 = game.addChild(new ActionButton('START WITH 100 HP', function () {
if (gameState === 'menu') {
startGameWithHealth(100);
}
}));
startButton100.x = 1024;
startButton100.y = 1450;
var startButton120 = game.addChild(new ActionButton('START WITH 120 HP', function () {
if (gameState === 'menu') {
startGameWithHealth(120);
}
}));
startButton120.x = 1024;
startButton120.y = 1550;
// Forgiveness bar
var forgivenessBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
forgivenessBg.x = 900;
forgivenessBg.y = 300;
forgivenessBg.width = 250;
var forgivenessBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 0
}));
forgivenessBar.x = 902;
forgivenessBar.y = 302;
forgivenessBar.width = 0;
forgivenessBar.tint = 0xffff00; // Yellow color
var forgivenessText = new Text2('FORGIVENESS: 0%', {
size: 20,
fill: 0xFFFFFF
});
forgivenessText.anchor.set(0, 0);
forgivenessText.x = 900;
forgivenessText.y = 330;
game.addChild(forgivenessText);
// TP bar - positioned on the side
var tpBg = game.addChild(LK.getAsset('healthBarBg', {
anchorX: 0,
anchorY: 0
}));
tpBg.x = 100;
tpBg.y = 1000;
tpBg.width = 30;
tpBg.height = 300;
var tpBar = game.addChild(LK.getAsset('healthBar', {
anchorX: 0,
anchorY: 1
}));
tpBar.x = 102;
tpBar.y = 1298;
tpBar.width = 26;
tpBar.height = 0;
tpBar.tint = 0xffff00; // Yellow color
var tpText = new Text2('TP', {
size: 20,
fill: 0xFFFFFF
});
tpText.anchor.set(0.5, 0);
tpText.x = 115;
tpText.y = 950;
game.addChild(tpText);
// Act menu buttons
var descriptionButton = game.addChild(new ActionButton('DESCRIPTION', function () {
if (gameState === 'playerTurn' && showingActMenu) {
showDescription();
}
}));
descriptionButton.x = 400;
descriptionButton.y = 2300;
descriptionButton.visible = false;
var calmButton = game.addChild(new ActionButton('TRY TO CALM', function () {
if (gameState === 'playerTurn' && showingActMenu) {
tryToCalm();
}
}));
calmButton.x = 650;
calmButton.y = 2300;
calmButton.visible = false;
var danceButton = game.addChild(new ActionButton('DANCE (25 TP)', function () {
if (gameState === 'playerTurn' && showingActMenu && currentTP >= 25) {
performDance();
}
}));
danceButton.x = 950;
danceButton.y = 2300;
danceButton.visible = false;
var backButton = game.addChild(new ActionButton('BACK', function () {
if (gameState === 'playerTurn' && (showingActMenu || showingDescription)) {
hideActMenu();
}
}));
backButton.x = 1200;
backButton.y = 2300;
backButton.visible = false;
// Description text
var descriptionTextBox = new Text2('', {
size: 24,
fill: 0xFFFFFF
});
descriptionTextBox.anchor.set(0.5, 0.5);
descriptionTextBox.x = 1024;
descriptionTextBox.y = 2100;
game.addChild(descriptionTextBox);
descriptionTextBox.visible = false;
// Calm attempt text
var calmText = new Text2('', {
size: 24,
fill: 0xFFFFFF
});
calmText.anchor.set(0.5, 0.5);
calmText.x = 1024;
calmText.y = 2150;
game.addChild(calmText);
calmText.visible = false;
// "Can be spared" indicator
var spareIndicator = new Text2('Can be spared', {
size: 20,
fill: 0xffff00
});
spareIndicator.anchor.set(0.5, 0);
spareIndicator.x = mercyButton.x;
spareIndicator.y = mercyButton.y - 40;
game.addChild(spareIndicator);
spareIndicator.visible = false;
// Initially hide action buttons and battle UI
attackButton.visible = false;
actButton.visible = false;
itemButton.visible = false;
defendButton.visible = false;
mercyButton.visible = false;
krisHealthBg.visible = false;
krisHealthBar.visible = false;
krisHead.visible = false;
krisNameText.visible = false;
krisHPText.visible = false;
tpBg.visible = false;
tpBar.visible = false;
tpText.visible = false;
forgivenessBg.visible = false;
forgivenessBar.visible = false;
forgivenessText.visible = false;
// Game functions
function startGameWithHealth(health) {
kris.maxHP = health;
kris.currentHP = health;
gameState = 'playerTurn';
turnText.setText('Your Turn');
menuTitle.visible = false;
startButton50.visible = false;
startButton100.visible = false;
startButton120.visible = false;
// Hide menu background elements
stoneWallBackground.visible = false;
doorBackground.visible = false;
// Show blue stripes in battle
for (var stripe = 0; stripe < 20; stripe++) {
game.children[stripe + 3].visible = true; // Blue stripes are children 3-22
}
// Show battle UI elements
krisHealthBg.visible = true;
krisHealthBar.visible = true;
krisHead.visible = true;
krisNameText.visible = true;
krisHPText.visible = true;
tpBg.visible = true;
tpBar.visible = true;
tpText.visible = true;
forgivenessBg.visible = true;
forgivenessBar.visible = true;
forgivenessText.visible = true;
// Switch to battle music
LK.playMusic('battleMusic');
attackButton.visible = true;
actButton.visible = true;
itemButton.visible = true;
defendButton.visible = true;
mercyButton.visible = true;
}
function performAttack() {
// Kris attack reaction - flash white and scale up briefly
tween(kris, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
}
});
LK.effects.flashObject(kris, 0xffffff, 300);
var damage = 25;
monster.takeDamage(damage);
// Show blue damage number
var damageNumber = game.addChild(new DamageNumber(damage, 0x0066ff));
damageNumber.x = monster.x;
damageNumber.y = monster.y - 100;
LK.getSound('attack').play();
if (monster.currentHP <= 0) {
gameState = 'gameOver';
turnText.setText('Victory!');
LK.showYouWin();
return;
}
switchToEnemyTurn();
}
function performAct() {
showActMenu();
}
function showActMenu() {
showingActMenu = true;
showingDescription = false;
// Hide main action buttons
attackButton.visible = false;
actButton.visible = false;
itemButton.visible = false;
defendButton.visible = false;
mercyButton.visible = false;
// Show act menu buttons
descriptionButton.visible = true;
calmButton.visible = true;
danceButton.visible = true;
// Update dance button color based on TP
if (currentTP >= 25) {
danceButton.tint = 0xffffff;
} else {
danceButton.tint = 0x666666;
}
backButton.visible = true;
// Hide any previous text
descriptionTextBox.visible = false;
calmText.visible = false;
}
function hideActMenu() {
showingActMenu = false;
showingDescription = false;
// Show main action buttons
attackButton.visible = true;
actButton.visible = true;
itemButton.visible = true;
defendButton.visible = true;
mercyButton.visible = true;
// Hide act menu buttons
descriptionButton.visible = false;
calmButton.visible = false;
danceButton.visible = false;
backButton.visible = false;
// Hide text
descriptionTextBox.visible = false;
calmText.visible = false;
}
function showDescription() {
showingDescription = true;
descriptionTextBox.setText('DINOSAUR Attack: 10 Defense: 5 HP: 8500\nA dinosaur seeking to no longer be used as a weapon');
descriptionTextBox.visible = true;
}
function tryToCalm() {
// Kris act reaction - subtle side step
tween(kris, {
x: kris.x + 30
}, {
duration: 250,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
x: 400
}, {
duration: 250,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0xffff00, 400);
// Increase forgiveness level
forgivenessLevel = Math.min(100, forgivenessLevel + 10);
updateForgivenessBar();
// Show calm attempt text
calmText.setText('Kris tried to calm Dinosaur. Didn\'t achieve much\nbut Dinosaur calmed down a little');
calmText.visible = true;
// Check if can be spared
if (forgivenessLevel >= 100) {
spareIndicator.visible = true;
mercyButton.tint = 0xffff00;
}
LK.setTimeout(function () {
hideActMenu();
switchToEnemyTurn();
}, 2000);
}
function performDance() {
if (currentTP < 25) return;
// Kris dance reaction - spin and bounce
tween(kris, {
rotation: Math.PI * 2,
y: kris.y - 40
}, {
duration: 800,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
rotation: 0,
y: 2000
}, {
duration: 400,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0xff00ff, 800);
// Consume TP
currentTP -= 25;
updateTPBar();
// Increase forgiveness level by 20%
forgivenessLevel = Math.min(100, forgivenessLevel + 20);
updateForgivenessBar();
// Show dance text
calmText.setText('Kris performed a beautiful dance!\nDinosaur was charmed and became much calmer');
calmText.visible = true;
// Check if can be spared
if (forgivenessLevel >= 100) {
spareIndicator.visible = true;
mercyButton.tint = 0xffff00;
}
LK.setTimeout(function () {
hideActMenu();
switchToEnemyTurn();
}, 2500);
}
function performItem() {
showItemMenu();
}
function showItemMenu() {
showingItemMenu = true;
// Hide main action buttons
attackButton.visible = false;
actButton.visible = false;
itemButton.visible = false;
defendButton.visible = false;
mercyButton.visible = false;
// Show item menu
showItemInventory();
}
function hideItemMenu() {
showingItemMenu = false;
// Show main action buttons
attackButton.visible = true;
actButton.visible = true;
itemButton.visible = true;
defendButton.visible = true;
mercyButton.visible = true;
// Hide item buttons
hideItemInventory();
}
function showItemInventory() {
// Create item buttons dynamically
for (var i = 0; i < inventory.length; i++) {
var item = inventory[i];
var itemButton = game.addChild(new ActionButton(item.name, createItemUseFunction(i)));
itemButton.x = 300 + i % 3 * 250;
itemButton.y = 2200 + Math.floor(i / 3) * 80;
itemButton.itemIndex = i;
}
// Add back button
var itemBackButton = game.addChild(new ActionButton('BACK', function () {
hideItemMenu();
}));
itemBackButton.x = 1200;
itemBackButton.y = 2400;
itemBackButton.isItemBack = true;
}
function hideItemInventory() {
// Remove all item buttons
var children = game.children.slice();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.itemIndex !== undefined || child.isItemBack) {
child.destroy();
}
}
}
function createItemUseFunction(itemIndex) {
return function () {
if (gameState === 'playerTurn' && showingItemMenu) {
useItem(itemIndex);
}
};
}
function useItem(itemIndex) {
var item = inventory[itemIndex];
// Kris item reaction - gentle bounce and green flash
tween(kris, {
y: kris.y - 20
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
y: 2000
}, {
duration: 300,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0x00ff00, 500);
if (item.type === 'heal') {
var healAmount = Math.floor(kris.maxHP * item.heal / 100);
kris.currentHP = Math.min(kris.maxHP, kris.currentHP + healAmount);
// Show green healing number
var healNumber = game.addChild(new DamageNumber('+' + healAmount, 0x00ff00));
healNumber.x = kris.x;
healNumber.y = kris.y - 100;
} else if (item.type === 'tp') {
currentTP = Math.min(100, currentTP + item.tp);
updateTPBar();
// Show green TP number
var tpNumber = game.addChild(new DamageNumber('+' + item.tp + ' TP', 0x00ff00));
tpNumber.x = kris.x;
tpNumber.y = kris.y - 100;
} else if (item.type === 'tpBoost') {
tpMultiplier += item.tpBoost / 100;
// Show green boost number
var boostNumber = game.addChild(new DamageNumber('TP Boost +' + item.tpBoost + '%', 0x00ff00));
boostNumber.x = kris.x;
boostNumber.y = kris.y - 100;
}
// Remove item from inventory
inventory.splice(itemIndex, 1);
hideItemMenu();
switchToEnemyTurn();
}
function performDefend() {
// Kris defend reaction - crouch down slightly
tween(kris, {
scaleY: 0.8,
y: kris.y + 20
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(kris, {
scaleY: 1.0,
y: 2000
}, {
duration: 300,
easing: tween.easeIn
});
}
});
LK.effects.flashObject(kris, 0x0066ff, 400);
// Set defending flag and gain TP
defending = true;
var tpGain = Math.floor(15 * tpMultiplier);
currentTP = Math.min(100, currentTP + tpGain);
updateTPBar();
// Show green TP gain number
var tpNumber = game.addChild(new DamageNumber('+' + tpGain + ' TP', 0x00ff00));
tpNumber.x = kris.x;
tpNumber.y = kris.y - 100;
switchToEnemyTurn();
}
function performMercy() {
if (forgivenessLevel >= 100) {
gameState = 'gameOver';
turnText.setText('You spared the monster!');
LK.showYouWin();
} else {
switchToEnemyTurn();
}
}
function switchToEnemyTurn() {
gameState = 'enemyTurn';
turnText.setText('Enemy Turn - Dodge!');
turnTimer = 0;
attackTimer = 0;
// Show battle box with high visibility
battleBox.alpha = 0.95;
// Add subtle glow effect to make battle box more visible
LK.effects.flashObject(battleBox, 0x00ff00, 200, true);
// Heart emerges from Kris's chest and moves to battle box
heart.x = kris.x;
heart.y = kris.y - 60; // Start from chest area
tween(heart, {
x: battleBox.x,
y: battleBox.y
}, {
duration: 800,
easing: tween.easeOut
});
}
function switchToPlayerTurn() {
gameState = 'playerTurn';
turnText.setText('Your Turn');
defending = false; // Reset defending flag
// Hide battle box
battleBox.alpha = 0;
// Clear bullets
for (var i = bullets.length - 1; i >= 0; i--) {
bullets[i].destroy();
bullets.splice(i, 1);
}
// Heart returns to Kris's chest area with animation
tween(heart, {
x: kris.x,
y: kris.y - 60
}, {
duration: 600,
easing: tween.easeIn
});
}
function spawnAttack() {
var attackType = Math.floor(Math.random() * 6) + 1; // Added laser beam attack
var boxLeft = battleBox.x - 300;
var boxRight = battleBox.x + 300;
var boxTop = battleBox.y - 200;
var boxBottom = battleBox.y + 200;
switch (attackType) {
case 1:
// Falling swords
for (var i = 0; i < 3; i++) {
var sword = new Sword();
sword.x = boxLeft + Math.random() * 600;
sword.y = boxTop - 100;
bullets.push(sword);
game.addChild(sword);
}
break;
case 2:
// Random spell explosion
var spell = new Spell();
spell.x = boxLeft + Math.random() * 600;
spell.y = boxTop + Math.random() * 400;
bullets.push(spell);
game.addChild(spell);
break;
case 3:
// White bullets from multiple points
for (var j = 0; j < 6; j++) {
var bullet = new Bullet();
var side = Math.floor(Math.random() * 4);
switch (side) {
case 0:
// Top
bullet.x = boxLeft + Math.random() * 600;
bullet.y = boxTop - 50;
bullet.speedX = (Math.random() - 0.5) * 2;
bullet.speedY = 3 + Math.random() * 2;
break;
case 1:
// Right
bullet.x = boxRight + 50;
bullet.y = boxTop + Math.random() * 400;
bullet.speedX = -3 - Math.random() * 2;
bullet.speedY = (Math.random() - 0.5) * 2;
break;
case 2:
// Bottom
bullet.x = boxLeft + Math.random() * 600;
bullet.y = boxBottom + 50;
bullet.speedX = (Math.random() - 0.5) * 2;
bullet.speedY = -3 - Math.random() * 2;
break;
case 3:
// Left
bullet.x = boxLeft - 50;
bullet.y = boxTop + Math.random() * 400;
bullet.speedX = 3 + Math.random() * 2;
bullet.speedY = (Math.random() - 0.5) * 2;
break;
}
bullets.push(bullet);
game.addChild(bullet);
}
break;
case 4:
// More white bullets
for (var k = 0; k < 8; k++) {
var bullet2 = new Bullet();
bullet2.x = boxLeft + Math.random() * 600;
bullet2.y = boxTop + Math.random() * 400;
var angle = Math.random() * Math.PI * 2;
var speed = 2 + Math.random() * 3;
bullet2.speedX = Math.cos(angle) * speed;
bullet2.speedY = Math.sin(angle) * speed;
bullets.push(bullet2);
game.addChild(bullet2);
}
break;
case 5:
// Giant bouncing ball
var giantBall = new GiantBall();
giantBall.x = boxLeft + Math.random() * 600;
giantBall.y = boxTop - 100;
bullets.push(giantBall);
game.addChild(giantBall);
break;
case 6:
// Laser beam attack
var laserBeam = new LaserBeam();
laserBeam.x = battleBox.x;
laserBeam.y = boxTop + Math.random() * 400; // Random Y position
bullets.push(laserBeam);
game.addChild(laserBeam);
break;
}
}
function updateHealthBars() {
// Update Kris health bar
var krisHealthRatio = kris.currentHP / kris.maxHP;
krisHealthBar.width = 246 * krisHealthRatio;
krisHPText.setText('HP: ' + kris.currentHP + '/' + kris.maxHP);
// Update monster health bar
var monsterHealthRatio = monster.currentHP / monster.maxHP;
monsterHealthBar.width = 200 * monsterHealthRatio;
monsterHPText.setText('MONSTER HP: ' + monster.currentHP + '/' + monster.maxHP);
}
function updateForgivenessBar() {
var forgivenessRatio = forgivenessLevel / 100;
forgivenessBar.width = 246 * forgivenessRatio;
forgivenessText.setText('FORGIVENESS: ' + forgivenessLevel + '%');
}
function updateTPBar() {
var tpRatio = currentTP / 100;
tpBar.height = 296 * tpRatio;
// No need to update text as it just says "TP"
}
// Heart movement
game.move = function (x, y, obj) {
if (gameState === 'enemyTurn' && dragHeart) {
// Constrain heart to battle box
var boxLeft = battleBox.x - 285;
var boxRight = battleBox.x + 285;
var boxTop = battleBox.y - 185;
var boxBottom = battleBox.y + 185;
heart.x = Math.max(boxLeft, Math.min(boxRight, x));
heart.y = Math.max(boxTop, Math.min(boxBottom, y));
}
};
game.down = function (x, y, obj) {
if (gameState === 'enemyTurn') {
dragHeart = true;
heart.x = Math.max(battleBox.x - 285, Math.min(battleBox.x + 285, x));
heart.y = Math.max(battleBox.y - 185, Math.min(battleBox.y + 185, y));
}
};
game.up = function (x, y, obj) {
dragHeart = false;
};
game.update = function () {
updateHealthBars();
updateForgivenessBar();
updateTPBar();
if (gameState === 'enemyTurn') {
turnTimer++;
attackTimer++;
// Spawn attacks periodically
if (attackTimer % 90 === 0) {
spawnAttack();
}
// Update bullets
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
// Check if bullet is off screen
if (bullet.x < -100 || bullet.x > 2148 || bullet.y < -100 || bullet.y > 2832) {
bullet.destroy();
bullets.splice(i, 1);
continue;
}
// Check collision with heart
if (bullet.intersects(heart)) {
var damage = 10;
if (defending) {
damage = Math.floor(damage * 0.5); // Reduce damage by 50% when defending
}
kris.takeDamage(damage);
// Show red damage number
var damageNumber = game.addChild(new DamageNumber(damage, 0xff0000));
damageNumber.x = kris.x;
damageNumber.y = kris.y - 100;
bullet.destroy();
bullets.splice(i, 1);
if (kris.currentHP <= 0) {
gameState = 'gameOver';
turnText.setText('Game Over');
LK.showGameOver();
return;
}
continue;
}
// Check for grazing (near miss) - distance between 25-50 pixels
var distance = Math.sqrt(Math.pow(bullet.x - heart.x, 2) + Math.pow(bullet.y - heart.y, 2));
if (distance >= 25 && distance <= 50 && !bullet.grazed) {
bullet.grazed = true; // Mark as grazed to prevent multiple TP gains
var tpGain = Math.floor(1 * tpMultiplier);
currentTP = Math.min(100, currentTP + tpGain);
updateTPBar();
// Show heart silhouette effect
var heartSilhouette = game.addChild(LK.getAsset('heart', {
anchorX: 0.5,
anchorY: 0.5
}));
heartSilhouette.x = heart.x;
heartSilhouette.y = heart.y;
heartSilhouette.alpha = 0.5;
heartSilhouette.tint = 0xff0000;
heartSilhouette.width = 50;
heartSilhouette.height = 50;
// Animate silhouette fading out
tween(heartSilhouette, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
heartSilhouette.destroy();
}
});
// Play graze sound
LK.getSound('hit').play();
}
}
// End enemy turn after 7 seconds
if (turnTimer >= 420) {
switchToPlayerTurn();
}
}
};
Corazón rojo. In-Game asset. 2d. High contrast. No shadows
No cambiar nada solo que parezca más femenino
Mostruo de color blanco con pinchos azules y ojos azules dientes azules y que parece dinosaurio. In-Game asset. 2d. High contrast. No shadows. Deltarune
Puerta de piedra cerrada. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Pared de piedra. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat