new Bullet(position, image, speed, ctx, canvasSize, damageopt, isPlayeropt)
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
position |
position | x and y. |
||
image |
HTMLImageElement | Image for bullet. |
||
speed |
number | Bullet speed. |
||
ctx |
CanvasRenderingContext2D | Canvas context. |
||
canvasSize |
canvasSize | Canvas width and height. |
||
damage |
number |
<optional> |
1
|
Bullet damage to collided object. |
isPlayer |
boolean |
<optional> |
false
|
Does the bullet belong to player? |
Methods
_destroy()
- Source:
Called when bullet is out of canvas.
_isInsideCanvas() → {boolean}
- Source:
Check if player is inside canvas.
Returns:
- Type
- boolean
draw()
- Source:
Draw function for bullets.