# Visual Basic > Games and Graphics Programming > Game Demos >  VB:Alpha Dogfighter Game 2D

## technorobbo

After playing with the concept for a week or so, I finally came up with a polished demo.

Feel free to modify or ask questions. It's pretty fast but you can make it faster by dropping the speed delay. I can't seem to play it much faster than it is. I get killed too often.

It uses API calls for all graphics. The sound is Directsound.

Graphics 32 Bit Alpha Channel files I call *.spr, one of the module includes the sprite file making routine. I've included the Alpha and bitmap files used for the spritemaker so you all can play. 

The controls are the arrow keys up,down left, right and spacebar to fire your rockets. Esc Key exits the game.

Graphic files make it too big to upload so Here's a link

http://home.comcast.net/~technorobbo/Alpha.zip

----------


## technorobbo

Version 1.1.0.50 was just uploaded. it includes alternate 4 scenes seamlessly interwoven. So if you can survive that long, you'll have some cool stuff to look at.

----------


## technorobbo

Update Revision 1.1.83 available:
Mostly code clean up - less memory usage - Some graphics cleanup.

Added more comments to source to code and arranged the code logically. This way you can dissect and modify easier.

AI is more agressive. 
How aggressive? It's a constant you can set - I guess you could call that the level of difficulty. The lower you set it the more likely they are to kill you. 

Your plane now drifts to center, not the bottom of screen. Keeps your on your toes!

Map Loader is now occuring after you get killed in the Tundra Map after the first fork in the river. If you survive the Tundra map will not update. Map replacement causes a pause in the code so I do it during the pause when you get killed.

There are now 4 maps:

Tundra Base Map (main map ties together all map transitions)
Ocean Map (with battleships)
Desert Oil Refinery Map 
River Canyon Map.

----------


## technorobbo

Revision 1.1.84 

New airplane graphics - All original art now!

Plane also has banking animaton.

1 potential bug corrected, No issue had appeared but it was a bug either way.

----------


## technorobbo

REVISION 1.1.89

By Rewriting the map transition routine to include the map loops and map transitions on 1 bitmap. I halved the size of files needed and was able to load all maps at once. Map Loader routine has been Rem'd out in source code for future use. 

AI Planes (my bogeys) now bank on turns like the players plane - animation graphics included in sample zip.

- Stay tuned for any new updates.

----------


## Jim Davis

Wow it's nice! And everything is done on one form, and by using one single module. It's great!  :Thumb:  

Theres only one thing i found so far. You are forgot to implementing the speed modifier, that is used to keep the game flow on a continous speed. You may noticed that your game speed is fluctuate, based on what it is does at the moment. For example, on each time the map is changed, the game is slows down, then speeds up. It may be a bit annoying. But, you can avoid it, by multiplying all the calculations where you implement speed intervals (just like the MapSpeed, RocketSpeed, and so on..) at _each frame_ with a time interval that is you can retrieve from the last frame your code drawn. To get an accurate timer, you can use the QueryPerformanceCounter() api. I have attached an example, how to implement this api.

Now, before your program enters the do..loop, call the initialization in the following order.

modQPT.Timer_InitTimer: modQPT.Timer_StopTimer: modQPT.Timer_ResetTimer

This will set up the timer, and it sets a valid interval for the timer_elapsed, that is you can call later.

Create a new value to store the response from the method timer_elapsed(), for later usage.
Dim FrameDrawTime As Double

At the very beginning of the do-loop, do a check to see if the value of FrameDrawTime is zero, or negative value, and set it to 0.001 (1 uc). Otherwise it may cause hanging, or reverse movement in the game.

If FrameDrawTime <= 0 Then FrameDrawTime = 0.001 

Now, in the do-loop, all the movement and speed calulactions, you have done, shold be multiplied by using this value. For the first time you implement this method, it will cause a huge speed drop, because you are multiplied calculations with a pretty small value (0.015 for example). So, to get the same speed you got before, all the speed constants you set, you have to multiply by 1000 for example. Just go and fine tune it.

Nah.. at the very end of your do-loop, you can retrieve how many microseconds elapsed to drawing this frame by this way:

modQPT.Timer_StopTimer
FrameDrawTime = modQPT.Timer_Elapsed 'store the time interval, for using in the next frame.
modQPT.Timer_ResetTimer

So..... The purpose of this method is, to keep the game speed in sync. If, drawing a  frame took more time, than the previous frame was, the timer will gives a higher value, so the calculated step sizes on the next frame will be higher. But, all you can see is that the map is flowing on a continous speed, because the timer is continously modifies the stepsize, in the right order!

Not to mention, there is an another big advantage of this method. This game will run on the exactly same speed on all kind of machines. For example, if a machine cannot produce more than 10 frames (or less) per seconds, it doesnt matter, because the timer produces higher values, so the movement speeds got higher values, the game will run on speed, you are set before.

Did you understand what am i talking about?  :Smilie: 

Ps: I love the explosion effect, reminds me the old commodore times  :Smilie:

----------


## technorobbo

I implemented that on the 3D version cause the directX was just too darn fast. My computer ran this GDI version fast but not too. (Allegro non troppo). So I left that out. Since I started the 3D version I shifted all my resources towards it. Maybe someday I'll revisit the 2D game. It was suppose to be reminiscent of the old Commodore and NES type games I'm glad you liked it.

----------

