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.Drawing;
- namespace SnakeV2
- {
- public class SnakeObject
- {
- public List<Point> Body;
- public Point Head;
- public char[] dirArrow = { '<', '>', '^', 'V' };
- public Direction Dir;
- public SnakeObject(int firstCreation)
- {
- Body = new List<Point>();
- for (int i = 0; i < firstCreation; i++)
- Body.Add(new Point(0, i));
- }
- public void Update()
- {
- Body.RemoveAt(0);
- Body.Add(Head);
- }
- public void Draw()
- {
- for (int i = 0; i < Body.Count - 1; i++)
- {
- Console.SetCursorPosition(Body[i].Y, Body[i].X);
- Console.Write('*');
- }
- Console.SetCursorPosition(Head.Y, Head.X);
- Console.Write(dirArrow[(int)Dir]);
- }
- public Point GetHeadPoint()
- {
- return new Point(Body.Last().X, Body.Last().Y);
- }
- public void Grow()
- {
- Body.Add(new Point(0, 0));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement