C# Class SimpleSoccer.Net.SoccerBall

Inheritance: MovingEntity
Show file Open project: soshimozi/SimpleSoccer.Net Class Usage Examples

Public Methods

Method Description
AddNoiseToKick ( Vector2D BallPos, Vector2D BallTarget ) : Vector2D

this can be used to vary the accuracy of a player's kick. Just call it prior to kicking the ball using the ball's position and the ball target as parameters.

CalculateFuturePosition ( double time ) : Vector2D

Given a time this method returns the ball position at that time in the future

CalucateTimeToCoverDistance ( Vector2D A, Vector2D B, double force ) : double

Given a force and a distance to cover given by two vectors, this method calculates how long it will take the ball to travel between the two points

Kick ( Vector2D direction, double force ) : void

applys a force to the ball in the direction of heading. Truncates the new velocity to make sure it doesn't exceed the max allowable.

PlaceAtPosition ( Vector2D NewPos ) : void

positions the ball at the desired location and sets the ball's velocity to zero

Render ( Graphics g ) : void
SoccerBall ( Vector2D position, double ballSize, double mass, List pitchBoundary ) : System
TestCollisionWithWalls ( List walls ) : void

Tests to see if the ball has collided with a ball and reflects the ball's velocity accordingly

Trap ( ) : void
Update ( ) : void

updates the ball physics, tests for any collisions and adjusts the ball's velocity accordingly

Private Methods

Method Description
RandomClamp ( ) : double

returns a random double in the range -1 < n < 1

Method Details

AddNoiseToKick() public static method

this can be used to vary the accuracy of a player's kick. Just call it prior to kicking the ball using the ball's position and the ball target as parameters.
public static AddNoiseToKick ( Vector2D BallPos, Vector2D BallTarget ) : Vector2D
BallPos Vector2D
BallTarget Vector2D
return Vector2D

CalculateFuturePosition() public method

Given a time this method returns the ball position at that time in the future
public CalculateFuturePosition ( double time ) : Vector2D
time double
return Vector2D

CalucateTimeToCoverDistance() public method

Given a force and a distance to cover given by two vectors, this method calculates how long it will take the ball to travel between the two points
public CalucateTimeToCoverDistance ( Vector2D A, Vector2D B, double force ) : double
A Vector2D
B Vector2D
force double
return double

Kick() public method

applys a force to the ball in the direction of heading. Truncates the new velocity to make sure it doesn't exceed the max allowable.
public Kick ( Vector2D direction, double force ) : void
direction Vector2D
force double
return void

PlaceAtPosition() public method

positions the ball at the desired location and sets the ball's velocity to zero
public PlaceAtPosition ( Vector2D NewPos ) : void
NewPos Vector2D
return void

Render() public method

public Render ( Graphics g ) : void
g System.Drawing.Graphics
return void

SoccerBall() public method

public SoccerBall ( Vector2D position, double ballSize, double mass, List pitchBoundary ) : System
position Vector2D
ballSize double
mass double
pitchBoundary List
return System

TestCollisionWithWalls() public method

Tests to see if the ball has collided with a ball and reflects the ball's velocity accordingly
public TestCollisionWithWalls ( List walls ) : void
walls List
return void

Trap() public method

public Trap ( ) : void
return void

Update() public method

updates the ball physics, tests for any collisions and adjusts the ball's velocity accordingly
public Update ( ) : void
return void