Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
Estoy tratando de mover mi fila de autos hacia el lado derecho en Javascript. Logré que se movieran hacia la izquierda, pero no hacia la derecha.

//! Variables

 const width = 9 const height = 8 const cellCount = width * height const cells = [] let counter = 0 let timer

//! movimiento de coches

// coche1

 const carRowIndexLeft = 6 const carGapLeft = 2 const carStartIndexLeft = width * carRowIndexLeft let carsLeft = []

// coche2

 const carRowIndexRight = 4 const carGapRight = 2 const carStartIndexRight = width * carRowIndexRight let carsRight = []

//!Creando una función de grilla

 function createGrid() { for (let i = 0; i < cellCount; i++) { const cell = document.createElement('div') cell.innerText = i cell.dataset.index = i cells.push(cell) grid.appendChild(cell) } carsLeft = Array.from(cells).slice(carStartIndexLeft, carStartIndexLeft + width) carsRight = Array.from(cells).slice(carStartIndexRight, carStartIndexRight + width)

// Comenzando el juego

 function startGame() { timer = setInterval(() => { counter++ cells.forEach(cell => cell.classList.remove('car1', 'car2')) carsLeft.forEach((car, i) => { if (i % carGapLeft === carGapLeft - 1 - counter % carGapLeft){ car.classList.add('car1')

//Aquí debería tener el movimiento para el auto2 hacia el lado derecho.

 }, 500) }
about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda