We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Shooting

Let's make things more interesting by allowing the player to shoot at the asteroids.

In our game, bullets:

  • Are small circles
  • Move at a constant speed in a straight line
  • Split up asteroids when they collide with them
  • Are spawned by player input (spacebar) and move in the direction the player is facing

Assignment

    • It should inherit from CircleShape, similar to the Asteroid class.
    • Create an __init__ method that accepts x and y. It should call the parent class's __init__ method with x, y, and the SHOT_RADIUS.
    • Override its draw and update methods, just like you did in the Asteroid class.

  • It's expected that holding the spacebar will create a constant stream of bullets. We'll fix that soon.
  • It's expected that bullets pass through asteroids without any consequences. We'll fix that soon, too.

If everything looks right, run and submit the CLI tests.