Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SnakeOOP2b.Controller;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SnakeOOP2b.View
- {
- class View
- {
- public void Render(Snake snake, Direction direction)
- {
- Point segment;
- Char symbol = '>';
- switch (direction)
- {
- case Direction.Right:
- symbol = '>';
- break;
- case Direction.Left:
- symbol = '<';
- break;
- case Direction.Up:
- symbol = '^';
- break;
- case Direction.Down:
- symbol = 'V';
- break;
- }
- // render snake
- Console.Clear();
- for (int i = 0; i < snake.body.Count; i++)
- {
- segment = snake.body.ElementAt(i);
- Console.SetCursorPosition(segment.x, segment.y);
- if (i == snake.body.Count - 1)
- {
- Console.Write(symbol);
- }
- else
- {
- Console.Write("*");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement