new Paddle(p_id, p_context, p_init)
This:
Parameters:
| Name | Type | Description |
|---|---|---|
p_id |
int | The identifier of the paddle (i.e. the number of the paddle) |
p_context |
CanvasRenderingContext2D | The 2d context of the canvas upon which the paddle 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
-
<static, constant> DOWN :int
-
Type:
- int
-
<static, constant> LEFT :int
-
Type:
- int
-
<static, constant> RIGHT :int
-
Type:
- int
-
<static, constant> UP :int
-
Type:
- int
-
ax :Number
-
The x-acceleration of the paddle.
Type:
- Number
-
axInit :Number
-
The initial x-acceleration of the paddle.
Type:
- Number
-
ay :Number
-
The y-acceleration of the paddle.
Type:
- Number
-
ayInit :Number
-
The initial y-acceleration of the paddle.
Type:
- Number
-
borderColor :String
-
The color of the border of the paddle.
Type:
- String
-
borderWidth :Number
-
The width of the border of the paddle.
Type:
- Number
-
color :String
-
The color of the paddle.
Type:
- String
-
height :Number
-
The he height the paddle.
Type:
- Number
-
vx :Number
-
The x-velocity of the paddle.
Type:
- Number
-
vxInit :Number
-
The initial x-velocity of the paddle.
Type:
- Number
-
vy :Number
-
The y-velocity of the paddle.
Type:
- Number
-
vyInit :Number
-
The initial y-velocity of the paddle.
Type:
- Number
-
width :Number
-
The width of the paddle.
Type:
- Number
-
x :Number
-
The x-position of the paddle.
Type:
- Number
-
xInit :Number
-
The initial x-position of the paddle.
Type:
- Number
-
y :Number
-
The y-position of the paddle.
Type:
- Number
-
yInit :Number
-
The initial y-position of the paddle.
Type:
- Number
Methods
-
draw()
-
Draws the paddle at its current position onto a 2d context.
-
move(p_delta_t)
-
Moves the paddle 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 paddle: Moves the paddle to its starting position.
-
start(p_direction)
-
Starts the paddle moving in a particular direction.
Parameters:
Name Type Description p_directionint Either $wk$.Paddle.LEFT,$wk$.Paddle.RIGHT,$wk$.Paddle.UP, or$wk$.Paddle.DOWN. -
stop()
-
Stops the paddle moving.