30 lines
766 B
C#
30 lines
766 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace 贪吃蛇
|
|
{
|
|
enum E_BodyType
|
|
{
|
|
Head, //蛇头
|
|
Body, //蛇身
|
|
}
|
|
class SnakeBody : GameObject
|
|
{
|
|
private E_BodyType bodyType; //身体类型
|
|
public SnakeBody(int x, int y, E_BodyType bodyType)
|
|
{
|
|
pos = new Position(x, y);
|
|
this.bodyType = bodyType;
|
|
}
|
|
public override void Draw()
|
|
{
|
|
Console.SetCursorPosition(pos.x, pos.y);
|
|
Console.ForegroundColor = bodyType == E_BodyType.Head ? ConsoleColor.Yellow : ConsoleColor.Green;
|
|
Console.Write(bodyType == E_BodyType.Head ? "●" : "○");
|
|
}
|
|
}
|
|
}
|