Updating older bottom brackets

It works on all kinds of systems (phones, mac, windows, Linux, ...) and once understood it's a lot of fun to work with.

To make our lives easier we will also use the GLUT library.

updating older bottom brackets-56updating older bottom brackets-1

It just provides us with a few more Open GL functions that would be a bit harder to implement otherwise (things like drawing text or creating a window).All we have to do to make Open GL and GLUT work are two things: 1.So let's use our draw Text function in our draw function in order to draw our score: This draws a score like "1:3" at the top center of the window (that's why the x coordinate is roughly width/2 and the y coordinate is roughly height).Since we want to make a game in C , we have to convert our integer score values to a string in order to use it with our draw Text function. Here is the int2str function, feel free to use it any time you want to convert a integer value to a string: We really want to see something now, so let's run the program. We have to save the position and the size of each racket.But in the background, update and draw are already called all the time (about 60 times per second). We want to make a 2D game, so obviously we have to tell Open GL that.

We will create a new enable2D function that will do all the Open GL configurations that are needed in order to let things appear in 2D.

We will just take the function as it is, without worrying too much about whatever crazy math is behind it: Besides that, we also want to draw our ball and our rackets in white, hence the gl Color3f function call in there.

The gl Color3f function takes three parameters, which are a red, green and blue factor. So if we would want to draw everything in red, we would call gl Color3f(1.0f, 0.0f, 0.0f) instead.

Download the needed Files, extract them and place them in our project in the same directory that holds the file (in our example it's C:/pong/pong/).

Our project directory should then look like this: 2.

Once installed, we open Visual Studio and select File-Project from the top menu: Now we select Win32 as Project type and then Win32 Console Application as Template.