User prompt
respon cepat buat ranjau
User prompt
hilangkan score ganti dengan display waktu permainan
User prompt
buat kontrol halus untuk player ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
player bergerak sangat cepat ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
buat efek flash merah gelap saat terjadi ledakkan ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
buat logic baru bull berubah jadi drone
User prompt
perbaiki asset
User prompt
perbaiki
User prompt
tambah tiga asset bull. satu bull bergerak dari kiri ke kanan. satu bull lagi bergerak dari kanan ke kiri. satu lagi bergerak dari atas ke bawah
User prompt
banteng bergerak sesuai. kepala didepan ekor di belakang ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
tap dua kali untuk meliris ranjau
User prompt
rilis toucpad untuk keluarkan ranjau
User prompt
buat tombol touch pad khusus untuk merilis ranjau
User prompt
buat fitur skill player bisa meninggalkan ranjau. dan saat ranjau ditabrak musuh. musuh meledak ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Matador Master
Initial prompt
buat game side scroller 4 arah. game matador
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Bull = Container.expand(function () { var self = Container.call(this); var bullGraphics = self.attachAsset('bull', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.direction = { x: 0, y: 0 }; self.fromDirection = ''; // 'left', 'right', 'top', 'bottom' self.lastX = 0; self.lastY = 0; self.hasTriggeredNearMiss = false; self.bodySegments = []; // Array to store body segments self.trailPositions = []; // Array to store previous positions for trail effect self.segmentCount = 4; // Number of body segments self.segmentDistance = 30; // Distance between segments // Initialize body segments for (var i = 0; i < self.segmentCount; i++) { var segment = self.addChild(LK.getAsset('bull', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8 - i * 0.1, // Make segments smaller towards tail scaleY: 0.8 - i * 0.1, tint: 0x8B4513 // Brown color for body })); self.bodySegments.push(segment); } self.setDirection = function (dx, dy, from) { self.direction.x = dx; self.direction.y = dy; self.fromDirection = from; // Rotate bull to face movement direction if (dx > 0) bullGraphics.rotation = 0; // Right else if (dx < 0) bullGraphics.rotation = Math.PI; // Left else if (dy > 0) bullGraphics.rotation = Math.PI / 2; // Down else if (dy < 0) bullGraphics.rotation = -Math.PI / 2; // Up }; self.update = function () { self.lastX = self.x; self.lastY = self.y; // Store current position for trail self.trailPositions.unshift({ x: self.x, y: self.y }); // Keep only necessary positions for body segments if (self.trailPositions.length > self.segmentCount * 3) { self.trailPositions.pop(); } self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; // Update body segments to follow head for (var i = 0; i < self.bodySegments.length; i++) { var segment = self.bodySegments[i]; var targetIndex = (i + 1) * 3; // Space out segments if (targetIndex < self.trailPositions.length) { var targetPos = self.trailPositions[targetIndex]; segment.x = targetPos.x; segment.y = targetPos.y; // Rotate segment to face movement direction if (i > 0 && targetIndex + 3 < self.trailPositions.length) { var prevPos = self.trailPositions[targetIndex + 3]; var dx = targetPos.x - prevPos.x; var dy = targetPos.y - prevPos.y; if (dx > 0) segment.rotation = 0;else if (dx < 0) segment.rotation = Math.PI;else if (dy > 0) segment.rotation = Math.PI / 2;else if (dy < 0) segment.rotation = -Math.PI / 2; } } } // Check for near miss with matador if (!self.hasTriggeredNearMiss && matador) { var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2)); if (distance < 150 && distance > 100) { self.hasTriggeredNearMiss = true; nearMissScore += 5; LK.setScore(LK.getScore() + 5); scoreTxt.setText(LK.getScore()); LK.getSound('nearMiss').play(); LK.effects.flashScreen(0xffd700, 200); } } }; return self; }); var BullLeftToRight = Container.expand(function () { var self = Container.call(this); var bullGraphics = self.attachAsset('bullLeftToRight', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.direction = { x: 1, y: 0 }; self.fromDirection = 'left'; self.lastX = 0; self.lastY = 0; self.hasTriggeredNearMiss = false; self.bodySegments = []; self.trailPositions = []; self.segmentCount = 4; self.segmentDistance = 30; // Initialize body segments for (var i = 0; i < self.segmentCount; i++) { var segment = self.addChild(LK.getAsset('bullLeftToRight', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8 - i * 0.1, scaleY: 0.8 - i * 0.1, tint: 0x8B4513 })); self.bodySegments.push(segment); } // Set rotation to face right bullGraphics.rotation = 0; self.update = function () { self.lastX = self.x; self.lastY = self.y; // Store current position for trail self.trailPositions.unshift({ x: self.x, y: self.y }); // Keep only necessary positions for body segments if (self.trailPositions.length > self.segmentCount * 3) { self.trailPositions.pop(); } self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; // Update body segments to follow head for (var i = 0; i < self.bodySegments.length; i++) { var segment = self.bodySegments[i]; var targetIndex = (i + 1) * 3; if (targetIndex < self.trailPositions.length) { var targetPos = self.trailPositions[targetIndex]; segment.x = targetPos.x; segment.y = targetPos.y; segment.rotation = 0; // Always face right } } // Check for near miss with matador if (!self.hasTriggeredNearMiss && matador) { var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2)); if (distance < 150 && distance > 100) { self.hasTriggeredNearMiss = true; nearMissScore += 5; LK.setScore(LK.getScore() + 5); scoreTxt.setText(LK.getScore()); LK.getSound('nearMiss').play(); LK.effects.flashScreen(0xffd700, 200); } } }; return self; }); var BullRightToLeft = Container.expand(function () { var self = Container.call(this); var bullGraphics = self.attachAsset('bullRightToLeft', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.direction = { x: -1, y: 0 }; self.fromDirection = 'right'; self.lastX = 0; self.lastY = 0; self.hasTriggeredNearMiss = false; self.bodySegments = []; self.trailPositions = []; self.segmentCount = 4; self.segmentDistance = 30; // Initialize body segments for (var i = 0; i < self.segmentCount; i++) { var segment = self.addChild(LK.getAsset('bullRightToLeft', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8 - i * 0.1, scaleY: 0.8 - i * 0.1, tint: 0x8B4513 })); self.bodySegments.push(segment); } // Set rotation to face left bullGraphics.rotation = Math.PI; self.update = function () { self.lastX = self.x; self.lastY = self.y; // Store current position for trail self.trailPositions.unshift({ x: self.x, y: self.y }); // Keep only necessary positions for body segments if (self.trailPositions.length > self.segmentCount * 3) { self.trailPositions.pop(); } self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; // Update body segments to follow head for (var i = 0; i < self.bodySegments.length; i++) { var segment = self.bodySegments[i]; var targetIndex = (i + 1) * 3; if (targetIndex < self.trailPositions.length) { var targetPos = self.trailPositions[targetIndex]; segment.x = targetPos.x; segment.y = targetPos.y; segment.rotation = Math.PI; // Always face left } } // Check for near miss with matador if (!self.hasTriggeredNearMiss && matador) { var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2)); if (distance < 150 && distance > 100) { self.hasTriggeredNearMiss = true; nearMissScore += 5; LK.setScore(LK.getScore() + 5); scoreTxt.setText(LK.getScore()); LK.getSound('nearMiss').play(); LK.effects.flashScreen(0xffd700, 200); } } }; return self; }); var BullTopToBottom = Container.expand(function () { var self = Container.call(this); var bullGraphics = self.attachAsset('bullTopToBottom', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 8; self.direction = { x: 0, y: 1 }; self.fromDirection = 'top'; self.lastX = 0; self.lastY = 0; self.hasTriggeredNearMiss = false; self.bodySegments = []; self.trailPositions = []; self.segmentCount = 4; self.segmentDistance = 30; // Initialize body segments for (var i = 0; i < self.segmentCount; i++) { var segment = self.addChild(LK.getAsset('bullTopToBottom', { anchorX: 0.5, anchorY: 0.5, scaleX: 0.8 - i * 0.1, scaleY: 0.8 - i * 0.1, tint: 0x8B4513 })); self.bodySegments.push(segment); } // Set rotation to face down bullGraphics.rotation = Math.PI / 2; self.update = function () { self.lastX = self.x; self.lastY = self.y; // Store current position for trail self.trailPositions.unshift({ x: self.x, y: self.y }); // Keep only necessary positions for body segments if (self.trailPositions.length > self.segmentCount * 3) { self.trailPositions.pop(); } self.x += self.direction.x * self.speed; self.y += self.direction.y * self.speed; // Update body segments to follow head for (var i = 0; i < self.bodySegments.length; i++) { var segment = self.bodySegments[i]; var targetIndex = (i + 1) * 3; if (targetIndex < self.trailPositions.length) { var targetPos = self.trailPositions[targetIndex]; segment.x = targetPos.x; segment.y = targetPos.y; segment.rotation = Math.PI / 2; // Always face down } } // Check for near miss with matador if (!self.hasTriggeredNearMiss && matador) { var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2)); if (distance < 150 && distance > 100) { self.hasTriggeredNearMiss = true; nearMissScore += 5; LK.setScore(LK.getScore() + 5); scoreTxt.setText(LK.getScore()); LK.getSound('nearMiss').play(); LK.effects.flashScreen(0xffd700, 200); } } }; return self; }); var Matador = Container.expand(function () { var self = Container.call(this); var matadorGraphics = self.attachAsset('matador', { anchorX: 0.5, anchorY: 0.5 }); self.isDragging = false; self.targetX = 0; self.targetY = 0; self.speed = 12; self.update = function () { // Smooth movement towards target position if (self.isDragging) { var dx = self.targetX - self.x; var dy = self.targetY - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { self.x += dx / distance * self.speed; self.y += dy / distance * self.speed; } } // Keep matador within game bounds self.x = Math.max(50, Math.min(1998, self.x)); self.y = Math.max(50, Math.min(2682, self.y)); }; self.setTarget = function (x, y) { self.targetX = x; self.targetY = y; }; return self; }); var Mine = Container.expand(function () { var self = Container.call(this); var mineGraphics = self.attachAsset('mine', { anchorX: 0.5, anchorY: 0.5 }); self.isArmed = false; self.armTimer = 0; self.armDelay = 30; // 0.5 seconds to arm self.update = function () { // Arm the mine after delay if (!self.isArmed) { self.armTimer++; if (self.armTimer >= self.armDelay) { self.isArmed = true; mineGraphics.tint = 0xff0000; // Turn red when armed } } }; self.explode = function () { // Visual explosion effect LK.effects.flashScreen(0xffaa00, 300); tween(mineGraphics, { scaleX: 3, scaleY: 3, alpha: 0 }, { duration: 500, onFinish: function onFinish() { self.destroy(); } }); LK.getSound('explosion').play(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xcd853f }); /**** * Game Code ****/ // Game variables var matador; var bulls = []; var mines = []; var bullSpawnTimer = 0; var bullSpawnInterval = 120; // Start spawning every 2 seconds var gameSpeed = 1; var nearMissScore = 0; var difficultyTimer = 0; var mineSkillCooldown = 0; var mineSkillCooldownMax = 180; // 3 seconds cooldown var lastTapTime = 0; var tapCount = 0; var doubleTapDelay = 500; // 500ms window for double tap // Create arena background var arenaBackground = game.attachAsset('arena', { anchorX: 0, anchorY: 0, x: 0, y: 0 }); // Create matador matador = game.addChild(new Matador()); matador.x = 1024; matador.y = 1366; // Create score display var scoreTxt = new Text2('0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create near miss indicator var nearMissText = new Text2('¡Olé!', { size: 80, fill: 0xFFD700 }); nearMissText.anchor.set(0.5, 0.5); nearMissText.alpha = 0; LK.gui.center.addChild(nearMissText); // Bull spawning function function spawnBull() { var bull = new Bull(); var spawnSide = Math.floor(Math.random() * 4); // Determine spawn position and direction switch (spawnSide) { case 0: // Left side bull.x = -60; bull.y = Math.random() * 2732; bull.setDirection(1, 0, 'left'); break; case 1: // Right side bull.x = 2108; bull.y = Math.random() * 2732; bull.setDirection(-1, 0, 'right'); break; case 2: // Top side bull.x = Math.random() * 2048; bull.y = -40; bull.setDirection(0, 1, 'top'); break; case 3: // Bottom side bull.x = Math.random() * 2048; bull.y = 2772; bull.setDirection(0, -1, 'bottom'); break; } bulls.push(bull); game.addChild(bull); LK.getSound('charge').play(); } // Spawn bull left to right function spawnBullLeftToRight() { var bull = new BullLeftToRight(); bull.x = -60; bull.y = Math.random() * 2732; bulls.push(bull); game.addChild(bull); LK.getSound('charge').play(); } // Spawn bull right to left function spawnBullRightToLeft() { var bull = new BullRightToLeft(); bull.x = 2108; bull.y = Math.random() * 2732; bulls.push(bull); game.addChild(bull); LK.getSound('charge').play(); } // Spawn bull top to bottom function spawnBullTopToBottom() { var bull = new BullTopToBottom(); bull.x = Math.random() * 2048; bull.y = -40; bulls.push(bull); game.addChild(bull); LK.getSound('charge').play(); } // Handle mouse/touch movement function handleMove(x, y, obj) { if (matador && matador.isDragging) { matador.setTarget(x, y); } } // Mouse/touch down handler game.down = function (x, y, obj) { if (matador) { matador.isDragging = true; matador.setTarget(x, y); // Double tap detection var currentTime = Date.now(); if (currentTime - lastTapTime < doubleTapDelay) { tapCount++; } else { tapCount = 1; } lastTapTime = currentTime; // Lay mine if double tap detected and skill is available if (tapCount >= 2 && mineSkillCooldown <= 0) { var mine = new Mine(); mine.x = matador.x; mine.y = matador.y; mines.push(mine); game.addChild(mine); mineSkillCooldown = mineSkillCooldownMax; tapCount = 0; // Reset tap count after laying mine } } }; // Mouse/touch up handler game.up = function (x, y, obj) { if (matador) { matador.isDragging = false; } }; // Mouse/touch move handler game.move = handleMove; // Track collision state var lastColliding = false; // Main game update loop game.update = function () { // Update bull spawn timer bullSpawnTimer++; if (bullSpawnTimer >= bullSpawnInterval) { // Randomly spawn one of the four bull types var bullType = Math.floor(Math.random() * 4); switch (bullType) { case 0: spawnBull(); break; case 1: spawnBullLeftToRight(); break; case 2: spawnBullRightToLeft(); break; case 3: spawnBullTopToBottom(); break; } bullSpawnTimer = 0; } // Increase difficulty over time difficultyTimer++; if (difficultyTimer >= 1800) { // Every 30 seconds difficultyTimer = 0; gameSpeed += 0.2; bullSpawnInterval = Math.max(60, bullSpawnInterval - 10); } // Update mine cooldown if (mineSkillCooldown > 0) { mineSkillCooldown--; } // Update and check bulls for (var i = bulls.length - 1; i >= 0; i--) { var bull = bulls[i]; var bullExploded = false; // Check collision with mines for (var j = mines.length - 1; j >= 0; j--) { var mine = mines[j]; if (mine.isArmed && bull.intersects(mine)) { // Mine explosion mine.explode(); mines.splice(j, 1); bull.destroy(); bulls.splice(i, 1); bullExploded = true; // Award bonus points for mine kill LK.setScore(LK.getScore() + 25); scoreTxt.setText(LK.getScore()); break; } } if (bullExploded) continue; // Check collision with matador var currentColliding = bull.intersects(matador); if (!lastColliding && currentColliding) { // Collision detected - game over LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); return; } // Remove bulls that are off screen var offScreen = false; if (bull.fromDirection === 'left' && bull.x > 2100) offScreen = true; if (bull.fromDirection === 'right' && bull.x < -100) offScreen = true; if (bull.fromDirection === 'top' && bull.y > 2800) offScreen = true; if (bull.fromDirection === 'bottom' && bull.y < -100) offScreen = true; if (offScreen) { bull.destroy(); bulls.splice(i, 1); // Award points for successful dodge LK.setScore(LK.getScore() + 10); scoreTxt.setText(LK.getScore()); } } // Update score display scoreTxt.setText(LK.getScore()); // Show near miss text effect if (nearMissScore > 0) { nearMissText.alpha = 1; tween(nearMissText, { alpha: 0 }, { duration: 1000 }); nearMissScore = 0; } }; // Start background music LK.playMusic('flamenco');
===================================================================
--- original.js
+++ change.js
@@ -92,8 +92,224 @@
}
};
return self;
});
+var BullLeftToRight = Container.expand(function () {
+ var self = Container.call(this);
+ var bullGraphics = self.attachAsset('bullLeftToRight', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.direction = {
+ x: 1,
+ y: 0
+ };
+ self.fromDirection = 'left';
+ self.lastX = 0;
+ self.lastY = 0;
+ self.hasTriggeredNearMiss = false;
+ self.bodySegments = [];
+ self.trailPositions = [];
+ self.segmentCount = 4;
+ self.segmentDistance = 30;
+ // Initialize body segments
+ for (var i = 0; i < self.segmentCount; i++) {
+ var segment = self.addChild(LK.getAsset('bullLeftToRight', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8 - i * 0.1,
+ scaleY: 0.8 - i * 0.1,
+ tint: 0x8B4513
+ }));
+ self.bodySegments.push(segment);
+ }
+ // Set rotation to face right
+ bullGraphics.rotation = 0;
+ self.update = function () {
+ self.lastX = self.x;
+ self.lastY = self.y;
+ // Store current position for trail
+ self.trailPositions.unshift({
+ x: self.x,
+ y: self.y
+ });
+ // Keep only necessary positions for body segments
+ if (self.trailPositions.length > self.segmentCount * 3) {
+ self.trailPositions.pop();
+ }
+ self.x += self.direction.x * self.speed;
+ self.y += self.direction.y * self.speed;
+ // Update body segments to follow head
+ for (var i = 0; i < self.bodySegments.length; i++) {
+ var segment = self.bodySegments[i];
+ var targetIndex = (i + 1) * 3;
+ if (targetIndex < self.trailPositions.length) {
+ var targetPos = self.trailPositions[targetIndex];
+ segment.x = targetPos.x;
+ segment.y = targetPos.y;
+ segment.rotation = 0; // Always face right
+ }
+ }
+ // Check for near miss with matador
+ if (!self.hasTriggeredNearMiss && matador) {
+ var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2));
+ if (distance < 150 && distance > 100) {
+ self.hasTriggeredNearMiss = true;
+ nearMissScore += 5;
+ LK.setScore(LK.getScore() + 5);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('nearMiss').play();
+ LK.effects.flashScreen(0xffd700, 200);
+ }
+ }
+ };
+ return self;
+});
+var BullRightToLeft = Container.expand(function () {
+ var self = Container.call(this);
+ var bullGraphics = self.attachAsset('bullRightToLeft', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.direction = {
+ x: -1,
+ y: 0
+ };
+ self.fromDirection = 'right';
+ self.lastX = 0;
+ self.lastY = 0;
+ self.hasTriggeredNearMiss = false;
+ self.bodySegments = [];
+ self.trailPositions = [];
+ self.segmentCount = 4;
+ self.segmentDistance = 30;
+ // Initialize body segments
+ for (var i = 0; i < self.segmentCount; i++) {
+ var segment = self.addChild(LK.getAsset('bullRightToLeft', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8 - i * 0.1,
+ scaleY: 0.8 - i * 0.1,
+ tint: 0x8B4513
+ }));
+ self.bodySegments.push(segment);
+ }
+ // Set rotation to face left
+ bullGraphics.rotation = Math.PI;
+ self.update = function () {
+ self.lastX = self.x;
+ self.lastY = self.y;
+ // Store current position for trail
+ self.trailPositions.unshift({
+ x: self.x,
+ y: self.y
+ });
+ // Keep only necessary positions for body segments
+ if (self.trailPositions.length > self.segmentCount * 3) {
+ self.trailPositions.pop();
+ }
+ self.x += self.direction.x * self.speed;
+ self.y += self.direction.y * self.speed;
+ // Update body segments to follow head
+ for (var i = 0; i < self.bodySegments.length; i++) {
+ var segment = self.bodySegments[i];
+ var targetIndex = (i + 1) * 3;
+ if (targetIndex < self.trailPositions.length) {
+ var targetPos = self.trailPositions[targetIndex];
+ segment.x = targetPos.x;
+ segment.y = targetPos.y;
+ segment.rotation = Math.PI; // Always face left
+ }
+ }
+ // Check for near miss with matador
+ if (!self.hasTriggeredNearMiss && matador) {
+ var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2));
+ if (distance < 150 && distance > 100) {
+ self.hasTriggeredNearMiss = true;
+ nearMissScore += 5;
+ LK.setScore(LK.getScore() + 5);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('nearMiss').play();
+ LK.effects.flashScreen(0xffd700, 200);
+ }
+ }
+ };
+ return self;
+});
+var BullTopToBottom = Container.expand(function () {
+ var self = Container.call(this);
+ var bullGraphics = self.attachAsset('bullTopToBottom', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 8;
+ self.direction = {
+ x: 0,
+ y: 1
+ };
+ self.fromDirection = 'top';
+ self.lastX = 0;
+ self.lastY = 0;
+ self.hasTriggeredNearMiss = false;
+ self.bodySegments = [];
+ self.trailPositions = [];
+ self.segmentCount = 4;
+ self.segmentDistance = 30;
+ // Initialize body segments
+ for (var i = 0; i < self.segmentCount; i++) {
+ var segment = self.addChild(LK.getAsset('bullTopToBottom', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8 - i * 0.1,
+ scaleY: 0.8 - i * 0.1,
+ tint: 0x8B4513
+ }));
+ self.bodySegments.push(segment);
+ }
+ // Set rotation to face down
+ bullGraphics.rotation = Math.PI / 2;
+ self.update = function () {
+ self.lastX = self.x;
+ self.lastY = self.y;
+ // Store current position for trail
+ self.trailPositions.unshift({
+ x: self.x,
+ y: self.y
+ });
+ // Keep only necessary positions for body segments
+ if (self.trailPositions.length > self.segmentCount * 3) {
+ self.trailPositions.pop();
+ }
+ self.x += self.direction.x * self.speed;
+ self.y += self.direction.y * self.speed;
+ // Update body segments to follow head
+ for (var i = 0; i < self.bodySegments.length; i++) {
+ var segment = self.bodySegments[i];
+ var targetIndex = (i + 1) * 3;
+ if (targetIndex < self.trailPositions.length) {
+ var targetPos = self.trailPositions[targetIndex];
+ segment.x = targetPos.x;
+ segment.y = targetPos.y;
+ segment.rotation = Math.PI / 2; // Always face down
+ }
+ }
+ // Check for near miss with matador
+ if (!self.hasTriggeredNearMiss && matador) {
+ var distance = Math.sqrt(Math.pow(self.x - matador.x, 2) + Math.pow(self.y - matador.y, 2));
+ if (distance < 150 && distance > 100) {
+ self.hasTriggeredNearMiss = true;
+ nearMissScore += 5;
+ LK.setScore(LK.getScore() + 5);
+ scoreTxt.setText(LK.getScore());
+ LK.getSound('nearMiss').play();
+ LK.effects.flashScreen(0xffd700, 200);
+ }
+ }
+ };
+ return self;
+});
var Matador = Container.expand(function () {
var self = Container.call(this);
var matadorGraphics = self.attachAsset('matador', {
anchorX: 0.5,
@@ -245,8 +461,35 @@
bulls.push(bull);
game.addChild(bull);
LK.getSound('charge').play();
}
+// Spawn bull left to right
+function spawnBullLeftToRight() {
+ var bull = new BullLeftToRight();
+ bull.x = -60;
+ bull.y = Math.random() * 2732;
+ bulls.push(bull);
+ game.addChild(bull);
+ LK.getSound('charge').play();
+}
+// Spawn bull right to left
+function spawnBullRightToLeft() {
+ var bull = new BullRightToLeft();
+ bull.x = 2108;
+ bull.y = Math.random() * 2732;
+ bulls.push(bull);
+ game.addChild(bull);
+ LK.getSound('charge').play();
+}
+// Spawn bull top to bottom
+function spawnBullTopToBottom() {
+ var bull = new BullTopToBottom();
+ bull.x = Math.random() * 2048;
+ bull.y = -40;
+ bulls.push(bull);
+ game.addChild(bull);
+ LK.getSound('charge').play();
+}
// Handle mouse/touch movement
function handleMove(x, y, obj) {
if (matador && matador.isDragging) {
matador.setTarget(x, y);
@@ -291,9 +534,24 @@
game.update = function () {
// Update bull spawn timer
bullSpawnTimer++;
if (bullSpawnTimer >= bullSpawnInterval) {
- spawnBull();
+ // Randomly spawn one of the four bull types
+ var bullType = Math.floor(Math.random() * 4);
+ switch (bullType) {
+ case 0:
+ spawnBull();
+ break;
+ case 1:
+ spawnBullLeftToRight();
+ break;
+ case 2:
+ spawnBullRightToLeft();
+ break;
+ case 3:
+ spawnBullTopToBottom();
+ break;
+ }
bullSpawnTimer = 0;
}
// Increase difficulty over time
difficultyTimer++;
war drone scifi model In-Game asset. 2d. High contrast. No shadows
scifi quad copter drone. In-Game asset. 2d. High contrast. No shadows
top down view scifi quad copter drone. red scorpion In-Game asset. 2d. High contrast. No shadows
sci fi floating war mine with red light In-Game asset. 2d. High contrast. No shadows
red and yellow mix orb. In-Game asset. 2d. High contrast. No shadows
langit malam dikejauhan kota modern dengan lampu lampu sorot ke atas langit . anime 2d. High contrast. No shadows