Skip to content

Instantly share code, notes, and snippets.

@EliteIntegrity
Created March 5, 2019 11:13
Show Gist options
  • Save EliteIntegrity/824274b79fffd288c7545b4277605cd8 to your computer and use it in GitHub Desktop.
Save EliteIntegrity/824274b79fffd288c7545b4277605cd8 to your computer and use it in GitHub Desktop.
This code draws all the bullets for the player and the invaders. Add the code after the code which draws the shelters/bricks, as shown.
...
...
// Draw the bricks if visible
for (brick in bricks) {
if (brick.isVisible) {
canvas.drawRect(brick.position, paint)
}
}
// Draw the players playerBullet if active
if (playerBullet.isActive) {
canvas.drawRect(playerBullet.position, paint)
}
// Draw the invaders bullets
for (bullet in invadersBullets) {
if (bullet.isActive) {
canvas.drawRect(bullet.position, paint)
}
}
// Draw the score and remaining lives
...
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment