<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width">
<title>Ondula</title>
<style>
.sprite {
position: fixed;
font-size: 3rem;
}
</style>
</head>
<body>
<h1>Ondula</h1>
<output id="carita"
class="sprite">
😄
</output>
<script>
const REFRESCO = 5
const VELOCIDAD = 0.5
const FRECUENCIA = 0.03
let x = 0
setInterval(avanza, REFRESCO)
function avanza() {
const xMáxima = innerWidth
const amplitud = innerHeight / 3
const yBase = innerHeight / 2
y = yBase +
amplitud *
Math.sin(FRECUENCIA * x)
carita.style =
`left: ${x}px; bottom: ${y}px`
x = (x + VELOCIDAD) % xMáxima
}
</script>
</body>
</html>