new Ball(p_context, p_init)
This:
Parameters:
| Name | Type | Description |
|---|---|---|
p_context |
CanvasRenderingContext2D | The 2d context of the canvas upon which the ball is to be drawn. |
p_init |
Object | An object that contains initialization values for the attributes
rInit, xInit, yInit,
vxInit, vyInit,
borderWidth, borderColor,
and color. |
Members
-
borderColor :String
-
The color of the border of the ball.
Type:
- String
-
borderWidth :Number
-
The width of the border of the ball.
Type:
- Number
-
color :String
-
The color of the ball.
Type:
- String
-
r :Number
-
The radius of the ball.
Type:
- Number
-
rInit :Number
-
The initial radius of the ball.
Type:
- Number
-
vx :Number
-
The x-velocity of the ball.
Type:
- Number
-
vxInit :Number
-
The initial x-velocity of the ball.
Type:
- Number
-
vy :Number
-
The y-velocity of the ball.
Type:
- Number
-
vyInit :Number
-
The initial y-velocity of the ball.
Type:
- Number
-
x :Number
-
The x-position of the ball.
Type:
- Number
-
xInit :Number
-
The initial x-position of the ball.
Type:
- Number
-
y :Number
-
The y-position of the ball.
Type:
- Number
-
yInit :Number
-
The initial y-position of the ball.
Type:
- Number
Methods
-
draw()
-
Draws the ball at its current position onto a 2d context.
-
move(p_delta_t)
-
Moves the ball in direction (vx,vy); the step size depends on FPS.
Parameters:
Name Type Description p_delta_tNumber The time elapsed since the last call of move. -
reset()
-
Resets the ball: Moves the ball to its starting position and computes randomly a velocity vector.