Class PlayField

java.lang.Object
  |
  +--PlayField

public class PlayField
extends Object


Field Summary
 Food[][] playfield
          two-dimensional array of food; allows the microbes to have a fast access to the playfield
 int playfield_height
          width and height of the playfield in units
 int playfield_width
          width and height of the playfield in units
static int TYPE_DEATH
          additional drawmode: death
static int TYPE_NEWLIFE
          additional drawmode: new life
static int TYPE_RANDOMFOOD
          additional drawmode: random
 
Constructor Summary
PlayField(int width, int height, int pixelsize)
          creates the playfield with the parameters
 
Method Summary
 void clear_all()
          fills the whole playfield with the food Food.TYPE_NOTHING
 void draw_all()
          draws the whole playfield (without microbes!)
 void fill_all(int color)
          fills the whole playfield with the food "color" and creates the playfield borders
the playfield borders are hardcoded into the microbes brain to be unpassable
 void fill_random()
          lets "rain" food in random order onto the playfield
 Microbe get_selectedmic()
          returns the selected microbe
 int getfoodtype(int x, int y)
          returns the food type at the position (x,y) in the playfield
 void manualdraw(int x, int y, int type, int size)
          draws the food "type" with the brush size "size" onto the position (x,y)
 Microbe new_microbe(int x, int y, int start_energy, int start_energyloss)
          creates a new microbe
 void refresh()
          calculates one step of every microbe and draws the changes
 void remove_microbe(int x, int y)
          removes the microbe at the position (x,y) on the playfield
 void set_graphics(Graphics g)
          sets graphics context for all further graphic operations
 void setenergyloss(int new_energyloss)
          sets the energyloss per stepp for every microbe
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_RANDOMFOOD

public static final int TYPE_RANDOMFOOD
additional drawmode: random

TYPE_NEWLIFE

public static final int TYPE_NEWLIFE
additional drawmode: new life

TYPE_DEATH

public static final int TYPE_DEATH
additional drawmode: death

playfield_width

public int playfield_width
width and height of the playfield in units

playfield_height

public int playfield_height
width and height of the playfield in units

playfield

public Food[][] playfield
two-dimensional array of food; allows the microbes to have a fast access to the playfield
Constructor Detail

PlayField

public PlayField(int width,
                 int height,
                 int pixelsize)
creates the playfield with the parameters
Parameters:
width - width of playfield in playfield-grid-points
height - height of playfield in playfield-grid-points
pixelsize - size of a pixel in the playfield (quadratic, unit: pixels)
Method Detail

set_graphics

public void set_graphics(Graphics g)
sets graphics context for all further graphic operations
Parameters:
g - graphics context

fill_all

public void fill_all(int color)
fills the whole playfield with the food "color" and creates the playfield borders
the playfield borders are hardcoded into the microbes brain to be unpassable
Parameters:
color - color (food-type) to fill the playfield with

clear_all

public void clear_all()
fills the whole playfield with the food Food.TYPE_NOTHING

fill_random

public void fill_random()
lets "rain" food in random order onto the playfield

manualdraw

public void manualdraw(int x,
                       int y,
                       int type,
                       int size)
draws the food "type" with the brush size "size" onto the position (x,y)
Parameters:
x - x position
y - y position
type - food type
size - size of the drawing brush

setenergyloss

public void setenergyloss(int new_energyloss)
sets the energyloss per stepp for every microbe
Parameters:
new_ernergyloss - new energyloss per step value

getfoodtype

public int getfoodtype(int x,
                       int y)
returns the food type at the position (x,y) in the playfield
Parameters:
x - x position
y - y position
Returns:
food type

draw_all

public void draw_all()
draws the whole playfield (without microbes!)

refresh

public void refresh()
calculates one step of every microbe and draws the changes

new_microbe

public Microbe new_microbe(int x,
                           int y,
                           int start_energy,
                           int start_energyloss)
creates a new microbe
Parameters:
x - x position
y - y position
start_energy - start energy for thge new microbe
start_energyloss - energy loss per step
Returns:
new microbe

remove_microbe

public void remove_microbe(int x,
                           int y)
removes the microbe at the position (x,y) on the playfield
Parameters:
x - x position
y - y position

get_selectedmic

public Microbe get_selectedmic()
returns the selected microbe
Returns:
selected microbe