New example space_shooter: space ship shooting rockets, destroying rocks, flying on a tiling background

Posted on

Space shooter example

Enjoy a new example in our engine: examples/space_shooter. Features:

  • Space ship (click anywhere on the screen, or use arrows, to move it).

  • Background (drawn efficiently as one quad, with texture repeating to infinity).

  • Rockets (fired by the player’s cannons). Each rocker has a collider and can detect when it hit an enemy. Rocket can be “armed” (destroys enemies) or “not” (just a ball that bounces off enemies).

  • Enemies, played by the Mighty Rotating Rocks! They just move slowly towards the player. You can shoot them to destroy.

Technically:

  • The player is just a TCastleScene inside a TCastleViewport, with input events handled in TViewMain.

  • Using TCastleComponentFactory to create rockets and rocks. Each of them is defined by a reusable design.

  • Using behaviors to define various behaviors of rocks and rockets.

  • Using physics to handle collisions between rockets and rocks.

  • Special component TTilingBackground to draw a background that (seems to) repeat to infinity. This is a reworked version of an old example background_tiling.

Start the discussion at Castle Game Engine Forum