boton colision

This commit is contained in:
Meinar00
2025-02-13 01:40:23 +01:00
parent c469b99bcc
commit 03acad431e
4 changed files with 13 additions and 1 deletions

BIN
public/audio/colision.m4a Normal file

Binary file not shown.

BIN
public/audio/colision.wav Normal file

Binary file not shown.

View File

@@ -64,4 +64,4 @@ body.light-theme {
body.dark-theme { body.dark-theme {
background-color: #343a40; /* Color de fondo oscuro */ background-color: #343a40; /* Color de fondo oscuro */
color: #f8f9fa; /* Color de texto claro */ color: #f8f9fa; /* Color de texto claro */
} }

View File

@@ -103,6 +103,13 @@ function App() {
} }
}; };
const reproducirColision = () => {
const audioColision = new Audio('/audio/colision.wav');
audioColision.play().catch(error => {
console.error("Error al reproducir audio:", error);
});
};
useEffect(() => { useEffect(() => {
const cargarAudios = () => { const cargarAudios = () => {
// Preload audio files (optional but recommended) // Preload audio files (optional but recommended)
@@ -115,6 +122,7 @@ function App() {
}); });
const audioVallecas = new Audio(`/audio/vallecas.wav`); // Preload new audio file const audioVallecas = new Audio(`/audio/vallecas.wav`); // Preload new audio file
const audioColision = new Audio(`/audio/colision.m4a`);
}; };
cargarAudios(); cargarAudios();
@@ -195,6 +203,10 @@ function App() {
<button onClick={toggleTheme} className="btn btn-secondary mt-3"> <button onClick={toggleTheme} className="btn btn-secondary mt-3">
Cambiar tema a {theme === 'light' ? 'oscuro' : 'claro'} Cambiar tema a {theme === 'light' ? 'oscuro' : 'claro'}
</button> </button>
<button onClick={reproducirColision} className="btn btn-danger mt-3 fixed-bottom">
Colisión
</button>
</div> </div>
); );
} }