-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSnake.cs
More file actions
37 lines (34 loc) · 775 Bytes
/
Snake.cs
File metadata and controls
37 lines (34 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
public class SnakeSegment
{
public int[] position = new int[2];
public dir direction = dir.Right;
public SnakeSegment(int[] spawnPosition)
{
position[0] = spawnPosition[0];
position[1] = spawnPosition[1];
}
public enum dir
{
Up, Down, Left, Right
}
public void moveSegment(dir moveDirection)
{
switch (moveDirection)
{
case dir.Left:
position[1]--;
break;
case dir.Right:
position[1]++;
break;
case dir.Up:
position[0]--;
break;
case dir.Down:
position[0]++;
break;
}
return;
}
}