net.petterroea.starterkit
Class Entity

java.lang.Object
  extended by net.petterroea.starterkit.Entity

public class Entity
extends java.lang.Object

A standard entity for use in a game

Author:
petterroea

Field Summary
 java.awt.Rectangle collisionbox
          The collisionbox of the entity
 Sprite entitysprite
          The sprite used by the entity
 int height
          Height of the entity
 boolean removeMe
          True if the entity is dead and should be removed
 int width
          Width of the entity
 double x
          X position with decimals, for greater accuracy
 double xspeed
          X axis speed in decimals, for greater accuracy
 double y
          Y position with decimals, for greater accuracy
 double yspeed
          Y axis speed in decimals, for greater accuracy
 
Constructor Summary
Entity(int x, int y)
          Constructor for a entity
 
Method Summary
private  boolean canCollideWith(Entity entity)
          Checks if an entity can collide with another entity
 void draw(java.awt.Graphics g, int xoff, int yoff)
          Draws the entity
 boolean isVisible(int xoff, int yoff)
          Checks if this is drawable in the window(In viewing range)
 void update(int delta)
          Updates the entity's x and y postition based on x and y speed
 void update(int delta, java.util.LinkedList<Entity> map, int pos)
          Updates the entity's position, while paying attention to other entities
 void update(int delta, Map map, int pos)
          Updates the entity's position, while paying attention to Both tiles and entities in a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

public double x
X position with decimals, for greater accuracy


y

public double y
Y position with decimals, for greater accuracy


xspeed

public double xspeed
X axis speed in decimals, for greater accuracy


yspeed

public double yspeed
Y axis speed in decimals, for greater accuracy


width

public int width
Width of the entity


height

public int height
Height of the entity


collisionbox

public java.awt.Rectangle collisionbox
The collisionbox of the entity


entitysprite

public Sprite entitysprite
The sprite used by the entity


removeMe

public boolean removeMe
True if the entity is dead and should be removed

Constructor Detail

Entity

public Entity(int x,
              int y)
Constructor for a entity

Parameters:
x - The x axis position of the entity
y - The y axis position of the entity
Method Detail

update

public void update(int delta)
Updates the entity's x and y postition based on x and y speed

Parameters:
delta - Milliseconds since last update

update

public void update(int delta,
                   java.util.LinkedList<Entity> map,
                   int pos)
Updates the entity's position, while paying attention to other entities

Parameters:
delta - Time since last update
map - The list of entities
pos - This enties position in the list

update

public void update(int delta,
                   Map map,
                   int pos)
Updates the entity's position, while paying attention to Both tiles and entities in a map.

Parameters:
delta - Time since last update in ms
map - The map this is using
pos - This enties position in the list

canCollideWith

private boolean canCollideWith(Entity entity)
Checks if an entity can collide with another entity

Parameters:
entity - The entity to check against
Returns:
true if they are collidable with each other

draw

public void draw(java.awt.Graphics g,
                 int xoff,
                 int yoff)
Draws the entity

Parameters:
g - The graphics object
xoff - x offset in pixels
yoff - y offset in pixels

isVisible

public boolean isVisible(int xoff,
                         int yoff)
Checks if this is drawable in the window(In viewing range)

Parameters:
xoff - X axis offset
yoff - Y axis offset
Returns:
True if the entity is vivible