|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gecco.client.Map
This class represents the map of a game. The map should be given an Image and a map size. The map has a coordinate system of its own, where the upper left corner is (0,0), and every pixel is an automaton. The coordinates are then given as integer numbers.
Every point of the map can be set as either visible or invisible. When a point is invisible it is painted darker. To make a point invisible, call invisiblizePoint(). To make a point visible, or to change the state of som point (automaton), call method updatePoint.
When the map is painted, a certain visible area of the map is painted. The currently visible area is specified with a left upper point (in the map's coordinates), and the size (in pixels) of the visible area. The resoultion is also affectable, by setting the size of the pixels (i.e. a number 1, 2, 3 indicating how many screen pixels the side of every map pixel should occupy).
Field Summary | |
(package private) BufferedImage |
map
Description of the Field |
(package private) Dimension |
size
Description of the Field |
(package private) int |
squareSize
Description of the Field |
(package private) boolean[][] |
visibilities
Description of the Field |
(package private) Dimension |
visibleAreaSize
Description of the Field |
(package private) Point |
visibleAreaUpperLeft
Description of the Field |
Constructor Summary | |
Map(Dimension size)
Initilizes a new map. |
Method Summary | |
void |
clear()
Clears the map. |
Dimension |
getSize()
Gets the Size attribute of the Map object |
void |
invisibilizePoint(Point p)
Makes the given point invisibile by making it darker. |
void |
loadMap(Image map)
Loads the given image as map. |
void |
paint(Graphics g)
Paints the map on the givewn graphics, with the currently set visible area and resolution. |
void |
setVisibleArea(Point upperLeft,
int squareSize,
Dimension size)
Set the currently visible area of the map. |
void |
updatePoint(Point p,
int color)
Updates the given point of the map to the new color. |
Methods inherited from class java.lang.Object |
|
Field Detail |
Dimension size
Point visibleAreaUpperLeft
int squareSize
Dimension visibleAreaSize
BufferedImage map
boolean[][] visibilities
Constructor Detail |
public Map(Dimension size)
size
- The size of the map.Method Detail |
public void setVisibleArea(Point upperLeft, int squareSize, Dimension size)
upperLeft
- The upper left corner of the currently visible area.
Relative to the map's coordinate system, with (0,0) in the upper
left corner.squareSize
- The size of every square (automaton) in pixels on the
screen when the map is painted.size
- The size (in squares, not actual screen size) of the
currently visible area of the map.public Dimension getSize()
public void clear()
public void loadMap(Image map)
map
- Description of Parameterpublic void invisibilizePoint(Point p)
p
- Description of Parameterpublic void updatePoint(Point p, int color)
p
- The point of the map to update, remember that the map has
(0,0) as its upper left corner.color
- The color of the point, given as an int as described in
java.awt.Color.public void paint(Graphics g)
g
- Description of Parameter
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |