Basketball

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:
Basketball

Source

Advertisements

Making Paint.

Recently, I took on a project that turned out to be real fun. I attempted to recreate paint. With OpenGL handling the drawing, it was a task to find a good UI library that integrated OpenGL code. An obvious solution would be to use Win32 controls but they’re cumbersome and difficult to use. GLUI turned out to be a disappointment as well, as it refused to work with Visual Studio without the dll. Finally, FLTK provided a much needed break. It’s pretty spiffy as far as GUI libraries go, is cross platform as well.

It’s also the first time I’ve split a project onto a more than 3 source files;
Screenshots:

 

Source

Release (Windows) 

Stock Quotes

StockSearch is a nifty little application that retrieves Stock Market data using the Yahoo! Finance API. This is the first time I’ve used HTTP in an application.

HTTP requests are handled using the libcurl library.

The app maintains a list of all known stock ticker symbols from the NASDAQ and NYSE. It uses this list to find Companies matching the name or symbol that the user has entered. As of now, the list cannot be updated (The functionality exists in the code but has been commented out).

The app has been written in C++ (Visual C++), The GUI has been written for win32 and hence will not compile on other platforms.

Download the Source

Download the App 

Dictionary

A Windows Dictionary App, written in C++. Unlike its cool cousin Mac OS X, Windows doesn’t come with  dictionary. Not that it’s a feature to die for. But still. Always nice to have it, in case you need it.

I’ve used SQLite3 to retrieve entries from the Data file.

Database management is an integral part of app development, and one that I had no idea about, until recently.

I’ve tried to make the client as small as possible (478KB).

Screenshot:

Download the App

Download the source