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

225
Vistas
How to implement background music to ur jump n run game with levels

I need to do a project for my IT course in school. I implemented a Jump N Run Game in Visual Studio Code with Javascript. It has 4 levels and works with html. My teacher now said that I have to add background music. And I have no idea where to start . I'm really not that good in IT and therefore I don't really know what information is needed in order to help me out with that question. I could send my whole folder in if needed. Thank you in advance. P.S.: I need to be finished by the end of the week.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can do this in JavaScript fairly easily.

// Create a variable to reference your music file
// that is stored in a new Audio object
const music = new Audio("./pathToMusicFile.wav");

// Add an event listener to detect user interaction
// and add a callback function that will run when
// the event occurs. I've added it to the window
// here, but you could add the event to the button
// that starts your game. I've named the callback
// function playMusic here
   window.addEventListener("click", playMusic);

// Function to play the music
// in a continuous loop
function playMusic() {
  // start the music
  music.play();
  // make the music loop continuously
  music.loop = true;
}

  // Note: If you want to stop the music at some point
  // you can do it like this: music.stop()
  // which you might want to do when each level of your
  // game ends, and  then perhaps, play a different tune
  // for the next level

This should be enough to get you started, I hope it helps

about 4 years ago · Juan Pablo Isaza Denunciar
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