贪吃蛇小项目
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace 贪吃蛇
|
||||
{
|
||||
class Map : IDraw
|
||||
{
|
||||
public Wall[] walls; //存放墙位置的数组
|
||||
|
||||
public Map()
|
||||
{
|
||||
//初始化墙
|
||||
walls = new Wall[Game.w + (Game.h -3) * 2];
|
||||
int index = 0;
|
||||
//上边墙
|
||||
for (int x = 0; x < Game.w; x+=2)
|
||||
{
|
||||
walls[index++] = new Wall(x, 0);
|
||||
}
|
||||
//下边墙
|
||||
for (int x = 0; x < Game.w; x+=2)
|
||||
{
|
||||
walls[index++] = new Wall(x, Game.h - 2);
|
||||
}
|
||||
//左边墙
|
||||
for (int y = 1; y < Game.h - 2; y++)
|
||||
{
|
||||
walls[index++] = new Wall(0, y);
|
||||
}
|
||||
//右边墙
|
||||
for (int y = 1; y < Game.h - 2; y++)
|
||||
{
|
||||
walls[index++] = new Wall(Game.w - 2, y);
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
for (int x = 0; x < walls.Length; x++)
|
||||
{
|
||||
walls[x].Draw();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user