Tu primer juego completo
El proyecto final del curso. Nada de esto es nuevo: es todo lo que ya aprendiste, en un solo lugar.
Your first complete game
The course's final project. None of this is new: it is everything you already learned, in one place.
Vamos a hacer Atrapa la estrella: caen estrellas, mueves una canasta con el dedo o el mouse, y sumas puntos por cada una que atrapes. Nada de esto es una idea nueva:
- El bucle de animación — del tutorial Haz que se mueva.
- Seguir el mouse o el dedo — del mismo tutorial, con el pong.
- Objetos y listas — para representar cada estrella cayendo.
localStorage— para el récord, del tutorial de guardar datos.
Un proyecto grande no es más que varias ideas chicas, ya conocidas, puestas juntas.
We are going to build Catch the star: stars fall, you move a basket with your finger or mouse, and score points for each one you catch. None of this is a new idea:
- The animation loop — from Make it move.
- Following the mouse or finger — same tutorial, with the pong.
- Objects and lists — to represent each falling star.
localStorage— for the high score, from the saving-data tutorial.
A big project is nothing more than several small, already-known ideas, put together.
Empecemos sin menú ni vidas: solo estrellas cayendo, una canasta que las sigue, y
puntaje. Una lista de objetos —cada estrella con su x,
y y velocidad— recorrida en cada cuadro.
Let us start without menu or lives: just falling stars, a basket that follows them, and a
score. A list of objects — each star with its x, y
and speed — looped over on every frame.
Un juego necesita poder terminar. Agregamos vidas: perder una estrella —que caiga sin ser atrapada— cuesta una vida, y en cero vidas se detiene el juego.
A game needs to be able to end. We add lives: missing a star — letting it fall without catching it — costs a life, and at zero lives the game stops.
Falta lo último: una pantalla de inicio, y que el mejor puntaje sobreviva aunque cierres la pestaña. Acá está todo junto — el juego completo.
One thing left: a start screen, and making the best score survive even after closing the tab. Here it all comes together — the complete game.
Repasa lo que acabas de construir: variables, decisiones, bucles, funciones, listas y
objetos para los datos del juego; HTML y CSS para lo que se ve; el DOM y los eventos para que
reaccione; y localStorage para que recuerde. Dieciocho tutoriales,
convertidos en un juego que funciona de verdad.
Desde acá, el camino es hacer más cosas. Cambia los colores, agrega power-ups, prueba con formas distintas —o mira cómo están hechos nuestros juegos, que empezaron exactamente en el mismo lugar que tú hoy.
Look back at what you just built: variables, decisions, loops, functions, lists and
objects for the game's data; HTML and CSS for what is on screen; the DOM and events to make
it react; and localStorage to make it remember. Eighteen tutorials,
turned into a game that actually works.
From here, the path is making more things. Change the colours, add power-ups, try different shapes — or look at how our own games are built, which started in exactly the same place you are today.