SHARE
TWEET

Untitled

a guest Apr 18th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace SnakeHome
  8. {
  9.     public class Snake
  10.     {
  11.         private int snakeLenght = 5;
  12.         private int direction = 1; // direction 1 Droite, 2 Bas, 3 Gauche, 4 Haut
  13.         private Case currentCase;
  14.  
  15.         public void FeedSnake()
  16.         {
  17.             snakeLenght += 1;
  18.         }
  19.  
  20.         public void MoveSnake()
  21.         {
  22.             SetCurrentCase(new Case(GetCurrentCase().GetX() + 1, GetCurrentCase().GetY()));
  23.         }
  24.  
  25.         public void DisplaySnake()
  26.         {
  27.             Console.SetCursorPosition(GetCurrentCase().GetX(), GetCurrentCase().GetY());
  28.             Console.Write("q");
  29.             for (int i = 1; i < GetSnakeLenght(); i++)
  30.             {
  31.                 Console.SetCursorPosition(GetCurrentCase().GetX() - i, GetCurrentCase().GetY());
  32.                 Console.WriteLine("o");
  33.             }
  34.         }
  35.  
  36.         public void SetSnakeLenght(int snakeLenght)
  37.         {
  38.             this.snakeLenght = snakeLenght;
  39.         }
  40.  
  41.         public void SetDirection (int direction)
  42.         {
  43.             this.direction = direction;
  44.         }
  45.  
  46.         public void SetCurrentCase (Case currentCase)
  47.         {
  48.             this.currentCase = currentCase;
  49.         }
  50.  
  51.         public int GetSnakeLenght()
  52.         {
  53.             return snakeLenght;
  54.         }
  55.  
  56.         public int GetDirection()
  57.         {
  58.             return direction;
  59.         }
  60.  
  61.         public Case GetCurrentCase()
  62.         {
  63.             return currentCase;
  64.         }
  65.  
  66.     }
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top