Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda