Class Port

java.lang.Object
  extended byPort

public class Port
extends java.lang.Object

Class Port implements a gate. FIXME: (1.1) This should probably be named "Gate".

A gate consists of two buoys floating on the water, left (portboard) and right (starboard).

Contains the anchored positions for each buoy and the moving positions of each buoy. The buoys can move, e.g. when hit by a boat. A buoy that has moved will float back to its anchored position.

Port contains the functionality to test collisions with the players and to test passing the gate. Passing the gate is dependent on the direction.

Version:
1.0
Author:
Stefan Brockmann, Tero Kuusela
See Also:
Vector2, Track

Field Summary
 Vector2 left
          portboard buoy of the port
private  Vector2 mount_left
          anchoring point of the portboard buoy
private  Vector2 mount_right
          anchoring point of the starboard buoy
 Vector2 right
          starboard buoy of the port
 
Constructor Summary
Port(Vector2 l, Vector2 r)
          Constructor.
 
Method Summary
 void crashWithPlayer(Player p)
          Checks the collisions between a player and the gate buoys.
 void move(float seconds)
          Moves the buoys towards the anchoring position if they aren't there.
 boolean passed(Vector2 p1, Vector2 p2)
          Checks if the line segment p1-p2 (the interval traveled by the boat) intersects with this gate while going to the allowed direction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

left

public Vector2 left
portboard buoy of the port


right

public Vector2 right
starboard buoy of the port


mount_left

private Vector2 mount_left
anchoring point of the portboard buoy


mount_right

private Vector2 mount_right
anchoring point of the starboard buoy

Constructor Detail

Port

public Port(Vector2 l,
            Vector2 r)
Constructor. FIXME: (1.1) Use p and s (portboard/starboard)

Parameters:
l - position of the portboard buoy
r - position of the starboard buoy
Method Detail

move

public void move(float seconds)
Moves the buoys towards the anchoring position if they aren't there.

Parameters:
seconds - time slice according to which the buoys should be moved

crashWithPlayer

public void crashWithPlayer(Player p)
Checks the collisions between a player and the gate buoys.

If there is a collision, the buoy should be moved.

Parameters:
p - the player to check the collisions with

passed

public boolean passed(Vector2 p1,
                      Vector2 p2)
Checks if the line segment p1-p2 (the interval traveled by the boat) intersects with this gate while going to the allowed direction.

Returns:
true if intersects correctly, false if doesn't