|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJTP.Level
public class Level
Deals with handling and storage of individual levels.
Constructor Summary | |
---|---|
Level(int width,
int height,
int maxTileHeight)
Constructs a new single-player Level instance with the given
attributes and no time limit. |
|
Level(int width,
int height,
int maxTileHeight,
boolean twoPlayer)
Constructs a new Level instance with the given attributes and
no time limit. |
|
Level(int width,
int height,
int maxTileHeight,
int timeLimit)
Constructs a new single-player Level instance with the given
attributes. |
|
Level(int width,
int height,
int maxTileHeight,
int timeLimit,
boolean twoPlayer)
Constructs a new Level instance with the given attributes. |
Method Summary | |
---|---|
void |
clear()
Clears a level. |
String |
getInText()
Get the level start message |
String |
getOutText()
Get the level end message |
Point |
getStart()
Returns 1st player start location |
Point |
getStart2()
Returns 2nd player start location |
protected Tile[][] |
getTiles()
Direct access to tile array. |
int |
getTimeLimit()
Get the time limit of this level |
boolean |
hasEqualStarts()
Checks whether both players have equal starts |
boolean |
isEmpty()
Determines whether the level is empty / blank. |
boolean |
isValid()
Validates a level. |
void |
manipulateMultiple(Point corner1,
Point corner2,
Tile attributeTile)
Push or pop multiple tiles. |
void |
popTile(Point location)
Pops a tile from the grid. |
protected boolean |
pushTile(Point location,
boolean isStart)
Only adds normal tiles and starts. |
void |
pushTile(Point location,
Tile attributeTile,
boolean p2Start)
Pushes a tile onto the grid (works a bit like a stack - hence the name). |
void |
setInText(String s)
Sets level start message to specified string |
void |
setOutText(String s)
Sets level end message to specified string |
void |
setTimeLimit(int seconds)
Sets time limit for this level |
int |
size()
Counts number of tiles (not piles) in this level |
protected Tile |
tile(int x,
int y)
Provides direct access to a tile at the given location |
protected Tile |
tile(Point location)
Provides direct access to a tile at the given location |
int |
tileType(Point location)
Returns type of tile at given location |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Level(int width, int height, int maxTileHeight, int timeLimit, boolean twoPlayer)
Level
instance with the given attributes.
width
- in tiles of the levelheight
- in tiles of the levelmaxTileHeight
- maximum height allowed for any one tile piletimeLimit
- in which player has to complete this level. Set to 0 for
no time limittwoPlayer
- specifies whether this a single or two-player level
IllegalArgumentException
- if any of the following are satisfied:
width
< 2height
< 2maxTileHeight
< 1timeLimit
< 0public Level(int width, int height, int maxTileHeight, boolean twoPlayer)
Level
instance with the given attributes and
no time limit.
width
- in tiles of the levelheight
- in tiles of the levelmaxTileHeight
- maximum height allowed for any one tile piletwoPlayer
- specifies whether this a single or two-player level
IllegalArgumentException
- if any of the following are satisfied:
width
< 2height
< 2maxTileHeight
< 1public Level(int width, int height, int maxTileHeight, int timeLimit)
Level
instance with the given
attributes.
width
- in tiles of the levelheight
- in tiles of the levelmaxTileHeight
- maximum height allowed for any one tile piletimeLimit
- in which player has to complete this level. Set to 0 for
no time limit
IllegalArgumentException
- if any of the following are satisfied:
width
< 2height
< 2maxTileHeight
< 1timeLimit
< 0public Level(int width, int height, int maxTileHeight)
Level
instance with the given
attributes and no time limit.
width
- in tiles of the levelheight
- in tiles of the levelmaxTileHeight
- maximum height allowed for any one tile pile
IllegalArgumentException
- if any of the following are satisfied:
width
< 2height
< 2maxTileHeight
< 1Method Detail |
---|
public void pushTile(Point location, Tile attributeTile, boolean p2Start) throws NullPointerException, IllegalArgumentException
location
- on grid where to push the given tile onp2Start
- if attributeTile
is a start tile then
this indicates whether it is the start of the 1st or 2nd player
NullPointerException
- if location
is null
IllegalArgumentException
- if location
is invalidpublic void popTile(Point location) throws NullPointerException, IllegalArgumentException
location
- on grid where to pop tile from
NullPointerException
- if location
is null
IllegalArgumentException
- if location
is invalidpublic void manipulateMultiple(Point corner1, Point corner2, Tile attributeTile)
START
and TELEPORT
type tiles will not be
altered by this operation.
corner1
- 1st corner for specifying push/pop areacorner2
- 2nd corner for specifying push/pop areaattributeTile
- tile to push, or set to null
to poppublic int tileType(Point location) throws NullPointerException, IllegalArgumentException
location
- of tile
Tile
class
NullPointerException
- if location
is null
IllegalArgumentException
- if location
is invalidpublic Point getStart()
public Point getStart2()
public void clear()
public boolean isValid()
true
if the level meets the above criteriapublic boolean isEmpty()
true
if no tiles have been placedprotected boolean pushTile(Point location, boolean isStart)
Challenge
class.
public boolean hasEqualStarts()
true
if both players start at the same locationprotected Tile tile(Point location)
protected Tile tile(int x, int y)
protected Tile[][] getTiles()
TilePainter
class for quick access during rendering
public int size()
public void setInText(String s)
s
- message to use for level startpublic void setOutText(String s)
s
- message to use for level endpublic String getInText()
public String getOutText()
public int getTimeLimit()
public void setTimeLimit(int seconds) throws IllegalArgumentException
seconds
- time limit
IllegalArgumentException
- if eitherseconds
< 0 orseconds
> 3599 (59m, 59s)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |