SmartFrog 3.10.000

org.smartfrog.examples.pong
Class Obstacle

java.lang.Object
  extended by org.smartfrog.examples.pong.Mass
      extended by org.smartfrog.examples.pong.Obstacle
Direct Known Subclasses:
Ball, Immobile, Racket

public class Obstacle
extends Mass

Defines the obstacle object.


Field Summary
protected  java.awt.Dimension size
          The dimension size.
 
Constructor Summary
Obstacle(int mass, java.awt.geom.Point2D initialPosition, java.awt.Dimension initialSize)
          Constructor.
 
Method Summary
 boolean collide(Immobile wall, double timeWindow)
          Collides the obstacle.
 boolean collide(Obstacle obs, double timeWindow)
          Collides the obstacle.
 void draw(java.awt.Graphics2D g2d)
          Draws the graphics object.
 void elasticCollision(Obstacle obs1, Obstacle obs2, int axis)
          Elastic collision of obstacles.
 java.awt.Dimension getDimension()
          Gets the dimension size.
 java.awt.geom.Point2D getLowerRightBound()
          Gets the lower right bound.
 java.awt.geom.Point2D getUpperLeftBound()
          Gets the upper left bound.
protected  void setDimension(java.awt.Dimension size)
          Sets the dimension.
protected  void setDimension(int w, int h)
          Sets the dimension.
 
Methods inherited from class org.smartfrog.examples.pong.Mass
getAccel, getMass, getPosition, getSpeed, setAccel, setMass, setPosition, setPosition, setSpeed, setSpeed, toString, updatePosition, updateSpeed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

size

protected java.awt.Dimension size
The dimension size.

Constructor Detail

Obstacle

public Obstacle(int mass,
                java.awt.geom.Point2D initialPosition,
                java.awt.Dimension initialSize)
Constructor.

Parameters:
mass - the mass of the ball
initialPosition - the initial position of the ball
initialSize - the dimension size
Method Detail

setDimension

protected void setDimension(java.awt.Dimension size)
Sets the dimension.

Parameters:
size - the dimension size
See Also:
getDimension()

setDimension

protected void setDimension(int w,
                            int h)
Sets the dimension.

Parameters:
w - the width
h - the height
See Also:
getDimension()

getDimension

public java.awt.Dimension getDimension()
Gets the dimension size.

Returns:
the dimension size
See Also:
setDimension(java.awt.Dimension)

collide

public boolean collide(Immobile wall,
                       double timeWindow)
Collides the obstacle.

Parameters:
wall - the wall object
timeWindow - collision time with window wall
Returns:
true if collison occurs else false

collide

public boolean collide(Obstacle obs,
                       double timeWindow)
Collides the obstacle.

Parameters:
obs - the obstacle object
timeWindow - collision time with window
Returns:
true if collison occurs else false

elasticCollision

public void elasticCollision(Obstacle obs1,
                             Obstacle obs2,
                             int axis)
Elastic collision of obstacles.

Parameters:
obs1 - obstacle object 1
obs2 - obstacle object 2
axis - the axis

getLowerRightBound

public java.awt.geom.Point2D getLowerRightBound()
Gets the lower right bound.

Returns:
the lower right bound.

getUpperLeftBound

public java.awt.geom.Point2D getUpperLeftBound()
Gets the upper left bound.

Returns:
the upper left bound.

draw

public void draw(java.awt.Graphics2D g2d)
Draws the graphics object.

Overrides:
draw in class Mass
Parameters:
g2d - graphics object

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP