From 5ffa8a150b9ae77b90f831cfbb3603f26620e530 Mon Sep 17 00:00:00 2001 From: jorge Date: Mon, 15 Jun 2026 17:15:03 +0200 Subject: [PATCH] Subir archivos a "/" Archivos iniciales --- gallina.js | 25 +++++++++++++++++++++++++ index.html | 18 ++++++++++++++++++ style.css | 16 ++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 gallina.js create mode 100644 index.html create mode 100644 style.css diff --git a/gallina.js b/gallina.js new file mode 100644 index 0000000..f256b03 --- /dev/null +++ b/gallina.js @@ -0,0 +1,25 @@ + +//La movemos cada 1000ms +setInterval(moverGallina, 500); + +//InnerHeight y Width pa que no se salva de la pantalla. +function moverGallina() { + let top = Math.floor(Math.random() * (innerHeight - 100 + 1) + 100); + let right = Math.floor(Math.random() * (innerHeight - 100 + 1) + 100); + let bottom = Math.floor(Math.random() * innerWidth + 100); + let left = Math.floor(Math.random() * (innerWidth - 100 + 1) + 100); + +//Lo de las comillas y el dolar dolor de wevos + document.getElementById("gallina").style.margin = + `${top}px ${right}px ${bottom}px ${left}px`; +} + + + +function ganar(){ + alert('¡Has pillado a la gallina!'); + +} + + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..455a1f8 --- /dev/null +++ b/index.html @@ -0,0 +1,18 @@ + + + + + + Juego Gallina + + + + + + +
+ robot_chicken +
+ + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..bae2c76 --- /dev/null +++ b/style.css @@ -0,0 +1,16 @@ +body { + background-image: url("images/grass.jpg"); + background-repeat: repeat; + display: flex; + justify-content: center; +} + + +#gallina { + /*Sin la absolute se lía*/ + position: absolute; + width: 300px; + height: 300px; + transition-duration: 0.3s; +} +