C# Класс SimpleSoccer.Net.SoccerBall

Наследование: MovingEntity
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
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

Приватные методы

Метод Описание
RandomClamp ( ) : double

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

Описание методов

AddNoiseToKick() публичный статический Метод

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
Результат Vector2D

CalculateFuturePosition() публичный Метод

Given a time this method returns the ball position at that time in the future
public CalculateFuturePosition ( double time ) : Vector2D
time double
Результат Vector2D

CalucateTimeToCoverDistance() публичный Метод

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
Результат double

Kick() публичный Метод

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
Результат void

PlaceAtPosition() публичный Метод

positions the ball at the desired location and sets the ball's velocity to zero
public PlaceAtPosition ( Vector2D NewPos ) : void
NewPos Vector2D
Результат void

Render() публичный Метод

public Render ( Graphics g ) : void
g System.Drawing.Graphics
Результат void

SoccerBall() публичный Метод

public SoccerBall ( Vector2D position, double ballSize, double mass, List pitchBoundary ) : System
position Vector2D
ballSize double
mass double
pitchBoundary List
Результат System

TestCollisionWithWalls() публичный Метод

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
Результат void

Trap() публичный Метод

public Trap ( ) : void
Результат void

Update() публичный Метод

updates the ball physics, tests for any collisions and adjusts the ball's velocity accordingly
public Update ( ) : void
Результат void