Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SnakeHome
- {
- public class Snake
- {
- private int snakeLenght = 5;
- private int direction = 1; // direction 1 Droite, 2 Bas, 3 Gauche, 4 Haut
- private Case currentCase;
- public void FeedSnake()
- {
- snakeLenght += 1;
- }
- public void MoveSnake()
- {
- SetCurrentCase(new Case(GetCurrentCase().GetX() + 1, GetCurrentCase().GetY()));
- }
- public void DisplaySnake()
- {
- Console.SetCursorPosition(GetCurrentCase().GetX(), GetCurrentCase().GetY());
- Console.Write("q");
- for (int i = 1; i < GetSnakeLenght(); i++)
- {
- Console.SetCursorPosition(GetCurrentCase().GetX() - i, GetCurrentCase().GetY());
- Console.WriteLine("o");
- }
- }
- public void SetSnakeLenght(int snakeLenght)
- {
- this.snakeLenght = snakeLenght;
- }
- public void SetDirection (int direction)
- {
- this.direction = direction;
- }
- public void SetCurrentCase (Case currentCase)
- {
- this.currentCase = currentCase;
- }
- public int GetSnakeLenght()
- {
- return snakeLenght;
- }
- public int GetDirection()
- {
- return direction;
- }
- public Case GetCurrentCase()
- {
- return currentCase;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement