puntaje) and the session high score (puntajeAlto). Both are integers initialized to 0 at startup.
Score
Increases by 10 each time the snake eats food. Resets to 0 on wall collision or self-collision. Displayed live on screen.
High score
Updated to match
puntaje whenever puntaje exceeds it. Never resets during the session — only a new game run starts it from 0.Earning points
A point event fires whenserpiente.distance(comida) < 20. The score increments by 10:
Score display
Thetexto turtle renders both values as a single line at position (0, -260). Before each write, texto.clear() removes the previous text:
When the display updates
There are three distinct cases wheretexto.clear() followed by texto.write() is called:
Food eaten — new high score
Food eaten — new high score
When
puntaje exceeds puntajeAlto, the high score is updated and the display refreshes:Food eaten — no new high score
Food eaten — no new high score
When
puntaje is still below puntajeAlto, the score still goes up and the display refreshes to show the new current score:Game reset (wall or self-collision)
Game reset (wall or self-collision)
On either type of collision,
puntaje resets to 0 and the display updates. puntajeAlto is left unchanged:The high score is stored in memory only. Closing the game window or restarting the script resets
puntajeAlto to 0. There is no file or database persistence between runs.