My very first sports game! A simple basketball game. Get the ball into the basket. No nonsense, really. The physics for this game was relatively simple. And fun. But then again, physics is always fun.

The key here is to setup a good aiming system. The game builds itself around that. One of the best solutions is to represent exactly half the parabolic path of the ball. The player will still have to judge the path of the ball, but the portion that we show on the screen would give him an idea of the velocity and angle.

Our interest is in calculating the path of the ball, which is determined by two parameters:

  • The velocity
  • The launch angle

Given that the mouse pointer represents the highest point on the parabolic path, both launch velocity and launch angle can be calculated. It’s really simple (should you have taken physics in high school).

Parabolic path of the ball


In the above equations R is the range of the projectile and H is the maximum height to which it rises. It’s easy to see why, for a given position of the mouse, R and H are constants that can be calculated. Rearranging and solving these equations will give us the velocity and angle which is what we need to describe the motion. The velocity will then be resolved into components, for convenience.

The game depends on a few libraries like SOIL for texture loading, freeglut for openGL and irrKlang for audio.

Coming up next is a version with highscore tables! Gotta learn a little php for that 😛

Edit: High score table is live but a little buggy.

Available on gumroad:




Roses are red,
Violets are Blue,
In Soviet Russia,
Tetris plays you

Tetris is a tile-matching puzzle video game originally designed and programmed byAlexey Pajitnov in the Soviet Union. It was released on June 6, 1984. Over the years, Tetris has been released on several platforms, from Nintendo’s NES to the iPhone.

I have attempted to remake Tetris, keeping most of the basic features intact. The game features the original soundtrack as well. 🙂
My version of Tetris is written in C++. I use OpenGL (GLFW Library) to draw, the SOIL library for texture loading, and the irrKlang Library for audio.

Download the C++ source

Download the release 

Note: You need to have the VC Redist installed on your PC

Shoot ‘Em Up

Shoot ‘Em Up is a simple shooting game, where you have to survive for as long as possible. Enemies spawn at random locations and move towards you.

Kill them by firing bullets.

This particular game involved a bit of math, especially making the enemies re – orient themselves when the player moves.

It’s trigonometry time!

Here’s a short of explanation of the math behind that particular feature:

For this game, I’ve written a small 2D Vector class which uses Unit Vector Notation to represent vectors.

Both the player and the Enemies are objects of the particle class. The floating point co – ordinates, and the velocity of a particle are stored as vectors.

The acute angle between the line joining the two particles, and the  x – axis is given by:

Basically, the enemy must move along this line, if it is to reach the player. When this angle is calculated, the velocity of the enemy may be in some other direction. Our goal now, is to “point” the enemy in the direction of the player without changing his speed.

Speed is defined as:

The mod() function of the Vector class gives this result. To re-orient the velocity vector along the new θ, keeping it’s magnitude constant, we calculate the new x and y components as follows:

There is one problem. θ will always be between 0 and π/2. Hence cos θ and sin θ will always be positive. To get around this, we check the sign of Δy and Δx. If Δy is negative, multiply the y component by -1, and if Δx is negative, multiply the x component by -1.

Pointing bullets towards the mouse works in a similar fashion, where the position of the mouse replaces the position of the enemy. Also, the bullet is pointed towards the mouse only at the time of firing.

So there you have it. Application of high school maths and physics in programming. Hope this helped 🙂

Screenshot of the game:


Download the game

Download the source

View the help file

Brickbreaker Gameplay

Falling Balls

Gameplay Trailer