Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

280
Views
Función para mover un objeto (trabajando con el motor del juego)

Tarea: escriba una función que se llame en cada iteración del juego y le diga a la entidad a dónde ir a continuación. (Se espera que la salida sea "derecha", "izquierda", "arriba", "abajo").

 * @typedef {Object} Point - coordinates on the map * @property {number} x * @property {number} y * * @typedef {Object} Pickup - A "food" object that can be picked up or "eaten" * @property {'pacdot' | type 'powerPellet'} - type of food * @property {Point} position - the position of the object on the map * @property {boolean} take - flag whether the object was raised or "eaten" * * @typedef {Object} Pacman - Pacman object * type @property {'pacman'} - type pacman * @property {Point} position - pacman position on the map * * @typedef {Pickup | Pacman | Ghost} Entity - one of the game entities * * @param {Entity []} entity - Array of entities on the game map * @param {string [] []} maze - The initial state of the game maze, where each value is: * - 'X' - labyrinth wall * - 'o' - food or "points" for which points are awarded * - '' - free space in the maze * @return {'up' | 'down' | "left" | 'right'} the direction the pakman needs to go * /

La idea de implementar la función es simple: escriba las coordenadas actuales del pakman, marque: a la derecha - comida ("o") o a la derecha - vacío (" "), si es así, muévase a la derecha. NOTA : es suficiente escribir una función que funcione para el nivel que se muestra en la foto. Es decir, siempre volveremos "a la derecha". Lo importante es cómo se calcula. A continuación se muestra un fragmento de código que no funciona para mí. Les pido que den pistas sobre por qué las pruebas pueden no pasar (estoy trabajando con esas cosas por primera vez, no se apresuren). Hacer clic

 let PacmanX = entities[Pacman].Point.x; let PacmanY = entities[Pacman].Point.y; let checkRightCell = maze[PacmanX+1][PacmanY]; if (checkRightCell === 'o' || checkRightCell === ' ') return 'right'; // output-error: Pacman is not defined
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!