Air Hockey Tutorial 2

This tutorial will teach you how to use the SwinGameSDK to develop a simple air hockey game. At the end of this tutorial you should be able to use Visual Basic 6 to implement your game which makes use of Vectors, Sprites and SoundEffects.

Creating an AirHockeyGame Type
In GameLogic we are going to create a function called "CreateGame" which will return a AirHockeyGame. This will start to set up the data structure for the our game. The data that needs to be in the an AirHockeyGame data type is Players, Ball and TablePics. First before we can create the data types we need to load the pictures so we can use them. The pictures are [[Media:AirHockey_Pics_Tutorial_2.zip|here]] for you to download. To do this go into "GameResources" and in the "LoadImages" method put this code:

At the moment we will create the Ball and TablePics. In here we have created a game with a ball and a table, but the table is empty. Now we need to create a table using a function called "CreateTable" which is called in "CreateGame". This will return all of our pictures for our table.

Drawing The Table
Now that we have loaded the pictures for the table we need to display them. For this we are going to make a Draw method that will draw everything we want to the screen. At the moment all we want to do is draw the table and change the background colour. So Draw will look like this: Now you need to call Draw in the loop that is in Run, Run should now be:

Setting The Constants Of The Table
To make some of the code easer to read we will add some constants. These will be things like the position of the sides and so on.

Download
Here is a copy of everything that is covered in this tutorial [[media:Air Hockey Tutorial 2.zip|Air Hockey Tutorial 2.zip]]

List Of Tutorials

 * 1) Introduction
 * 2) Table
 * 3) Ball
 * 4) Player
 * 5) AI
 * 6) Scoring
 * 7) Sound
 * 8) Menu
 * 9) Finishing