Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
No están tirando objetos a la moto, mejora la aparición de las personas y objetos al lado de la ruta. Deben aparecer antes y asegúrate que siguen escalando y alejándose del centro hasta salir por completo de la pantalla, pin un margen alto ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Cada 10 segundos debe repetirse aleatoriamente una de seis frases que serán assets de sonido
Code edit (2 edits merged)
Please save this source code
User prompt
Los objetos al lado del camino deben estar mucho más espaciados ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'play')' in or related to this line: 'LK.playMusic('moto').play();' Line Number: 51
Code edit (13 edits merged)
Please save this source code
User prompt
Debe salir del asset karina o de truck1 que es lo mismo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
El ítem debe salir desde el asset karina y debe caer el algún lugar random de la ruta siguiendo una parábola ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Los assets al lado de la ruta deben seguir escalando y alejarse del centro hasta salir por completo, ahora falla al final ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Cuando l al personas los árboles y los carteles digan de la pantalla, en ves de seguir escalando y alejarse del centro simplemente bajan y rompen la perspectiva ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
El juego debe tener una barra de power vertical a la derecha, cuando un proyectil lo golpea debe bajar un 3% de la barra, también habrá otro tipo de proyectil que le bajará un 50%, la camioneta debe ser una sola y debe estar siempre delante de la moto bastante alejada, la camioneta debe arrojar ítem que restauran un 3% el power ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Cuando la moto pasa de la mitad izquierda debe hacer un flip en el eje y para que de la sensacion de peespectiva ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Están tirando muchos proyectiles no debe haber más de 3 proyectiles al mismo tiempo
Code edit (1 edits merged)
Please save this source code
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Motorcycle = Container.expand(function () { var self = Container.call(this); var motorcycleGraphics = self.attachAsset('motorcycle', { anchorX: 0.5, anchorY: 0.5 }); self.health = 3; self.power = 100; // Power bar from 0-100% self.speed = 0; self.maxSpeed = 8; self.x = 129; self.update = function () { if (gameStarted) { // Gradually increase speed if (self.speed < self.maxSpeed) { self.speed += 0.02; } // Move forward (simulate road movement) roadOffset += self.speed; } }; self.takeDamage = function (damageAmount) { damageAmount = damageAmount || 3; // Default 3% damage self.power = Math.max(0, self.power - damageAmount); // Flash red when hit LK.effects.flashObject(self, 0xff0000, 500); LK.getSound('hit').play(); if (self.power <= 0) { LK.showGameOver(); } }; self.restorePower = function (amount) { amount = amount || 3; // Default 3% restoration self.power = Math.min(100, self.power + amount); LK.getSound('power_up').play(); }; return self; }); var PowerItem = Container.expand(function () { var self = Container.call(this); var itemGraphics = self.attachAsset('power_item', { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.gravity = 0.15; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += self.gravity; }; return self; }); var Projectile = Container.expand(function (isHeavy) { var self = Container.call(this); self.isHeavy = isHeavy || false; var assetName = self.isHeavy ? 'heavy_projectile' : 'projectile'; var projectileGraphics = self.attachAsset(assetName, { anchorX: 0.5, anchorY: 0.5 }); self.velocityX = 0; self.velocityY = 0; self.gravity = 0; self.update = function () { self.x += self.velocityX; self.y += self.velocityY; self.velocityY += self.gravity; // Rotate projectile based on velocity self.rotation += 0.1; }; return self; }); var RoadsideObject = Container.expand(function (type) { var self = Container.call(this); self.objectType = type || 'person'; var objectGraphics = self.attachAsset(self.objectType, { anchorX: 0.5, anchorY: 1.0 }); self.throwTimer = 0; self.throwDelay = Math.random() * 180 + 60; // Random delay between throws self.isLeftSide = true; self.originalY = 0; // Store original Y position for movement animation self.hasThrownThisCycle = false; // Evita lanzar dos veces por ciclo self.minThrowDistanceFromMotorcycle = 900; // Debe lanzar cuando est lo suficientemente lejos self.update = function () { // Only people throw objects if (self.objectType === 'person') { self.throwTimer++; if (self.throwTimer >= self.throwDelay && gameStarted && !self.hasThrownThisCycle) { // Lanza solo si a est lejos de la moto if (self.y <= motorcycle.y - self.minThrowDistanceFromMotorcycle) { self.throwObject(); self.hasThrownThisCycle = true; self.throwTimer = 0; self.throwDelay = Math.random() * 120 + 400; // Next throw delay } } } // Move object backward to simulate forward motion if (gameStarted && motorcycle.speed > 0) { self.y += motorcycle.speed * 3; // Calculate current perspective for this object var currentDistance = Math.max(0, roadY - self.y); var perspective = Math.max(0.01, Math.min(1, 1 - currentDistance / horizonDistance)); var roadWidth = 2048 * perspective; // Update object position and scale based on perspective if (self.isLeftSide) { self.x = 1024 - roadWidth / 2 - 120 * perspective; } else { self.x = 1024 + roadWidth / 2 + 120 * perspective; } self.scaleX = perspective; self.scaleY = perspective; // Lanzar tan pronto como est suficientemente lejos, independiente del temporizador if (gameStarted && self.objectType === 'person' && !self.hasThrownThisCycle) { if (self.y <= motorcycle.y - self.minThrowDistanceFromMotorcycle) { self.throwObject(); self.hasThrownThisCycle = true; self.throwTimer = 0; self.throwDelay = Math.random() * 120 + 400; } } // Reset object position when it goes past the bottom if (self.y > roadY + 200) { self.y = self.originalY; // Reset scale for new cycle var resetDistance = roadY - self.originalY; var resetPerspective = Math.max(0.01, Math.min(1, 1 - resetDistance / horizonDistance)); self.scaleX = resetPerspective; self.scaleY = resetPerspective; self.hasThrownThisCycle = false; // listo para lanzar en el nuevo ciclo } } }; self.throwObject = function () { // Only throw if there are less than 3 projectiles if (projectiles.length >= 3) { return; // Don't throw if we already have 3 or more projectiles } // 15% chance of throwing heavy projectile var isHeavy = Math.random() < 0.15; var projectile = new Projectile(isHeavy); projectile.x = self.x; projectile.y = self.y - 20; // Parbola fcil de esquivar: velocidad horizontal menor y impulso hacia arriba var targetX = motorcycle.x + (Math.random() - 0.5) * 260; // ligera variacin var horizontalFactor = isHeavy ? 0.009 : 0.008; // ms lento projectile.velocityX = (targetX - projectile.x) * horizontalFactor; // Impulso inicial hacia arriba para crear arco var initialUpImpulse = isHeavy ? -6 - Math.random() * 2 : -8 - Math.random() * 3; projectile.velocityY = initialUpImpulse; projectile.gravity = isHeavy ? 0.35 : 0.28; projectiles.push(projectile); game.addChild(projectile); LK.getSound('throw').play(); }; return self; }); var Truck = Container.expand(function () { var self = Container.call(this); var truckGraphics = self.attachAsset('truck', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -6; self.active = true; self.dropTimer = 0; self.dropDelay = 180; // Drop item every 3 seconds self.targetY = horizonY + (roadY - horizonY) * 0.25; // Mantenerse a 1/4 de pantalla (en la zona visible entre horizonte y piso) self.baseX = 1600; // lado derecho self.oscAmp = 30; // amplitud leve en X self.oscSpeed = 0.02; // velocidad de oscilacin self.oscPhase = Math.random() * Math.PI * 2; self.update = function () { if (self.active) { // Avanzar hasta targetY y mantenerse allí if (self.y > self.targetY) { self.y += self.speed; // speed negativa: sube hacia targetY if (self.y <= self.targetY) { self.y = self.targetY; } } else { self.y = self.targetY; } // Posicin en X hacia la derecha con leve oscilacin self.oscPhase += self.oscSpeed; self.x = self.baseX + Math.sin(self.oscPhase) * self.oscAmp; // Calculate perspective based on distance to horizon var distanceToHorizon = roadY - horizonY; // Total distance from bottom to horizon var currentDistance = roadY - self.y; // Current distance from bottom var perspective = Math.max(0, 1 - currentDistance / distanceToHorizon); // Perspective ratio // Move horizontally toward center point (1024) as truck approaches horizon var centerX = 1024; // Scale trucks according to perspective self.scaleX = perspective; self.scaleY = perspective; // Drop power items periodically if (gameStarted) { self.dropTimer++; if (self.dropTimer >= self.dropDelay) { self.dropPowerItem(); self.dropTimer = 0; } } // Reset truck when it reaches horizon instead of deactivating } }; self.dropPowerItem = function () { var powerItem = new PowerItem(); powerItem.x = self.x + (Math.random() - 0.5) * 100; powerItem.y = self.y + 50; // Calculate trajectory toward road var targetX = motorcycle.x + (Math.random() - 0.5) * 300; var targetY = roadY; powerItem.velocityX = (targetX - powerItem.x) * 0.01; powerItem.velocityY = (targetY - powerItem.y) * 0.008; powerItems.push(powerItem); game.addChild(powerItem); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ var roadY = 2732; // Position road at very bottom of screen var horizonY = 1366; // Horizon at middle height of screen (2732/2) var roadOffset = 0; var gameStarted = false; var trucksCleared = false; // Create perspective road using segments var roadSegments = []; var roadLines = []; var leftSidewalks = []; var rightSidewalks = []; // Create road segments that form triangular perspective from full width to horizon var totalSegments = 90; var horizonDistance = roadY - horizonY; // Distance from bottom to horizon for (var i = 0; i < totalSegments; i++) { var distance = i / totalSegments * horizonDistance; // Distance from bottom var yPosition = roadY - distance; var perspective = 1 - distance / horizonDistance; // Linear perspective to horizon var roadWidth = 2048 * perspective; // Road width from full screen width to narrow at horizon var segmentHeight = horizonDistance / totalSegments * 1.2; if (yPosition >= horizonY) { // Only render segments from bottom to horizon // Road segment var roadSeg = game.addChild(LK.getAsset('road_segment', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: yPosition, scaleX: roadWidth / 100, scaleY: segmentHeight / 50 })); roadSegments.push(roadSeg); // Center line segments if (i % 4 == 0) { // Every 4th segment for dashed line effect var centerLine = game.addChild(LK.getAsset('road_line', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: yPosition, scaleX: perspective * 2, scaleY: perspective * 2 })); roadLines.push(centerLine); } // Left sidewalk var leftSidewalk = game.addChild(LK.getAsset('sidewalk_segment', { anchorX: 1, anchorY: 0.5, x: 1024 - roadWidth / 2 - 80 * perspective, y: yPosition, scaleX: perspective * 1.5, scaleY: segmentHeight / 40 })); leftSidewalks.push(leftSidewalk); // Right sidewalk var rightSidewalk = game.addChild(LK.getAsset('sidewalk_segment', { anchorX: 0, anchorY: 0.5, x: 1024 + roadWidth / 2 + 80 * perspective, y: yPosition, scaleX: perspective * 1.5, scaleY: segmentHeight / 40 })); rightSidewalks.push(rightSidewalk); } } // Create single truck ahead of motorcycle var trucks = []; var truck1 = game.addChild(new Truck()); truck1.x = 1024; truck1.y = roadY - 600; // Position far ahead trucks.push(truck1); // Create power bar UI var powerBarBg = LK.getAsset('power_bar_bg', { anchorX: 0.5, anchorY: 1.0, x: 600, y: -300 }); LK.gui.center.addChild(powerBarBg); var powerBarFill = LK.getAsset('power_bar_fill', { anchorX: 0.5, anchorY: 1.0, x: 600, y: -300 }); LK.gui.center.addChild(powerBarFill); var powerItems = []; // Create motorcycle at bottom of screen behind trucks var motorcycle = game.addChild(new Motorcycle()); motorcycle.x = 800; motorcycle.y = roadY - 50; // Positioned on road at bottom of screen // Create roadside objects (people, trees, signs) var roadsideObjects = []; var projectiles = []; var objectTypes = ['person', 'tree', 'sign']; // Left side objects positioned along the perspective sidewalk for (var i = 0; i < 30; i++) { var objectType = objectTypes[i % 3]; // Cycle through person, tree, sign var leftObject = game.addChild(new RoadsideObject(objectType)); var distance = i / 30 * horizonDistance; var yPos = roadY - distance; var perspective = 1 - distance / horizonDistance; var roadWidth = 2048 * perspective; if (yPos >= horizonY) { leftObject.x = 1024 - roadWidth / 2 - 120 * perspective; leftObject.y = yPos; leftObject.originalY = yPos; leftObject.scaleX = perspective; leftObject.scaleY = perspective; leftObject.isLeftSide = true; roadsideObjects.push(leftObject); } } // Right side objects positioned along the perspective sidewalk for (var i = 0; i < 30; i++) { var objectType = objectTypes[i % 3]; // Cycle through person, tree, sign var rightObject = game.addChild(new RoadsideObject(objectType)); var distance = i / 30 * horizonDistance; var yPos = roadY - distance; var perspective = 1 - distance / horizonDistance; var roadWidth = 2048 * perspective; if (yPos >= horizonY) { rightObject.x = 1024 + roadWidth / 2 + 120 * perspective; rightObject.y = yPos; rightObject.originalY = yPos; rightObject.scaleX = perspective; rightObject.scaleY = perspective; rightObject.isLeftSide = false; roadsideObjects.push(rightObject); } } // Score display var scoreTxt = new Text2('Distance: 0m', { size: 60, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Health display var healthTxt = new Text2('Health: 3', { size: 60, fill: 0xFF0000 }); healthTxt.anchor.set(0, 0); healthTxt.x = 0; healthTxt.y = 0; LK.gui.topRight.addChild(healthTxt); var dragStartX = 0; var isDragging = false; // Touch controls game.down = function (x, y, obj) { if (gameStarted) { isDragging = true; dragStartX = x; } }; game.move = function (x, y, obj) { if (isDragging && gameStarted) { var deltaX = x - dragStartX; var newX = motorcycle.x + deltaX * 0.5; // Keep motorcycle on perspective road at bottom (full width bounds) var roadLeft = 200; // Road width at motorcycle position (bottom of screen) var roadRight = 1848; // Almost full screen width if (newX >= roadLeft && newX <= roadRight) { motorcycle.x = newX; } dragStartX = x; } }; game.up = function (x, y, obj) { isDragging = false; }; game.update = function () { // Check if trucks have cleared if (!trucksCleared) { var allTrucksCleared = true; for (var i = 0; i < trucks.length; i++) { if (trucks[i].y > roadY - 300) { // Start immediately when trucks move forward significantly allTrucksCleared = false; break; } } if (allTrucksCleared) { trucksCleared = true; gameStarted = true; } } // Animate individual road blocks advancing from horizon if (gameStarted && motorcycle.speed > 0) { var roadMovement = motorcycle.speed * 3; // Move individual road segments from horizon toward bottom for (var i = 0; i < roadSegments.length; i++) { roadSegments[i].y += roadMovement; // Calculate current perspective for this segment var currentDistance = Math.max(0, roadY - roadSegments[i].y); var perspective = Math.max(0.01, Math.min(1, 1 - currentDistance / horizonDistance)); var roadWidth = 2048 * perspective; // Update segment scaling based on current position roadSegments[i].scaleX = roadWidth / 100; roadSegments[i].scaleY = horizonDistance / totalSegments * 1.2 / 50 * perspective; // Reset segments that have passed the bottom back to horizon with proper spacing if (roadSegments[i].y > roadY + 100) { var segmentSpacing = horizonDistance / totalSegments; roadSegments[i].y = horizonY + i * segmentSpacing / totalSegments; roadSegments[i].scaleX = 0.01; // Very small at horizon roadSegments[i].scaleY = 0.01; } } // Move individual road lines from horizon toward bottom for (var i = 0; i < roadLines.length; i++) { roadLines[i].y += roadMovement; // Calculate current perspective for this line var currentDistance = Math.max(0, roadY - roadLines[i].y); var perspective = Math.max(0.01, Math.min(1, 1 - currentDistance / horizonDistance)); // Update line scaling based on current position roadLines[i].scaleX = perspective * 3; roadLines[i].scaleY = perspective * 4; // Reset lines that have passed the bottom back to horizon with proper spacing if (roadLines[i].y > roadY + 100) { var lineSpacing = horizonDistance / totalSegments * 4; // Lines are spaced every 4 segments var lineIndex = roadLines.indexOf(roadLines[i]); roadLines[i].y = horizonY + lineIndex * lineSpacing / 15; // Distribute evenly roadLines[i].scaleX = 0.01; // Very small at horizon roadLines[i].scaleY = 0.01; } } // Move individual sidewalk blocks from horizon toward bottom for (var i = 0; i < leftSidewalks.length; i++) { leftSidewalks[i].y += roadMovement; rightSidewalks[i].y += roadMovement; // Calculate current perspective for sidewalks var currentDistance = Math.max(0, roadY - leftSidewalks[i].y); var perspective = Math.max(0.01, Math.min(1, 1 - currentDistance / horizonDistance)); var roadWidth = 2048 * perspective; var segmentHeight = horizonDistance / totalSegments * 1.2 * perspective; // Update sidewalk positions and scaling based on current position leftSidewalks[i].x = 1024 - roadWidth / 2 - 80 * perspective; leftSidewalks[i].scaleX = perspective * 2; leftSidewalks[i].scaleY = segmentHeight / 40; rightSidewalks[i].x = 1024 + roadWidth / 2 + 80 * perspective; rightSidewalks[i].scaleX = perspective * 2; rightSidewalks[i].scaleY = segmentHeight / 40; // Reset sidewalks that have passed the bottom back to horizon with proper spacing if (leftSidewalks[i].y > roadY + 100) { var sidewalkSpacing = horizonDistance / totalSegments; leftSidewalks[i].y = horizonY + i * sidewalkSpacing / totalSegments; rightSidewalks[i].y = horizonY + i * sidewalkSpacing / totalSegments; // Reset to horizon positions with minimal scale leftSidewalks[i].x = 1024 - 1; rightSidewalks[i].x = 1024 + 1; leftSidewalks[i].scaleX = 0.01; rightSidewalks[i].scaleX = 0.01; leftSidewalks[i].scaleY = 0.01; rightSidewalks[i].scaleY = 0.01; } } } // Update score if (gameStarted) { var distance = Math.floor(roadOffset / 10); scoreTxt.setText('Distance: ' + distance + 'm'); LK.setScore(distance); } // Update health display to show power healthTxt.setText('Power: ' + Math.round(motorcycle.power) + '%'); // Check for motorcycle flip when crossing center line for perspective effect if (gameStarted) { if (motorcycle.lastX === undefined) { motorcycle.lastX = motorcycle.x; motorcycle.isFlipping = false; } // Check if motorcycle crossed from left half to right half or vice versa var screenCenter = 1024; var crossedToRight = motorcycle.lastX < screenCenter && motorcycle.x >= screenCenter; var crossedToLeft = motorcycle.lastX > screenCenter && motorcycle.x <= screenCenter; if ((crossedToRight || crossedToLeft) && !motorcycle.isFlipping) { motorcycle.isFlipping = true; // Flip the motorcycle by animating scaleX tween(motorcycle, { scaleX: -motorcycle.scaleX }, { duration: 0, easing: tween.easeOut, onFinish: function onFinish() { motorcycle.isFlipping = false; } }); } motorcycle.lastX = motorcycle.x; } // Update power bar display var powerPercentage = motorcycle.power / 100; powerBarFill.scaleY = powerPercentage; if (powerPercentage > 0.6) { powerBarFill.tint = 0x00ff00; // Green } else if (powerPercentage > 0.3) { powerBarFill.tint = 0xffff00; // Yellow } else { powerBarFill.tint = 0xff0000; // Red } // Check projectile collisions for (var i = projectiles.length - 1; i >= 0; i--) { var projectile = projectiles[i]; // Remove off-screen projectiles if (projectile.x < -100 || projectile.x > 2148 || projectile.y > 2732 + 100) { projectile.destroy(); projectiles.splice(i, 1); continue; } // Check collision with motorcycle if (gameStarted && projectile.intersects(motorcycle)) { var damageAmount = projectile.isHeavy ? 20 : 3; // Heavy projectiles do 50% damage motorcycle.takeDamage(damageAmount); projectile.destroy(); projectiles.splice(i, 1); continue; } // Check if projectile hits road (bounce or break) if (projectile.y >= roadY - 20 && projectile.velocityY > 0) { projectile.destroy(); projectiles.splice(i, 1); } } // Check power item collisions for (var i = powerItems.length - 1; i >= 0; i--) { var powerItem = powerItems[i]; // Remove off-screen power items if (powerItem.x < -100 || powerItem.x > 2148 || powerItem.y > 2732 + 100) { powerItem.destroy(); powerItems.splice(i, 1); continue; } // Check collision with motorcycle if (gameStarted && powerItem.intersects(motorcycle)) { motorcycle.restorePower(3); // Restore 3% power powerItem.destroy(); powerItems.splice(i, 1); continue; } // Remove power items that hit the road if (powerItem.y >= roadY - 20 && powerItem.velocityY > 0) { powerItem.destroy(); powerItems.splice(i, 1); } } // Increase difficulty over time if (gameStarted && LK.ticks % 600 == 0) { // Every 10 seconds // Increase throw frequency for people objects for (var j = 0; j < roadsideObjects.length; j++) { if (roadsideObjects[j].objectType === 'person') { roadsideObjects[j].throwDelay = Math.max(20, roadsideObjects[j].throwDelay - 5); } } } };
===================================================================
--- original.js
+++ change.js
@@ -90,16 +90,22 @@
self.throwTimer = 0;
self.throwDelay = Math.random() * 180 + 60; // Random delay between throws
self.isLeftSide = true;
self.originalY = 0; // Store original Y position for movement animation
+ self.hasThrownThisCycle = false; // Evita lanzar dos veces por ciclo
+ self.minThrowDistanceFromMotorcycle = 900; // Debe lanzar cuando est lo suficientemente lejos
self.update = function () {
// Only people throw objects
if (self.objectType === 'person') {
self.throwTimer++;
- if (self.throwTimer >= self.throwDelay && gameStarted) {
- self.throwObject();
- self.throwTimer = 0;
- self.throwDelay = Math.random() * 120 + 400; // Next throw delay
+ if (self.throwTimer >= self.throwDelay && gameStarted && !self.hasThrownThisCycle) {
+ // Lanza solo si a est lejos de la moto
+ if (self.y <= motorcycle.y - self.minThrowDistanceFromMotorcycle) {
+ self.throwObject();
+ self.hasThrownThisCycle = true;
+ self.throwTimer = 0;
+ self.throwDelay = Math.random() * 120 + 400; // Next throw delay
+ }
}
}
// Move object backward to simulate forward motion
if (gameStarted && motorcycle.speed > 0) {
@@ -115,16 +121,26 @@
self.x = 1024 + roadWidth / 2 + 120 * perspective;
}
self.scaleX = perspective;
self.scaleY = perspective;
+ // Lanzar tan pronto como est suficientemente lejos, independiente del temporizador
+ if (gameStarted && self.objectType === 'person' && !self.hasThrownThisCycle) {
+ if (self.y <= motorcycle.y - self.minThrowDistanceFromMotorcycle) {
+ self.throwObject();
+ self.hasThrownThisCycle = true;
+ self.throwTimer = 0;
+ self.throwDelay = Math.random() * 120 + 400;
+ }
+ }
// Reset object position when it goes past the bottom
if (self.y > roadY + 200) {
self.y = self.originalY;
// Reset scale for new cycle
var resetDistance = roadY - self.originalY;
var resetPerspective = Math.max(0.01, Math.min(1, 1 - resetDistance / horizonDistance));
self.scaleX = resetPerspective;
self.scaleY = resetPerspective;
+ self.hasThrownThisCycle = false; // listo para lanzar en el nuevo ciclo
}
}
};
self.throwObject = function () {
@@ -136,14 +152,16 @@
var isHeavy = Math.random() < 0.15;
var projectile = new Projectile(isHeavy);
projectile.x = self.x;
projectile.y = self.y - 20;
- // Calculate trajectory toward motorcycle position on road
- var targetX = motorcycle.x + (Math.random() - 0.5) * 200; // Target motorcycle with some variance
- var targetY = roadY;
- projectile.velocityX = (targetX - projectile.x) * 0.015;
- projectile.velocityY = (targetY - projectile.y) * 0.015;
- projectile.gravity = 0.2;
+ // Parbola fcil de esquivar: velocidad horizontal menor y impulso hacia arriba
+ var targetX = motorcycle.x + (Math.random() - 0.5) * 260; // ligera variacin
+ var horizontalFactor = isHeavy ? 0.009 : 0.008; // ms lento
+ projectile.velocityX = (targetX - projectile.x) * horizontalFactor;
+ // Impulso inicial hacia arriba para crear arco
+ var initialUpImpulse = isHeavy ? -6 - Math.random() * 2 : -8 - Math.random() * 3;
+ projectile.velocityY = initialUpImpulse;
+ projectile.gravity = isHeavy ? 0.35 : 0.28;
projectiles.push(projectile);
game.addChild(projectile);
LK.getSound('throw').play();
};
@@ -158,19 +176,33 @@
self.speed = -6;
self.active = true;
self.dropTimer = 0;
self.dropDelay = 180; // Drop item every 3 seconds
+ self.targetY = horizonY + (roadY - horizonY) * 0.25; // Mantenerse a 1/4 de pantalla (en la zona visible entre horizonte y piso)
+ self.baseX = 1600; // lado derecho
+ self.oscAmp = 30; // amplitud leve en X
+ self.oscSpeed = 0.02; // velocidad de oscilacin
+ self.oscPhase = Math.random() * Math.PI * 2;
self.update = function () {
if (self.active) {
- self.y += self.speed; // Move toward horizon (upward on screen)
+ // Avanzar hasta targetY y mantenerse allí
+ if (self.y > self.targetY) {
+ self.y += self.speed; // speed negativa: sube hacia targetY
+ if (self.y <= self.targetY) {
+ self.y = self.targetY;
+ }
+ } else {
+ self.y = self.targetY;
+ }
+ // Posicin en X hacia la derecha con leve oscilacin
+ self.oscPhase += self.oscSpeed;
+ self.x = self.baseX + Math.sin(self.oscPhase) * self.oscAmp;
// Calculate perspective based on distance to horizon
var distanceToHorizon = roadY - horizonY; // Total distance from bottom to horizon
var currentDistance = roadY - self.y; // Current distance from bottom
var perspective = Math.max(0, 1 - currentDistance / distanceToHorizon); // Perspective ratio
// Move horizontally toward center point (1024) as truck approaches horizon
var centerX = 1024;
- var horizontalConvergence = (centerX - self.x) * 0.02; // Gradual convergence
- self.x += horizontalConvergence;
// Scale trucks according to perspective
self.scaleX = perspective;
self.scaleY = perspective;
// Drop power items periodically
@@ -180,11 +212,8 @@
self.dropPowerItem();
self.dropTimer = 0;
}
}
- if (self.y > 400) {
- self.y = 400;
- }
// Reset truck when it reaches horizon instead of deactivating
}
};
self.dropPowerItem = function () {
@@ -222,9 +251,9 @@
var roadLines = [];
var leftSidewalks = [];
var rightSidewalks = [];
// Create road segments that form triangular perspective from full width to horizon
-var totalSegments = 60;
+var totalSegments = 90;
var horizonDistance = roadY - horizonY; // Distance from bottom to horizon
for (var i = 0; i < totalSegments; i++) {
var distance = i / totalSegments * horizonDistance; // Distance from bottom
var yPosition = roadY - distance;
@@ -286,24 +315,24 @@
trucks.push(truck1);
// Create power bar UI
var powerBarBg = LK.getAsset('power_bar_bg', {
anchorX: 0.5,
- anchorY: 0.5,
- x: 1950,
- y: 400
+ anchorY: 1.0,
+ x: 600,
+ y: -300
});
LK.gui.center.addChild(powerBarBg);
var powerBarFill = LK.getAsset('power_bar_fill', {
anchorX: 0.5,
anchorY: 1.0,
- x: 1950,
- y: 598
+ x: 600,
+ y: -300
});
LK.gui.center.addChild(powerBarFill);
var powerItems = [];
// Create motorcycle at bottom of screen behind trucks
var motorcycle = game.addChild(new Motorcycle());
-motorcycle.x = 1024;
+motorcycle.x = 800;
motorcycle.y = roadY - 50; // Positioned on road at bottom of screen
// Create roadside objects (people, trees, signs)
var roadsideObjects = [];
var projectiles = [];
@@ -356,10 +385,10 @@
size: 60,
fill: 0xFF0000
});
healthTxt.anchor.set(0, 0);
-healthTxt.x = 50;
-healthTxt.y = 50;
+healthTxt.x = 0;
+healthTxt.y = 0;
LK.gui.topRight.addChild(healthTxt);
var dragStartX = 0;
var isDragging = false;
// Touch controls
@@ -524,9 +553,9 @@
continue;
}
// Check collision with motorcycle
if (gameStarted && projectile.intersects(motorcycle)) {
- var damageAmount = projectile.isHeavy ? 50 : 3; // Heavy projectiles do 50% damage
+ var damageAmount = projectile.isHeavy ? 20 : 3; // Heavy projectiles do 50% damage
motorcycle.takeDamage(damageAmount);
projectile.destroy();
projectiles.splice(i, 1);
continue;
Un grupo de gente manifestando a cuerpo completo mirando al frente enojada con banderas argentinas, todo en pixel art. In-Game asset. 2d. High contrast. No shadows
Una planta de lechuga en pixel art en el aire. In-Game asset. 2d. High contrast. No shadows
Un queso gruyere en pixel art. In-Game asset. 2d. High contrast. No shadows
moto
Music
gritos
Music
noEsUnaHuida
Sound effect
frase2
Sound effect
frase3
Sound effect
frase6
Sound effect
edge
Sound effect
frase1
Sound effect
frase4
Sound effect
frase5
Sound effect
hit
Sound effect
power_up
Sound effect
throw
Sound effect
piedra
Sound effect
altacoimera
Sound effect
alta
Music
cloaca
Sound effect
corruptosLoTuyos
Sound effect
frase7
Sound effect
queso
Sound effect
espert
Sound effect
afuera
Sound effect
level_complete
Sound effect
pill_throw
Sound effect
diaper_drop
Sound effect
bridge_level
Sound effect
miraConan
Sound effect