
180 6. Collisions and Entities
• Planet Collision. Two spaceships y around, bouncing o a planet and each other.
– Demonstrates how to call the bounce function for the two entities involved in
a collision.
– e planet is assumed to have innite mass relative to the spaceship.
– Demonstrates displaying semitransparent images using the alpha channel.
• Gravity. A yellow ball bounces inside a blue box.
– Simulates how gravity aects a falling object.
– Energy is lost on each bounce.
• Orbit. A spaceship orbits a planet.
– Demonstrates the Entity::gravityForce function to calculate the force
applied by gravity between two entities.