data
Class GameEntity

java.lang.Object
  extended by data.GameEntity
Direct Known Subclasses:
Balloon, Bonus, Obstacle, Player, Sting

public abstract class GameEntity
extends java.lang.Object

Author:
Tansel

Field Summary
protected  double dx
          The current speed of this entity horizontally (pixels/sec)
protected  double dy
          The current speed of this entity vertically (pixels/sec)
protected  GameEngine ge
          GameEngine object is taken to notify GameEngine on specific occurrences
private  java.awt.Rectangle other
          The rectangle used for other entities during collision resolution
private  java.awt.Rectangle own
          The rectangle used for this entity during collisions resolution
protected  ScreenManager sm
          The rectangle used for other entities during collision resolution
protected  Sprite sprite
          The sprite that represents this entity
protected  double x
          The current x location of this entity
protected  double y
          The current y location of this entity
 
Constructor Summary
GameEntity(GameEngine ge, java.lang.String file, int x, int y, ScreenManager sm)
          This is the constructor of our abstract class GameEntity.
 
Method Summary
abstract  void collidedWith(GameEntity entity)
          Collision responses will take within Game Entities.
 boolean collidesWith(GameEntity entity)
          This method check the collision between itself and another entity.
 void draw(java.awt.Graphics2D g)
          This method draws the visual of the entity to the screen.
 int getX()
           
 int getY()
           
 void move(long delta)
          Moves the entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

protected double x
The current x location of this entity


y

protected double y
The current y location of this entity


sprite

protected Sprite sprite
The sprite that represents this entity


dx

protected double dx
The current speed of this entity horizontally (pixels/sec)


dy

protected double dy
The current speed of this entity vertically (pixels/sec)


own

private java.awt.Rectangle own
The rectangle used for this entity during collisions resolution


other

private java.awt.Rectangle other
The rectangle used for other entities during collision resolution


sm

protected ScreenManager sm
The rectangle used for other entities during collision resolution


ge

protected GameEngine ge
GameEngine object is taken to notify GameEngine on specific occurrences

Constructor Detail

GameEntity

public GameEntity(GameEngine ge,
                  java.lang.String file,
                  int x,
                  int y,
                  ScreenManager sm)
This is the constructor of our abstract class GameEntity. All objects in the screen are instance of this class.

Parameters:
ge - GameEngine object to send specific messages on specific occurrences.
file - Path to the image.
x - X position of the object.
y - Y position of the object.
sm - ScreenManager object to determine the boundaries of the screen.
Method Detail

getX

public int getX()
Returns:
The x position of the entity.

getY

public int getY()
Returns:
The y position of the entity.

move

public void move(long delta)
Moves the entity. Probably will be overridden by each object.

Parameters:
delta - is the amount of time that entity will move.

draw

public void draw(java.awt.Graphics2D g)
This method draws the visual of the entity to the screen. Each object draws itself.

Parameters:
g - A Graphics2D object coming from GameEngine

collidesWith

public boolean collidesWith(GameEntity entity)
This method check the collision between itself and another entity. GameEngine calls this method for each entity and they return a boolean value if collision occurs.

Parameters:
entity - Entity to be collided.
Returns:
If collision occurred.

collidedWith

public abstract void collidedWith(GameEntity entity)
Collision responses will take within Game Entities. GameEngine will check for collisions, but every respective response to collisions will be taken care of in different entities like this: -Bonus Entity:.......collision with Player Entity -Player Entity:......collision with Balloon Entity -Sting Entity:.......collision with Balloon Entity -Obstacle Entity:....collision with Sting Entity -Balloon Entity:.....collision with Obstacle Entity

Parameters:
entity -