Home

Forum

Games

~~~~~~~~~~~~~

Chapter
Examples



Programming 2D Games

Official site of "Programming 2D Games" the book
by: Charles Kelly

Chapter 6 Collisions and Entities

Bounce

One spaceship bounces off the d\edges of the window.

  • Demonstrates collisions with the edge of the game screen.

Bounce

download......(Source Included)

Planet Collision

Two spaceships fly around bouncing off a planet and each other.

  • Demonstrates how to call the bounce function for the two entities involved in a collision.
  • The planet is assumed to have infinite mass relative to the space ship.
  • Demonstrates displaying semi-transparent images using the Alpha channel.

Planet Collision

download......(Source included)

Gravity

A yellow ball bounces inside a blue box and off the paddle.

  • Simulates how gravity affects a falling object.
  • Demonstrates BALL and ROTATED_BOX collision.
  • The paddle is moved with left/right arrow keys.

Gravity

Download......(Source included)

Orbit

A spaceship orbits a planet.

  • Demonstrates the Entity::gravityForce function to calculate the force applied by gravity between two entities..

Orbit

download......(Source Included)

 

Collision Types (Bonus Material)

A spaceship may be moved using the arrow keys. When it collides with one of the targets the collision vector is displayed in light blue. The collision type is selcted by pressing a number:

  1 = Rectangle  2 = Box
  3 = Circle     4 = Pixel Perfect

  • Demonstrates how the different collision types interact.
  • Demonstrates the use of the stencil buffer.
  • Note! Box collision is only used when both entites are using Box collision.

Collision Types

download......(Source included)

   


Creative Commons License
Programming 2D Games Examples by Charles Kelly are licensed under a Creative Commons Attribution 3.0 Unported License.

 

This website copyright © 2012 by Charles Kelly, All Rights Reserved

Last Updated:

24 May, 2013