-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player.cs
42 lines (33 loc) · 945 Bytes
/
Player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Snakes
{
public class Player
{
Game game;
public string name;
public Keys[] keys;
public Color color;
public int score;
public Snake snake;
public Player(Color color, Keys[] keys, Game game) {
this.color = color;
this.keys = keys;
this.game = game;
this.snake = createSnake();
}
Snake createSnake(){
return new Snake(keys, color, game, this);
}
public void PrepareForNewRound() {
game.GetCollisions().RemoveSnake(snake.id);
snake.id = game.GetNewId();
game.GetCollisions().AddSnake(snake.id);
snake.crashed = false;
snake.ExpirePowerups(true);
snake.NewRandomPosition();
}
}
}