Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
fp2025:lab08 [2026/04/23 16:52]
silviu
fp2025:lab08 [2026/04/23 16:52] (current)
silviu
Line 18: Line 18:
  
 **8.7.** Implement the `step` function that: **8.7.** Implement the `step` function that:
-moves the snake in the current direction +  * moves the snake in the current direction 
- +  ​* ​if the snake moves over the apple the apple is consumed, a new apple is randomly placed on the grid and the snake body gets a new segment 
-if the snake moves over the apple the apple is consumed, a new apple is randomly placed on the grid and the snake body gets a new segment +  ​* ​if the snake moves over it's body the game is over 
- +  ​* ​if the game is over nothing moves
-if the snake moves over it's body the game is over +
- +
-if the game is over nothing moves+
  
 **8.8** Run the game and try playing it, use the arrow keys to change the direction the snake moves. ​ **8.8** Run the game and try playing it, use the arrow keys to change the direction the snake moves. ​
Line 30: Line 27:
 **8.9.** (Bonus) Implement the `setReverse` activated by pressing the `R` key with the following behavior: **8.9.** (Bonus) Implement the `setReverse` activated by pressing the `R` key with the following behavior:
  
-if the set value is false the game plays normal and at each step the current state of the game is saved +  * if the set value is false the game plays normal and at each step the current state of the game is saved 
- +  ​* ​if the set value is true the game will go at each call of the `step` function back showing the previous game state such that the game plays alone in reverse as you played until pressing the `R` key.
-if the set value is true the game will go at each call of the `step` function back showing the previous game state such that the game plays alone in reverse as you played until pressing the `R` key.+