A basic Gameboard package to be installed in .../BlueJ/lib/userlib
.
All images need to be placed in the project folder.
import bbegameboard.*;
public CustomClassName extens Gameboard {
// implement custom functionality for your Gameboard
}
In your main create a Gameboard and add players and coins like this:
public static void main(String[] args) {
Gameboard board = new Gameboard;
board.addSpieler(new CustomPlayer(x,y));
board.addSpieler(new Coin(coinX,coinY)); // the coin class is provided by this library
}
The Gameboard cycles through the run-Methods of all players and then displays them at their position using getX() and getY().
CustomPlayer classes can use the follwoing methods:
int getX()
,int getY()
: used by Gameboard to determine the player's position. AllowsDouble
,Float
,Integer
,Long
,Short
,Byte
as return type (which are then internally converted to int). The coordinates are interpreted as upper left corner of the player.void run()
: Is called by Gameboard for all players in every cycle before displaying the positions. This method should implement moving behavior etc.Image getImage()
: Returns the image that represents the player and shall be displayed on the Gameboard.String getText()
: returns are Text that shall be displayed next to the players image.void crashMuenze()
: Is called by Gameboard when a player's hitbox hits the hitbox of a coin (the outer borders of the images are interpreted as hitbox)void setLeft(boolean)
,void setRight(boolean)
,void setUp(boolean)
,void setDown(boolean)
,void setW(boolean)
,void setA(boolean)
,void setS(boolean)
,void setD(boolean)
,void setEnter(boolean)
,void setSpace(boolean)
: Are called by Gameboard in every cycle to set if the named keys are currently pressed.