/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BlueRaptor = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('blueRaptor', { anchorX: 0.5, anchorY: 0.5 }); self.health = 100; self.maxHealth = 100; self.speed = 8; self.dashCooldown = 0; self.slashCooldown = 0; self.energyFallCooldown = 0; self.isMoving = false; self.facing = 1; // 1 for right, -1 for left self.update = function () { if (self.dashCooldown > 0) self.dashCooldown--; if (self.slashCooldown > 0) self.slashCooldown--; if (self.energyFallCooldown > 0) self.energyFallCooldown--; // Update graphics based on facing direction graphics.scaleX = self.facing; // Keep player in bounds if (self.x < 40) self.x = 40; if (self.x > 2008) self.x = 2008; if (self.y < 60) self.y = 60; if (self.y > 2672) self.y = 2672; }; self.shadowDash = function (targetX, targetY) { if (self.dashCooldown > 0) return; // Create dash effect var dashEffect = game.addChild(LK.getAsset('shadowDash', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y, alpha: 0.7 })); // Move to target position self.x = targetX; self.y = targetY; // Play dash sound LK.getSound('dash').play(); // Animate dash effect tween(dashEffect, { alpha: 0, scaleX: 2, scaleY: 2 }, { duration: 300, onFinish: function onFinish() { dashEffect.destroy(); } }); self.dashCooldown = 120; // 2 seconds at 60fps }; self.bloodSlash = function (direction) { if (self.slashCooldown > 0) return; var slash = game.addChild(LK.getAsset('bloodSlash', { anchorX: 0.5, anchorY: 0.5, x: self.x + direction.x * 100, y: self.y + direction.y * 100, rotation: Math.atan2(direction.y, direction.x), scaleX: 1.5, scaleY: 1.2 })); bloodSlashes.push(slash); // Play slash sound LK.getSound('slash').play(); // Animate slash tween(slash, { alpha: 0, scaleX: 2.0, scaleY: 1.5 }, { duration: 300, onFinish: function onFinish() { slash.destroy(); var index = bloodSlashes.indexOf(slash); if (index > -1) bloodSlashes.splice(index, 1); } }); self.slashCooldown = 30; // 0.5 seconds }; self.energyFall = function () { if (self.energyFallCooldown > 0) return; var explosion = game.addChild(LK.getAsset('energyFall', { anchorX: 0.5, anchorY: 0.5, x: self.x, y: self.y, alpha: 0.8, scaleX: 0.1, scaleY: 0.1 })); energyFalls.push(explosion); // Play explosion sound LK.getSound('explosion').play(); // Animate explosion tween(explosion, { alpha: 0, scaleX: 1, scaleY: 1 }, { duration: 500, easing: tween.easeOut, onFinish: function onFinish() { explosion.destroy(); var index = energyFalls.indexOf(explosion); if (index > -1) energyFalls.splice(index, 1); } }); self.energyFallCooldown = 300; // 5 seconds }; return self; }); var Enemy = Container.expand(function (enemyType) { var self = Container.call(this); var graphics = self.attachAsset(enemyType, { anchorX: 0.5, anchorY: 0.5 }); self.enemyType = enemyType; self.health = 50; self.speed = 2; self.attackCooldown = 0; self.lastPlayerX = 0; self.lastPlayerY = 0; // Set enemy-specific properties based on size (smaller to larger) switch (enemyType) { case 'velocorator': // Smallest (60x80) self.health = 25; self.speed = 4; break; case 'delophospurus': // Small-medium (70x100) self.health = 75; self.speed = 3; break; case 'stegospurus': // Medium-large (100x90) self.health = 150; self.speed = 1.5; break; case 'tricerator': // Largest (120x80) self.health = 250; self.speed = 1; break; } self.update = function () { if (self.attackCooldown > 0) self.attackCooldown--; // AI: Move towards player var dx = player.x - self.x; var dy = player.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { var moveX = dx / distance * self.speed; var moveY = dy / distance * self.speed; self.x += moveX; self.y += moveY; // Face player graphics.scaleX = dx > 0 ? 1 : -1; } // Keep enemy in bounds if (self.x < 0) self.x = 0; if (self.x > 2048) self.x = 2048; if (self.y < 0) self.y = 0; if (self.y > 2732) self.y = 2732; }; self.takeDamage = function (damage) { self.health -= damage; // Flash red when hit tween(graphics, { tint: 0xff0000 }, { duration: 100, onFinish: function onFinish() { tween(graphics, { tint: 0xffffff }, { duration: 100 }); } }); LK.getSound('vurmasesi').play(); if (self.health <= 0) { LK.setScore(LK.getScore() + 25); var scoreText = LK.gui.topLeft.children[1]; // Score text is the second child (index 1) if (scoreText && scoreText.setText) { scoreText.setText('Score: ' + LK.getScore().toString()); } // Chance to drop power-up if (Math.random() < 0.3) { spawnPowerUp(self.x, self.y); } return true; // Enemy is dead } return false; }; return self; }); var PowerUp = Container.expand(function () { var self = Container.call(this); var graphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.collectTimer = 0; self.update = function () { self.collectTimer++; // Pulse effect var pulse = Math.sin(self.collectTimer * 0.1) * 0.3 + 1; graphics.scaleX = pulse; graphics.scaleY = pulse; // Auto-destroy after 10 seconds if (self.collectTimer > 600) { self.destroy(); var index = powerUps.indexOf(self); if (index > -1) powerUps.splice(index, 1); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000022 }); /**** * Game Code ****/ // Roman numeral conversion function function toRomanNumeral(num) { var romanNumerals = [{ value: 50, symbol: 'L' }, { value: 40, symbol: 'XL' }, { value: 10, symbol: 'X' }, { value: 9, symbol: 'IX' }, { value: 5, symbol: 'V' }, { value: 4, symbol: 'IV' }, { value: 1, symbol: 'I' }]; var result = ''; for (var i = 0; i < romanNumerals.length; i++) { while (num >= romanNumerals[i].value) { result += romanNumerals[i].symbol; num -= romanNumerals[i].value; } } return result; } // Game variables var player; var enemies = []; var bloodSlashes = []; var energyFalls = []; var powerUps = []; var waveNumber = 1; var enemiesSpawned = 0; var enemiesPerWave = 5; var spawnTimer = 0; var backgroundPulse = 0; var lastTouchX = 0; var lastTouchY = 0; var moveKeys = {}; var forestElements = []; var mistElements = []; var gameStarted = false; var welcomeScreen = null; var startButton = null; var welcomeText = null; // Create forest background elements function createForestBackground() { // Left side trees for (var i = 0; i < 8; i++) { var leftTree = game.addChild(LK.getAsset('treeLeft', { anchorX: 1, anchorY: 1, x: -50 + Math.random() * 150, y: 200 + i * 300, alpha: 0.6 + Math.random() * 0.3, scaleX: 0.8 + Math.random() * 0.4, scaleY: 0.8 + Math.random() * 0.4 })); forestElements.push(leftTree); } // Right side trees for (var i = 0; i < 8; i++) { var rightTree = game.addChild(LK.getAsset('treeRight', { anchorX: 0, anchorY: 1, x: 1950 + Math.random() * 150, y: 150 + i * 320, alpha: 0.5 + Math.random() * 0.4, scaleX: 0.7 + Math.random() * 0.5, scaleY: 0.9 + Math.random() * 0.3 })); forestElements.push(rightTree); } // Top edge trees for (var i = 0; i < 6; i++) { var topTree = game.addChild(LK.getAsset('treeTop', { anchorX: 0.5, anchorY: 1, x: 300 + i * 280, y: -20 + Math.random() * 100, alpha: 0.4 + Math.random() * 0.3, scaleX: 0.6 + Math.random() * 0.4, scaleY: 0.8 + Math.random() * 0.4 })); forestElements.push(topTree); } // Bottom edge trees for (var i = 0; i < 6; i++) { var bottomTree = game.addChild(LK.getAsset('treeBottom', { anchorX: 0.5, anchorY: 0, x: 250 + i * 300, y: 2650 + Math.random() * 100, alpha: 0.5 + Math.random() * 0.2, scaleX: 0.7 + Math.random() * 0.3, scaleY: 0.9 + Math.random() * 0.2 })); forestElements.push(bottomTree); } // Create mysterious mist effects for (var i = 0; i < 12; i++) { var mist = game.addChild(LK.getAsset('mistEffect', { anchorX: 0.5, anchorY: 0.5, x: 200 + Math.random() * 1600, y: 200 + Math.random() * 2300, alpha: 0.1 + Math.random() * 0.15, scaleX: 1 + Math.random() * 2, scaleY: 0.5 + Math.random() * 1 })); mistElements.push(mist); } // Add some cave art/ancient symbols for (var i = 0; i < 4; i++) { var caveArt = game.addChild(LK.getAsset('caveArt', { anchorX: 0.5, anchorY: 0.5, x: 100 + Math.random() * 150, y: 300 + i * 500, alpha: 0.3 + Math.random() * 0.2, rotation: Math.random() * Math.PI * 2 })); forestElements.push(caveArt); } } // Create welcome screen function createWelcomeScreen() { // Create semi-transparent background welcomeScreen = game.addChild(LK.getAsset('treeTop', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366, alpha: 0.8, scaleX: 10, scaleY: 15, tint: 0x000000 })); // Create welcome message welcomeText = new Text2('This game is designed\nto be played on computer', { size: 80, fill: '#ffffff' }); welcomeText.anchor.set(0.5, 0.5); welcomeText.x = 1024; welcomeText.y = 1100; game.addChild(welcomeText); // Create start button (arrow) startButton = game.addChild(LK.getAsset('powerUp', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1600, scaleX: 3, scaleY: 3, tint: 0x00ff00 })); // Add pulsing effect to start button tween(startButton, { scaleX: 3.5, scaleY: 3.5 }, { duration: 800, yoyo: true, repeat: -1 }); } // Create welcome screen first createWelcomeScreen(); // Create forest background createForestBackground(); // Spawn power-up function function spawnPowerUp(x, y) { var powerUp = game.addChild(new PowerUp()); powerUp.x = x; powerUp.y = y; powerUps.push(powerUp); } // Spawn enemy function function spawnEnemy() { var enemyTypes = ['delophospurus', 'stegospurus', 'tricerator', 'velocorator']; var randomType = enemyTypes[Math.floor(Math.random() * enemyTypes.length)]; var enemy = game.addChild(new Enemy(randomType)); // Spawn at random edge var edge = Math.floor(Math.random() * 4); switch (edge) { case 0: // Top enemy.x = Math.random() * 2048; enemy.y = -50; break; case 1: // Right enemy.x = 2098; enemy.y = Math.random() * 2732; break; case 2: // Bottom enemy.x = Math.random() * 2048; enemy.y = 2782; break; case 3: // Left enemy.x = -50; enemy.y = Math.random() * 2732; break; } enemies.push(enemy); } // Function to start the game function startGame() { if (gameStarted) return; gameStarted = true; // Remove welcome screen if (welcomeScreen) { welcomeScreen.destroy(); welcomeScreen = null; } // Remove start button if (startButton) { startButton.destroy(); startButton = null; } // Remove welcome text if (welcomeText) { welcomeText.destroy(); welcomeText = null; } // Clear GUI LK.gui.center.removeChildren(); // Create player player = game.addChild(new BlueRaptor()); player.x = 1024; player.y = 1366; // Create UI with enhanced styling // Score panel background var scorePanel = game.addChild(LK.getAsset('treeTop', { anchorX: 0, anchorY: 0, x: 100, y: 30, scaleX: 1.2, scaleY: 0.8, alpha: 0.3, tint: 0x004444 })); LK.gui.topLeft.addChild(scorePanel); var scoreText = new Text2('Score: 0', { size: 60, fill: '#00ffff', stroke: '#004444', strokeThickness: 3, dropShadow: true, dropShadowColor: '#000000', dropShadowBlur: 5, dropShadowAngle: Math.PI / 6, dropShadowDistance: 4 }); scoreText.anchor.set(0, 0); scoreText.x = 120; scoreText.y = 50; LK.gui.topLeft.addChild(scoreText); // Add pulsing animation to score tween(scoreText, { scaleX: 1.1, scaleY: 1.1 }, { duration: 1000, yoyo: true, repeat: -1, easing: tween.easeInOut }); // Health bar background var healthBarBg = game.addChild(LK.getAsset('treeBottom', { anchorX: 1, anchorY: 0, x: -20, y: 40, scaleX: 1.5, scaleY: 0.3, alpha: 0.4, tint: 0x330000 })); LK.gui.topRight.addChild(healthBarBg); // Health bar fill var healthBarFill = game.addChild(LK.getAsset('treeBottom', { anchorX: 1, anchorY: 0, x: -20, y: 40, scaleX: 1.5, scaleY: 0.3, alpha: 0.8, tint: 0x00ff00 })); LK.gui.topRight.addChild(healthBarFill); // Health text var healthText = new Text2('Health: 100', { size: 45, fill: '#ffffff', stroke: '#000000', strokeThickness: 2, dropShadow: true, dropShadowColor: '#000000', dropShadowBlur: 3, dropShadowAngle: Math.PI / 6, dropShadowDistance: 2 }); healthText.anchor.set(1, 0); healthText.x = -30; healthText.y = 80; LK.gui.topRight.addChild(healthText); // Wave banner background var waveBanner = game.addChild(LK.getAsset('treeTop', { anchorX: 0.5, anchorY: 0, x: 0, y: 30, scaleX: 3, scaleY: 1, alpha: 0.4, tint: 0x444400 })); LK.gui.top.addChild(waveBanner); // Wave progress circle background var waveCircleBg = game.addChild(LK.getAsset('powerUp', { anchorX: 0.5, anchorY: 0.5, x: -150, y: 70, scaleX: 3, scaleY: 3, alpha: 0.3, tint: 0x333333 })); LK.gui.top.addChild(waveCircleBg); // Wave progress circle fill var waveCircleFill = game.addChild(LK.getAsset('powerUp', { anchorX: 0.5, anchorY: 0.5, x: -150, y: 70, scaleX: 2.5, scaleY: 2.5, alpha: 0.6, tint: 0xffff00 })); LK.gui.top.addChild(waveCircleFill); var waveText = new Text2('Wave I', { size: 60, fill: '#ffff00', stroke: '#444400', strokeThickness: 3, dropShadow: true, dropShadowColor: '#000000', dropShadowBlur: 5, dropShadowAngle: Math.PI / 6, dropShadowDistance: 4 }); waveText.anchor.set(0.5, 0); LK.gui.top.addChild(waveText); // Add glowing animation to wave text tween(waveText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 800, yoyo: true, repeat: -1, easing: tween.easeInOut }); // Start background music with fade-in effect LK.playMusic('ses', { loop: true, fade: { start: 0, end: 0.7, duration: 1000 } }); } // Touch controls game.down = function (x, y, obj) { if (!gameStarted) { // Check if clicked on start button area - use coordinates directly var buttonBounds = { x: 1024 - 100, y: 1600 - 100, width: 200, height: 200 }; if (x >= buttonBounds.x && x <= buttonBounds.x + buttonBounds.width && y >= buttonBounds.y && y <= buttonBounds.y + buttonBounds.height) { startGame(); } return; } lastTouchX = x; lastTouchY = y; // Double tap for shadow dash if (obj.tapCount === 2) { player.shadowDash(x, y); } }; game.up = function (x, y, obj) { if (!gameStarted) return; var dx = x - player.x; var dy = y - player.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 50) { // Blood slash in direction of touch var direction = { x: dx / distance, y: dy / distance }; player.bloodSlash(direction); } else { // Energy fall at current position player.energyFall(); } }; game.move = function (x, y, obj) { if (!gameStarted) return; // Move player towards touch position var dx = x - player.x; var dy = y - player.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 20) { var moveX = dx / distance * player.speed; var moveY = dy / distance * player.speed; player.x += moveX; player.y += moveY; player.facing = dx > 0 ? 1 : -1; player.isMoving = true; } else { player.isMoving = false; } }; // Main game loop game.update = function () { backgroundPulse += 0.05; // Animate background color with darker forest tones var pulseValue = Math.sin(backgroundPulse) * 0.08 + 0.08; var bgColor = 0x001100 + Math.floor(pulseValue * 180) * 0x010101; game.setBackgroundColor(bgColor); // Animate mist effects for (var i = 0; i < mistElements.length; i++) { var mist = mistElements[i]; mist.alpha = 0.1 + Math.sin(backgroundPulse + i * 0.5) * 0.05; mist.x += Math.sin(backgroundPulse * 0.3 + i) * 0.5; } // Only run game logic after game started if (!gameStarted) return; // Update UI with dynamic effects var healthBarFill = LK.gui.topRight.children[1]; var healthText = LK.gui.topRight.children[2]; if (healthText && healthBarFill) { healthText.setText('Health: ' + player.health); // Dynamic health color based on health percentage var healthPercent = player.health / player.maxHealth; // Update health bar fill width healthBarFill.scaleX = 1.5 * healthPercent; if (healthPercent > 0.7) { healthBarFill.tint = 0x00ff00; // Green for high health } else if (healthPercent > 0.3) { healthBarFill.tint = 0xffff00; // Yellow for medium health } else { healthBarFill.tint = 0xff0000; // Red for low health // Add urgent pulsing for low health if (healthPercent <= 0.3) { tween(healthBarFill, { scaleY: 0.4 }, { duration: 300, yoyo: true, repeat: 1 }); } } } // Add score increase animation var scoreText = LK.gui.topLeft.children[1]; if (scoreText && LK.getScore() > 0) { // Change color based on score milestones var score = LK.getScore(); if (score >= 1000) { scoreText.fill = '#ff00ff'; // Purple for high scores } else if (score >= 500) { scoreText.fill = '#ffd700'; // Gold for medium-high scores } else if (score >= 250) { scoreText.fill = '#ff8800'; // Orange for medium scores } else { scoreText.fill = '#00ffff'; // Cyan for low scores } // Animate score text when it changes tween(scoreText, { scaleX: 1.3, scaleY: 1.3 }, { duration: 200, yoyo: true, repeat: 1 }); } // Spawn enemies if (enemiesSpawned < enemiesPerWave) { spawnTimer++; if (spawnTimer > 120) { // Every 2 seconds spawnEnemy(); enemiesSpawned++; spawnTimer = 0; } } // Update wave progress circle var waveCircleFill = LK.gui.top.children[2]; if (waveCircleFill) { var waveProgress = (enemiesPerWave - enemies.length) / enemiesPerWave; waveCircleFill.scaleX = 2.5 * waveProgress; waveCircleFill.scaleY = 2.5 * waveProgress; } // Check for wave completion if (enemiesSpawned >= enemiesPerWave && enemies.length === 0) { waveNumber++; enemiesPerWave += 2; enemiesSpawned = 0; var waveText = LK.gui.top.children[3]; if (waveText) { waveText.setText('Wave ' + toRomanNumeral(waveNumber)); // Add celebration animation for new wave tween(waveText, { scaleX: 2, scaleY: 2, rotation: Math.PI * 2 }, { duration: 1000, easing: tween.easeOut, onFinish: function onFinish() { tween(waveText, { scaleX: 1, scaleY: 1, rotation: 0 }, { duration: 300 }); } }); // Flash screen with golden color for wave completion LK.effects.flashScreen(0xffd700, 500); } // Restore some health player.health = Math.min(player.health + 20, player.maxHealth); } // Enemy vs player collision for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (enemy.intersects(player)) { if (!enemy.lastPlayerCollision) { player.health -= 10; enemy.lastPlayerCollision = true; // Push player away var dx = player.x - enemy.x; var dy = player.y - enemy.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 0) { player.x += dx / distance * 30; player.y += dy / distance * 30; } // Screen shake effect LK.effects.flashScreen(0xff0000, 200); // Add dramatic health bar shake when damaged var healthBarFill = LK.gui.topRight.children[1]; var healthText = LK.gui.topRight.children[2]; if (healthText && healthBarFill) { tween(healthBarFill, { scaleY: 0.5, rotation: 0.1 }, { duration: 100, yoyo: true, repeat: 3, onFinish: function onFinish() { healthBarFill.rotation = 0; // Reset rotation } }); tween(healthText, { scaleX: 1.2, scaleY: 1.2 }, { duration: 150, yoyo: true, repeat: 2 }); } if (player.health <= 0) { LK.showGameOver(); } } } else { enemy.lastPlayerCollision = false; } } // Blood slash vs enemies for (var i = bloodSlashes.length - 1; i >= 0; i--) { var slash = bloodSlashes[i]; for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (slash.intersects(enemy)) { if (enemy.takeDamage(50)) { enemy.destroy(); enemies.splice(j, 1); } } } } // Energy fall vs enemies for (var i = energyFalls.length - 1; i >= 0; i--) { var explosion = energyFalls[i]; for (var j = enemies.length - 1; j >= 0; j--) { var enemy = enemies[j]; if (explosion.intersects(enemy)) { if (!enemy.lastExplosionHit) { enemy.lastExplosionHit = true; if (enemy.takeDamage(100)) { enemy.destroy(); enemies.splice(j, 1); } } } else { enemy.lastExplosionHit = false; } } } // Power-up collection for (var i = powerUps.length - 1; i >= 0; i--) { var powerUp = powerUps[i]; if (powerUp.intersects(player)) { // Restore health and reset cooldowns player.health = Math.min(player.health + 30, player.maxHealth); player.dashCooldown = Math.max(0, player.dashCooldown - 60); player.slashCooldown = Math.max(0, player.slashCooldown - 30); player.energyFallCooldown = Math.max(0, player.energyFallCooldown - 120); powerUp.destroy(); powerUps.splice(i, 1); } } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BlueRaptor = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('blueRaptor', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 100;
self.maxHealth = 100;
self.speed = 8;
self.dashCooldown = 0;
self.slashCooldown = 0;
self.energyFallCooldown = 0;
self.isMoving = false;
self.facing = 1; // 1 for right, -1 for left
self.update = function () {
if (self.dashCooldown > 0) self.dashCooldown--;
if (self.slashCooldown > 0) self.slashCooldown--;
if (self.energyFallCooldown > 0) self.energyFallCooldown--;
// Update graphics based on facing direction
graphics.scaleX = self.facing;
// Keep player in bounds
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
if (self.y < 60) self.y = 60;
if (self.y > 2672) self.y = 2672;
};
self.shadowDash = function (targetX, targetY) {
if (self.dashCooldown > 0) return;
// Create dash effect
var dashEffect = game.addChild(LK.getAsset('shadowDash', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
alpha: 0.7
}));
// Move to target position
self.x = targetX;
self.y = targetY;
// Play dash sound
LK.getSound('dash').play();
// Animate dash effect
tween(dashEffect, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
dashEffect.destroy();
}
});
self.dashCooldown = 120; // 2 seconds at 60fps
};
self.bloodSlash = function (direction) {
if (self.slashCooldown > 0) return;
var slash = game.addChild(LK.getAsset('bloodSlash', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x + direction.x * 100,
y: self.y + direction.y * 100,
rotation: Math.atan2(direction.y, direction.x),
scaleX: 1.5,
scaleY: 1.2
}));
bloodSlashes.push(slash);
// Play slash sound
LK.getSound('slash').play();
// Animate slash
tween(slash, {
alpha: 0,
scaleX: 2.0,
scaleY: 1.5
}, {
duration: 300,
onFinish: function onFinish() {
slash.destroy();
var index = bloodSlashes.indexOf(slash);
if (index > -1) bloodSlashes.splice(index, 1);
}
});
self.slashCooldown = 30; // 0.5 seconds
};
self.energyFall = function () {
if (self.energyFallCooldown > 0) return;
var explosion = game.addChild(LK.getAsset('energyFall', {
anchorX: 0.5,
anchorY: 0.5,
x: self.x,
y: self.y,
alpha: 0.8,
scaleX: 0.1,
scaleY: 0.1
}));
energyFalls.push(explosion);
// Play explosion sound
LK.getSound('explosion').play();
// Animate explosion
tween(explosion, {
alpha: 0,
scaleX: 1,
scaleY: 1
}, {
duration: 500,
easing: tween.easeOut,
onFinish: function onFinish() {
explosion.destroy();
var index = energyFalls.indexOf(explosion);
if (index > -1) energyFalls.splice(index, 1);
}
});
self.energyFallCooldown = 300; // 5 seconds
};
return self;
});
var Enemy = Container.expand(function (enemyType) {
var self = Container.call(this);
var graphics = self.attachAsset(enemyType, {
anchorX: 0.5,
anchorY: 0.5
});
self.enemyType = enemyType;
self.health = 50;
self.speed = 2;
self.attackCooldown = 0;
self.lastPlayerX = 0;
self.lastPlayerY = 0;
// Set enemy-specific properties based on size (smaller to larger)
switch (enemyType) {
case 'velocorator':
// Smallest (60x80)
self.health = 25;
self.speed = 4;
break;
case 'delophospurus':
// Small-medium (70x100)
self.health = 75;
self.speed = 3;
break;
case 'stegospurus':
// Medium-large (100x90)
self.health = 150;
self.speed = 1.5;
break;
case 'tricerator':
// Largest (120x80)
self.health = 250;
self.speed = 1;
break;
}
self.update = function () {
if (self.attackCooldown > 0) self.attackCooldown--;
// AI: Move towards player
var dx = player.x - self.x;
var dy = player.y - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
var moveX = dx / distance * self.speed;
var moveY = dy / distance * self.speed;
self.x += moveX;
self.y += moveY;
// Face player
graphics.scaleX = dx > 0 ? 1 : -1;
}
// Keep enemy in bounds
if (self.x < 0) self.x = 0;
if (self.x > 2048) self.x = 2048;
if (self.y < 0) self.y = 0;
if (self.y > 2732) self.y = 2732;
};
self.takeDamage = function (damage) {
self.health -= damage;
// Flash red when hit
tween(graphics, {
tint: 0xff0000
}, {
duration: 100,
onFinish: function onFinish() {
tween(graphics, {
tint: 0xffffff
}, {
duration: 100
});
}
});
LK.getSound('vurmasesi').play();
if (self.health <= 0) {
LK.setScore(LK.getScore() + 25);
var scoreText = LK.gui.topLeft.children[1]; // Score text is the second child (index 1)
if (scoreText && scoreText.setText) {
scoreText.setText('Score: ' + LK.getScore().toString());
}
// Chance to drop power-up
if (Math.random() < 0.3) {
spawnPowerUp(self.x, self.y);
}
return true; // Enemy is dead
}
return false;
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5
});
self.collectTimer = 0;
self.update = function () {
self.collectTimer++;
// Pulse effect
var pulse = Math.sin(self.collectTimer * 0.1) * 0.3 + 1;
graphics.scaleX = pulse;
graphics.scaleY = pulse;
// Auto-destroy after 10 seconds
if (self.collectTimer > 600) {
self.destroy();
var index = powerUps.indexOf(self);
if (index > -1) powerUps.splice(index, 1);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000022
});
/****
* Game Code
****/
// Roman numeral conversion function
function toRomanNumeral(num) {
var romanNumerals = [{
value: 50,
symbol: 'L'
}, {
value: 40,
symbol: 'XL'
}, {
value: 10,
symbol: 'X'
}, {
value: 9,
symbol: 'IX'
}, {
value: 5,
symbol: 'V'
}, {
value: 4,
symbol: 'IV'
}, {
value: 1,
symbol: 'I'
}];
var result = '';
for (var i = 0; i < romanNumerals.length; i++) {
while (num >= romanNumerals[i].value) {
result += romanNumerals[i].symbol;
num -= romanNumerals[i].value;
}
}
return result;
}
// Game variables
var player;
var enemies = [];
var bloodSlashes = [];
var energyFalls = [];
var powerUps = [];
var waveNumber = 1;
var enemiesSpawned = 0;
var enemiesPerWave = 5;
var spawnTimer = 0;
var backgroundPulse = 0;
var lastTouchX = 0;
var lastTouchY = 0;
var moveKeys = {};
var forestElements = [];
var mistElements = [];
var gameStarted = false;
var welcomeScreen = null;
var startButton = null;
var welcomeText = null;
// Create forest background elements
function createForestBackground() {
// Left side trees
for (var i = 0; i < 8; i++) {
var leftTree = game.addChild(LK.getAsset('treeLeft', {
anchorX: 1,
anchorY: 1,
x: -50 + Math.random() * 150,
y: 200 + i * 300,
alpha: 0.6 + Math.random() * 0.3,
scaleX: 0.8 + Math.random() * 0.4,
scaleY: 0.8 + Math.random() * 0.4
}));
forestElements.push(leftTree);
}
// Right side trees
for (var i = 0; i < 8; i++) {
var rightTree = game.addChild(LK.getAsset('treeRight', {
anchorX: 0,
anchorY: 1,
x: 1950 + Math.random() * 150,
y: 150 + i * 320,
alpha: 0.5 + Math.random() * 0.4,
scaleX: 0.7 + Math.random() * 0.5,
scaleY: 0.9 + Math.random() * 0.3
}));
forestElements.push(rightTree);
}
// Top edge trees
for (var i = 0; i < 6; i++) {
var topTree = game.addChild(LK.getAsset('treeTop', {
anchorX: 0.5,
anchorY: 1,
x: 300 + i * 280,
y: -20 + Math.random() * 100,
alpha: 0.4 + Math.random() * 0.3,
scaleX: 0.6 + Math.random() * 0.4,
scaleY: 0.8 + Math.random() * 0.4
}));
forestElements.push(topTree);
}
// Bottom edge trees
for (var i = 0; i < 6; i++) {
var bottomTree = game.addChild(LK.getAsset('treeBottom', {
anchorX: 0.5,
anchorY: 0,
x: 250 + i * 300,
y: 2650 + Math.random() * 100,
alpha: 0.5 + Math.random() * 0.2,
scaleX: 0.7 + Math.random() * 0.3,
scaleY: 0.9 + Math.random() * 0.2
}));
forestElements.push(bottomTree);
}
// Create mysterious mist effects
for (var i = 0; i < 12; i++) {
var mist = game.addChild(LK.getAsset('mistEffect', {
anchorX: 0.5,
anchorY: 0.5,
x: 200 + Math.random() * 1600,
y: 200 + Math.random() * 2300,
alpha: 0.1 + Math.random() * 0.15,
scaleX: 1 + Math.random() * 2,
scaleY: 0.5 + Math.random() * 1
}));
mistElements.push(mist);
}
// Add some cave art/ancient symbols
for (var i = 0; i < 4; i++) {
var caveArt = game.addChild(LK.getAsset('caveArt', {
anchorX: 0.5,
anchorY: 0.5,
x: 100 + Math.random() * 150,
y: 300 + i * 500,
alpha: 0.3 + Math.random() * 0.2,
rotation: Math.random() * Math.PI * 2
}));
forestElements.push(caveArt);
}
}
// Create welcome screen
function createWelcomeScreen() {
// Create semi-transparent background
welcomeScreen = game.addChild(LK.getAsset('treeTop', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366,
alpha: 0.8,
scaleX: 10,
scaleY: 15,
tint: 0x000000
}));
// Create welcome message
welcomeText = new Text2('This game is designed\nto be played on computer', {
size: 80,
fill: '#ffffff'
});
welcomeText.anchor.set(0.5, 0.5);
welcomeText.x = 1024;
welcomeText.y = 1100;
game.addChild(welcomeText);
// Create start button (arrow)
startButton = game.addChild(LK.getAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1600,
scaleX: 3,
scaleY: 3,
tint: 0x00ff00
}));
// Add pulsing effect to start button
tween(startButton, {
scaleX: 3.5,
scaleY: 3.5
}, {
duration: 800,
yoyo: true,
repeat: -1
});
}
// Create welcome screen first
createWelcomeScreen();
// Create forest background
createForestBackground();
// Spawn power-up function
function spawnPowerUp(x, y) {
var powerUp = game.addChild(new PowerUp());
powerUp.x = x;
powerUp.y = y;
powerUps.push(powerUp);
}
// Spawn enemy function
function spawnEnemy() {
var enemyTypes = ['delophospurus', 'stegospurus', 'tricerator', 'velocorator'];
var randomType = enemyTypes[Math.floor(Math.random() * enemyTypes.length)];
var enemy = game.addChild(new Enemy(randomType));
// Spawn at random edge
var edge = Math.floor(Math.random() * 4);
switch (edge) {
case 0:
// Top
enemy.x = Math.random() * 2048;
enemy.y = -50;
break;
case 1:
// Right
enemy.x = 2098;
enemy.y = Math.random() * 2732;
break;
case 2:
// Bottom
enemy.x = Math.random() * 2048;
enemy.y = 2782;
break;
case 3:
// Left
enemy.x = -50;
enemy.y = Math.random() * 2732;
break;
}
enemies.push(enemy);
}
// Function to start the game
function startGame() {
if (gameStarted) return;
gameStarted = true;
// Remove welcome screen
if (welcomeScreen) {
welcomeScreen.destroy();
welcomeScreen = null;
}
// Remove start button
if (startButton) {
startButton.destroy();
startButton = null;
}
// Remove welcome text
if (welcomeText) {
welcomeText.destroy();
welcomeText = null;
}
// Clear GUI
LK.gui.center.removeChildren();
// Create player
player = game.addChild(new BlueRaptor());
player.x = 1024;
player.y = 1366;
// Create UI with enhanced styling
// Score panel background
var scorePanel = game.addChild(LK.getAsset('treeTop', {
anchorX: 0,
anchorY: 0,
x: 100,
y: 30,
scaleX: 1.2,
scaleY: 0.8,
alpha: 0.3,
tint: 0x004444
}));
LK.gui.topLeft.addChild(scorePanel);
var scoreText = new Text2('Score: 0', {
size: 60,
fill: '#00ffff',
stroke: '#004444',
strokeThickness: 3,
dropShadow: true,
dropShadowColor: '#000000',
dropShadowBlur: 5,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 4
});
scoreText.anchor.set(0, 0);
scoreText.x = 120;
scoreText.y = 50;
LK.gui.topLeft.addChild(scoreText);
// Add pulsing animation to score
tween(scoreText, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 1000,
yoyo: true,
repeat: -1,
easing: tween.easeInOut
});
// Health bar background
var healthBarBg = game.addChild(LK.getAsset('treeBottom', {
anchorX: 1,
anchorY: 0,
x: -20,
y: 40,
scaleX: 1.5,
scaleY: 0.3,
alpha: 0.4,
tint: 0x330000
}));
LK.gui.topRight.addChild(healthBarBg);
// Health bar fill
var healthBarFill = game.addChild(LK.getAsset('treeBottom', {
anchorX: 1,
anchorY: 0,
x: -20,
y: 40,
scaleX: 1.5,
scaleY: 0.3,
alpha: 0.8,
tint: 0x00ff00
}));
LK.gui.topRight.addChild(healthBarFill);
// Health text
var healthText = new Text2('Health: 100', {
size: 45,
fill: '#ffffff',
stroke: '#000000',
strokeThickness: 2,
dropShadow: true,
dropShadowColor: '#000000',
dropShadowBlur: 3,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 2
});
healthText.anchor.set(1, 0);
healthText.x = -30;
healthText.y = 80;
LK.gui.topRight.addChild(healthText);
// Wave banner background
var waveBanner = game.addChild(LK.getAsset('treeTop', {
anchorX: 0.5,
anchorY: 0,
x: 0,
y: 30,
scaleX: 3,
scaleY: 1,
alpha: 0.4,
tint: 0x444400
}));
LK.gui.top.addChild(waveBanner);
// Wave progress circle background
var waveCircleBg = game.addChild(LK.getAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: 70,
scaleX: 3,
scaleY: 3,
alpha: 0.3,
tint: 0x333333
}));
LK.gui.top.addChild(waveCircleBg);
// Wave progress circle fill
var waveCircleFill = game.addChild(LK.getAsset('powerUp', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: 70,
scaleX: 2.5,
scaleY: 2.5,
alpha: 0.6,
tint: 0xffff00
}));
LK.gui.top.addChild(waveCircleFill);
var waveText = new Text2('Wave I', {
size: 60,
fill: '#ffff00',
stroke: '#444400',
strokeThickness: 3,
dropShadow: true,
dropShadowColor: '#000000',
dropShadowBlur: 5,
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 4
});
waveText.anchor.set(0.5, 0);
LK.gui.top.addChild(waveText);
// Add glowing animation to wave text
tween(waveText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 800,
yoyo: true,
repeat: -1,
easing: tween.easeInOut
});
// Start background music with fade-in effect
LK.playMusic('ses', {
loop: true,
fade: {
start: 0,
end: 0.7,
duration: 1000
}
});
}
// Touch controls
game.down = function (x, y, obj) {
if (!gameStarted) {
// Check if clicked on start button area - use coordinates directly
var buttonBounds = {
x: 1024 - 100,
y: 1600 - 100,
width: 200,
height: 200
};
if (x >= buttonBounds.x && x <= buttonBounds.x + buttonBounds.width && y >= buttonBounds.y && y <= buttonBounds.y + buttonBounds.height) {
startGame();
}
return;
}
lastTouchX = x;
lastTouchY = y;
// Double tap for shadow dash
if (obj.tapCount === 2) {
player.shadowDash(x, y);
}
};
game.up = function (x, y, obj) {
if (!gameStarted) return;
var dx = x - player.x;
var dy = y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 50) {
// Blood slash in direction of touch
var direction = {
x: dx / distance,
y: dy / distance
};
player.bloodSlash(direction);
} else {
// Energy fall at current position
player.energyFall();
}
};
game.move = function (x, y, obj) {
if (!gameStarted) return;
// Move player towards touch position
var dx = x - player.x;
var dy = y - player.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 20) {
var moveX = dx / distance * player.speed;
var moveY = dy / distance * player.speed;
player.x += moveX;
player.y += moveY;
player.facing = dx > 0 ? 1 : -1;
player.isMoving = true;
} else {
player.isMoving = false;
}
};
// Main game loop
game.update = function () {
backgroundPulse += 0.05;
// Animate background color with darker forest tones
var pulseValue = Math.sin(backgroundPulse) * 0.08 + 0.08;
var bgColor = 0x001100 + Math.floor(pulseValue * 180) * 0x010101;
game.setBackgroundColor(bgColor);
// Animate mist effects
for (var i = 0; i < mistElements.length; i++) {
var mist = mistElements[i];
mist.alpha = 0.1 + Math.sin(backgroundPulse + i * 0.5) * 0.05;
mist.x += Math.sin(backgroundPulse * 0.3 + i) * 0.5;
}
// Only run game logic after game started
if (!gameStarted) return;
// Update UI with dynamic effects
var healthBarFill = LK.gui.topRight.children[1];
var healthText = LK.gui.topRight.children[2];
if (healthText && healthBarFill) {
healthText.setText('Health: ' + player.health);
// Dynamic health color based on health percentage
var healthPercent = player.health / player.maxHealth;
// Update health bar fill width
healthBarFill.scaleX = 1.5 * healthPercent;
if (healthPercent > 0.7) {
healthBarFill.tint = 0x00ff00; // Green for high health
} else if (healthPercent > 0.3) {
healthBarFill.tint = 0xffff00; // Yellow for medium health
} else {
healthBarFill.tint = 0xff0000; // Red for low health
// Add urgent pulsing for low health
if (healthPercent <= 0.3) {
tween(healthBarFill, {
scaleY: 0.4
}, {
duration: 300,
yoyo: true,
repeat: 1
});
}
}
}
// Add score increase animation
var scoreText = LK.gui.topLeft.children[1];
if (scoreText && LK.getScore() > 0) {
// Change color based on score milestones
var score = LK.getScore();
if (score >= 1000) {
scoreText.fill = '#ff00ff'; // Purple for high scores
} else if (score >= 500) {
scoreText.fill = '#ffd700'; // Gold for medium-high scores
} else if (score >= 250) {
scoreText.fill = '#ff8800'; // Orange for medium scores
} else {
scoreText.fill = '#00ffff'; // Cyan for low scores
}
// Animate score text when it changes
tween(scoreText, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 200,
yoyo: true,
repeat: 1
});
}
// Spawn enemies
if (enemiesSpawned < enemiesPerWave) {
spawnTimer++;
if (spawnTimer > 120) {
// Every 2 seconds
spawnEnemy();
enemiesSpawned++;
spawnTimer = 0;
}
}
// Update wave progress circle
var waveCircleFill = LK.gui.top.children[2];
if (waveCircleFill) {
var waveProgress = (enemiesPerWave - enemies.length) / enemiesPerWave;
waveCircleFill.scaleX = 2.5 * waveProgress;
waveCircleFill.scaleY = 2.5 * waveProgress;
}
// Check for wave completion
if (enemiesSpawned >= enemiesPerWave && enemies.length === 0) {
waveNumber++;
enemiesPerWave += 2;
enemiesSpawned = 0;
var waveText = LK.gui.top.children[3];
if (waveText) {
waveText.setText('Wave ' + toRomanNumeral(waveNumber));
// Add celebration animation for new wave
tween(waveText, {
scaleX: 2,
scaleY: 2,
rotation: Math.PI * 2
}, {
duration: 1000,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(waveText, {
scaleX: 1,
scaleY: 1,
rotation: 0
}, {
duration: 300
});
}
});
// Flash screen with golden color for wave completion
LK.effects.flashScreen(0xffd700, 500);
}
// Restore some health
player.health = Math.min(player.health + 20, player.maxHealth);
}
// Enemy vs player collision
for (var i = enemies.length - 1; i >= 0; i--) {
var enemy = enemies[i];
if (enemy.intersects(player)) {
if (!enemy.lastPlayerCollision) {
player.health -= 10;
enemy.lastPlayerCollision = true;
// Push player away
var dx = player.x - enemy.x;
var dy = player.y - enemy.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
player.x += dx / distance * 30;
player.y += dy / distance * 30;
}
// Screen shake effect
LK.effects.flashScreen(0xff0000, 200);
// Add dramatic health bar shake when damaged
var healthBarFill = LK.gui.topRight.children[1];
var healthText = LK.gui.topRight.children[2];
if (healthText && healthBarFill) {
tween(healthBarFill, {
scaleY: 0.5,
rotation: 0.1
}, {
duration: 100,
yoyo: true,
repeat: 3,
onFinish: function onFinish() {
healthBarFill.rotation = 0; // Reset rotation
}
});
tween(healthText, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
yoyo: true,
repeat: 2
});
}
if (player.health <= 0) {
LK.showGameOver();
}
}
} else {
enemy.lastPlayerCollision = false;
}
}
// Blood slash vs enemies
for (var i = bloodSlashes.length - 1; i >= 0; i--) {
var slash = bloodSlashes[i];
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (slash.intersects(enemy)) {
if (enemy.takeDamage(50)) {
enemy.destroy();
enemies.splice(j, 1);
}
}
}
}
// Energy fall vs enemies
for (var i = energyFalls.length - 1; i >= 0; i--) {
var explosion = energyFalls[i];
for (var j = enemies.length - 1; j >= 0; j--) {
var enemy = enemies[j];
if (explosion.intersects(enemy)) {
if (!enemy.lastExplosionHit) {
enemy.lastExplosionHit = true;
if (enemy.takeDamage(100)) {
enemy.destroy();
enemies.splice(j, 1);
}
}
} else {
enemy.lastExplosionHit = false;
}
}
}
// Power-up collection
for (var i = powerUps.length - 1; i >= 0; i--) {
var powerUp = powerUps[i];
if (powerUp.intersects(player)) {
// Restore health and reset cooldowns
player.health = Math.min(player.health + 30, player.maxHealth);
player.dashCooldown = Math.max(0, player.dashCooldown - 60);
player.slashCooldown = Math.max(0, player.slashCooldown - 30);
player.energyFallCooldown = Math.max(0, player.energyFallCooldown - 120);
powerUp.destroy();
powerUps.splice(i, 1);
}
}
};
bir rüzgar gibi bir şey retro oyunlardaki vurma efekti gibi olsun lazer ile rüzgarın karışımı birşey. In-Game asset. 2d. High contrast. No shadows
90'lardaki retro oyun dinazoru. vahşi olsun In-Game asset. 2d. High contrast. No shadows
90'lardaki retro oyun dinazoru. vahşi olsun. sarı olsun In-Game asset. 2d. High contrast. No shadows
90'lardaki retro oyun dinazoru. vahşi olsun. mavi ile sarı karışımı bir renk olsun In-Game asset. 2d. High contrast. No shadows
90'lardaki retro oyun dinazoru. vahşi olsun. diğer canavarlarda gibi olmayan renk olsun In-Game asset. 2d. High contrast. No shadows
90'lardaki retro oyun dinazoru. vahşi olsun. yeşil renk olsun In-Game asset. 2d. High contrast. No shadows