Exemplo n.º 1
0
 private void Initialize()
 {
     _direction = Snake.EDirection.E;
     var size = new Size(70, 50);
     _snake = new Snake(3, size);
     picturebox.Size = Visualizer.MapSize = new Size(size.Width * Visualizer.CellSize, size.Height * Visualizer.CellSize);
     picturebox.Image = Visualizer.Paint(_snake.GetCoords());
     timer.Start();
 }
Exemplo n.º 2
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if (_flag) return;
     _flag = true;
     switch (e.KeyCode)
     {
         case Keys.Up:
             if (_direction != Snake.EDirection.S) _direction = Snake.EDirection.N;
             break;
         case Keys.Down:
             if (_direction != Snake.EDirection.N) _direction = Snake.EDirection.S;
             break;
         case Keys.Left:
             if (_direction != Snake.EDirection.E) _direction = Snake.EDirection.W;
             break;
         case Keys.Right:
             if (_direction != Snake.EDirection.W) _direction = Snake.EDirection.E;
             break;
     }
 }