gecco.client
Class Map

java.lang.Object
  |
  +--gecco.client.Map

public class Map
extends Object

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 hidePoint(). To make a point visible, or to change the state of som point (automaton), call method updatePoint.

Author:
Andreas Enblom, Karl Hasselström

Constructor Summary
Map()
          Initilizes a new map.
 
Method Summary
 void clear()
          Clears the map.
 Position getCenter()
          Return the center of the map, in map coordinates.
 Image getImage()
          Gets the image of automaton colors.
 Dimension getSize()
          Return the size of the map, in automatons.
 void hidePoint(int x, int y)
          Makes the given point invisibile by making it darker.
 void loadMap(BufferedImage map)
          Loads the given image as map.
 void setSize(Dimension size)
           
 void updatePoint(int x, int y, int color)
          Updates the given point of the map to the new color.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Map

public Map()
Initilizes a new map.
Parameters:
size - The size of the map, in automatons.
Method Detail

getSize

public Dimension getSize()
Return the size of the map, in automatons.
Returns:
The map size in automatons.

getCenter

public Position getCenter()
Return the center of the map, in map coordinates.
Returns:
The center of the map.

getImage

public Image getImage()
Gets the image of automaton colors.
Returns:
The automaton image.

clear

public void clear()
Clears the map.

loadMap

public void loadMap(BufferedImage map)
Loads the given image as map. The map is set as invisible.
Parameters:
map - Description of Parameter

hidePoint

public void hidePoint(int x,
                      int y)
Makes the given point invisibile by making it darker. If the point is already set as invisible, nothing is done.
Parameters:
x - Description of Parameter
y - Description of Parameter

updatePoint

public void updatePoint(int x,
                        int y,
                        int color)
Updates the given point of the map to the new color. This marks the point as visible.
Parameters:
x - The x coordinate of the point.
y - The y coordinate of the point.
color - The color of the point, given as an int as described in java.awt.Color.

setSize

public void setSize(Dimension size)