Updated README
This commit is contained in:
36
README-fr.md
36
README-fr.md
@@ -1,6 +1,6 @@
|
|||||||
# Jeu Snake 2025
|
# Jeu Snake 2025
|
||||||
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp2/README.md)
|
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp6/README.md)
|
||||||
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp2/README-fr.md)
|
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp6/README-fr.md)
|
||||||
|
|
||||||
Ce projet est un jeu snake basé sur une grille utilisant la bibliothèque graphique MLV. La grille représente un plateau de jeu avec des murs, des espaces vides, des fruits et un serpent. Le programme affiche la grille dans une fenêtre graphique et attend une interaction de l'utilisateur.
|
Ce projet est un jeu snake basé sur une grille utilisant la bibliothèque graphique MLV. La grille représente un plateau de jeu avec des murs, des espaces vides, des fruits et un serpent. Le programme affiche la grille dans une fenêtre graphique et attend une interaction de l'utilisateur.
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ Ce projet est un jeu snake basé sur une grille utilisant la bibliothèque graph
|
|||||||
- Utilise la bibliothèque graphique MLV pour le rendu graphique.
|
- Utilise la bibliothèque graphique MLV pour le rendu graphique.
|
||||||
- Assure que les blocs en dehors de la grille sont affichés en noir.
|
- Assure que les blocs en dehors de la grille sont affichés en noir.
|
||||||
- Permet à l'utilisateur de quitter le programme en appuyant sur la touche ESC.
|
- Permet à l'utilisateur de quitter le programme en appuyant sur la touche ESC.
|
||||||
|
- Implémente un serpent dynamique utilisant une liste chaînée pour ses segments.
|
||||||
|
- Gère le mouvement du serpent en mettant à jour la position de la tête et en déplaçant tous les segments en conséquence.
|
||||||
|
- Permet au serpent de grandir lorsqu'il mange des fruits.
|
||||||
|
|
||||||
## Représentation de la Grille
|
## Représentation de la Grille
|
||||||
|
|
||||||
@@ -19,6 +22,16 @@ Ce projet est un jeu snake basé sur une grille utilisant la bibliothèque graph
|
|||||||
- `'f'` pour les fruits.
|
- `'f'` pour les fruits.
|
||||||
- `'s'` pour le serpent.
|
- `'s'` pour le serpent.
|
||||||
|
|
||||||
|
## Représentation du Serpent
|
||||||
|
|
||||||
|
- Le serpent est implémenté comme une liste chaînée de segments (`Position`), où :
|
||||||
|
- Chaque segment a des coordonnées `x` et `y`.
|
||||||
|
- Le pointeur `next` relie le segment suivant dans le serpent.
|
||||||
|
- Le mouvement du serpent est géré en :
|
||||||
|
- Ajoutant une nouvelle tête en fonction de la direction actuelle.
|
||||||
|
- Déplaçant tous les segments pour suivre la tête.
|
||||||
|
- Supprimant la queue sauf si le serpent mange un fruit.
|
||||||
|
|
||||||
## Dépendances
|
## Dépendances
|
||||||
|
|
||||||
- GCC (GNU Compiler Collection)
|
- GCC (GNU Compiler Collection)
|
||||||
@@ -52,7 +65,24 @@ Cela compilera les fichiers sources et créera un exécutable nommé `game` dans
|
|||||||
./game
|
./game
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Une fenêtre s'ouvrira affichant la grille. Les blocs en dehors de la grille apparaîtront en noir. Appuyez sur la touche ESC pour fermer la fenêtre.
|
2. Une fenêtre s'ouvrira affichant la grille. Les blocs en dehors de la grille apparaîtront en noir. Utilisez les flèches directionnelles pour contrôler le serpent. Appuyez sur la touche ESC pour fermer la fenêtre.
|
||||||
|
|
||||||
|
## Logique du Jeu
|
||||||
|
|
||||||
|
- **Mouvement du Serpent** :
|
||||||
|
- Le serpent se déplace dans la direction actuelle, en mettant à jour la position de sa tête et en déplaçant tous les segments.
|
||||||
|
- Si le serpent mange un fruit, il grandit en ajoutant un nouveau segment sans supprimer la queue.
|
||||||
|
- Si le serpent entre en collision avec un mur ou lui-même, le jeu se termine.
|
||||||
|
|
||||||
|
- **Mise à Jour de la Grille** :
|
||||||
|
- La grille est mise à jour pour refléter la nouvelle position du serpent après chaque mouvement.
|
||||||
|
- Les fruits sont supprimés de la grille lorsqu'ils sont mangés par le serpent.
|
||||||
|
|
||||||
|
- **Condition de Victoire** :
|
||||||
|
- Le joueur gagne lorsque tous les fruits sur la grille sont collectés.
|
||||||
|
|
||||||
|
- **Condition de Défaite** :
|
||||||
|
- Le jeu se termine si le serpent entre en collision avec un mur ou lui-même.
|
||||||
|
|
||||||
## Nettoyage
|
## Nettoyage
|
||||||
|
|
||||||
|
|||||||
36
README.md
36
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Snake 2025 Game
|
# Snake 2025 Game
|
||||||
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp2/README.md)
|
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp6/README.md)
|
||||||
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp2/README-fr.md)
|
[](https://git.esiee.fr/frequela/snake2025/-/blob/tp6/README-fr.md)
|
||||||
|
|
||||||
This project is a simple grid-based snake game using the MLV graphics library. The grid represents a game board with walls, empty spaces, fruits, and a snake. The program displays the grid in a graphical window and waits for user interaction.
|
This project is a simple grid-based snake game using the MLV graphics library. The grid represents a game board with walls, empty spaces, fruits, and a snake. The program displays the grid in a graphical window and waits for user interaction.
|
||||||
|
|
||||||
@@ -10,6 +10,9 @@ This project is a simple grid-based snake game using the MLV graphics library. T
|
|||||||
- Uses the MLV graphics library for graphical rendering.
|
- Uses the MLV graphics library for graphical rendering.
|
||||||
- Ensures that blocks outside the grid are displayed as black.
|
- Ensures that blocks outside the grid are displayed as black.
|
||||||
- Allows the user to quit the program by pressing the ESC key.
|
- Allows the user to quit the program by pressing the ESC key.
|
||||||
|
- Implements a dynamic snake using a linked list for its segments.
|
||||||
|
- Handles snake movement by updating the head position and shifting all segments accordingly.
|
||||||
|
- Supports snake growth when eating fruits.
|
||||||
|
|
||||||
## Grid Representation
|
## Grid Representation
|
||||||
|
|
||||||
@@ -19,6 +22,16 @@ This project is a simple grid-based snake game using the MLV graphics library. T
|
|||||||
- `'f'` for fruits.
|
- `'f'` for fruits.
|
||||||
- `'s'` for the snake.
|
- `'s'` for the snake.
|
||||||
|
|
||||||
|
## Snake Representation
|
||||||
|
|
||||||
|
- The snake is implemented as a linked list of segments (`Position` structures), where:
|
||||||
|
- Each segment has `x` and `y` coordinates.
|
||||||
|
- The `next` pointer links to the next segment in the snake.
|
||||||
|
- The snake's movement is handled by:
|
||||||
|
- Adding a new head based on the current direction.
|
||||||
|
- Shifting all segments to follow the head.
|
||||||
|
- Removing the tail unless the snake eats a fruit.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
- GCC (GNU Compiler Collection)
|
- GCC (GNU Compiler Collection)
|
||||||
@@ -52,7 +65,24 @@ This will compile the source files and create an executable named `game` in the
|
|||||||
./game
|
./game
|
||||||
```
|
```
|
||||||
|
|
||||||
2. A window will open displaying the grid. Blocks outside the grid will appear black. Press the ESC key to close the window.
|
2. A window will open displaying the grid. Blocks outside the grid will appear black. Use the arrow keys to control the snake. Press the ESC key to close the window.
|
||||||
|
|
||||||
|
## Game Logic
|
||||||
|
|
||||||
|
- **Snake Movement**:
|
||||||
|
- The snake moves in the current direction, updating its head position and shifting all segments.
|
||||||
|
- If the snake eats a fruit, it grows by adding a new segment without removing the tail.
|
||||||
|
- If the snake collides with a wall or itself, the game ends.
|
||||||
|
|
||||||
|
- **Grid Updates**:
|
||||||
|
- The grid is updated to reflect the snake's new position after each move.
|
||||||
|
- Fruits are removed from the grid when eaten by the snake.
|
||||||
|
|
||||||
|
- **Winning Condition**:
|
||||||
|
- The player wins when all fruits on the grid are collected.
|
||||||
|
|
||||||
|
- **Losing Condition**:
|
||||||
|
- The game ends if the snake collides with a wall or itself.
|
||||||
|
|
||||||
## Cleaning Up
|
## Cleaning Up
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user