Files
snake/Snake/Form1.cs
maxwes08 df6832419f eating
2026-01-30 12:14:01 +01:00

40 lines
969 B
C#

namespace Snake
{
public partial class Form1 : Form
{
private Game _game;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
_game = new Game(this);
_game.Start();
}
private void timer_Tick(object sender, EventArgs e)
{
_game.Update();
Invalidate();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.W:
_game.UpdateInput(Directions.Up); break;
case Keys.A:
_game.UpdateInput(Directions.Left); break;
case Keys.S:
_game.UpdateInput(Directions.Down); break;
case Keys.D:
_game.UpdateInput(Directions.Right); break;
}
}
}
}