ice.player

AI and human player classes.

abstract class Player;

Parent class for all players.

Note that it is expected to explicitly destroy the Player using clear() once it is not used anymore.

protected const string name_;

Player name.

protected uint score_;

Current player score.

const pure nothrow @property string name();

Get name of this player.

void update();

Update player state.

Parameters:
game Reference to the game.
pure nothrow void control(EntityID id, ref ControllerComponent control);

Control entity with specified ID through its ControllerComponent.

const pure nothrow string toString();

String representation of the player (currently just returns player name).

protected this(const(immutable(char)[]) name);

Construct a player.

Parameters:
const(immutable(char)[]) name Player name.
class AIPlayer: ice.player.Player;

AI player.

protected Timer updateTimer_;

Timer determining when to update the AI.

protected Vector2f ballLast_;

Position of the ball during last AI update.

this(const(immutable(char)[]) name, const(real) updatePeriod);

Construct an AI player.

Parameters:
const(immutable(char)[]) name Player name.
const(real) updatePeriod Time period of AI updates.
class HumanPlayer: ice.player.Player;

Human player controlling the game through user input.

this(Platform platform, const(immutable(char)[]) name);

Construct a human player.

Parameters:
Platform platform Platform for user input.
const(immutable(char)[]) name Name of the player.
void keyHandler(KeyState state, Key key, dchar unicode);

Process keyboard input.

Parameters:
KeyState state State of the key.
Key key Keyboard key.
dchar unicode Unicode value of the key.