public class PlayerHandler
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
PlayerHandler.RemotePlayerWorkerThread
The RemotePlayerWorkerThread class is a thread that spawns and handles the timer that is used
to execute RemotePlayersWorker periodically.
|
Constructor and Description |
---|
PlayerHandler(PlayerCanvas parentCanvas,
RemoteHandler remoteHandle,
MapFrame mframe)
A PlayerHandler handles the creation and spawning of local players, as well
as the spawning and monitoring of remote players on the map.
|
Modifier and Type | Method and Description |
---|---|
Player |
createPlayer(int hp,
int level,
java.lang.String name,
RemoteHandler remote)
Creates a new local player that the user is able to interact with via WASD or arrow keys.
|
RemotePlayer |
createRemotePlayer(int hp,
int level,
java.lang.String name)
Creates a new remote player that the local user is unable to move.
|
public PlayerHandler(PlayerCanvas parentCanvas, RemoteHandler remoteHandle, MapFrame mframe)
parentCanvas
- An instance of a PlayerCanvas that the PlayerHandler can spawn players on.remoteHandle
- An instance of the RemoteHandler class that a PlayerHandler can use to fetch remote playersmframe
- An instance of the MapFrame class that is essentially the container for the game, and passed to the createPlayer() method.public RemotePlayer createRemotePlayer(int hp, int level, java.lang.String name)
hp
- The remote player's health points.level
- The remote player's levelname
- The remote player's name, as it will appear under their avatarpublic Player createPlayer(int hp, int level, java.lang.String name, RemoteHandler remote)
hp
- The number of health points the player has (out of 100)level
- The player's level in-game (usually 1).name
- The name that will appear under the player's spriteremote
- The RemoteHandler that is used to interact with the server on the player's behalf.