45 lines
984 B
C#
45 lines
984 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Snake
|
|
{
|
|
public class Game
|
|
{
|
|
//new Cell(10, 10, CellTypes.Snake)
|
|
Worm worm;
|
|
Directions direction = Directions.Down;
|
|
Map map;
|
|
Form1 form;
|
|
|
|
public Game(Form1 form)
|
|
{
|
|
this.form = form;
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
Cell startCell = new Cell(10, 10, CellTypes.Snake);
|
|
map = new Map(20, 20);
|
|
map.SetCell(startCell);
|
|
worm = new Worm(startCell);
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
map.Render(form.gamearea.CreateGraphics());
|
|
form.Invalidate();
|
|
|
|
int x = worm.Body[0].X;
|
|
int y = worm.Body[0].Y;
|
|
|
|
Cell snakeCell = map.Cells[x, y];
|
|
Cell cellBelow = map.Cells[x, y-1];
|
|
|
|
map.SwapCells(snakeCell, cellBelow);
|
|
}
|
|
}
|
|
}
|