# Visual Basic > Games and Graphics Programming > Game Demos >  [VB6] Penny Arcade

## JQuinn

*** Improvements as of 12/28/05 ***

BUGFIXES
----------
-Fixed a bug with the game halting when the Air Crisis help screen is called (must have been slow in the head that day; used bRunning to break the game totally instead of loading the help screen as Modal) <- 12/28/05
-Fixed the slight delay with the controls (switched from the GetKeyState API to DirectInput) <- 12/24/05.

CHANGES
----------
-Smaller .zip files after compressing the .wavs to .mp3 (used 48-bit for the bitrate when compressing the wavs.  This results in a smaller file without too much quality loss)
-Switched from DirectSound to DirectShow to play the .mp3s (thanks to Jacob Romain's tutorial that he was kind enough to link to).

PENNY ARCADE
---------------
-All three of the main game screens have their own backgroud music.
-If you hover your mouse over the picture buttons a tooltip appears with the name of the games.
-Both of the games are accessable from the menu within the games.

AIR CRISIS
-----------
-Flickerfree Graphics (thanks to the BitBlt API).
-High Scores are stored in the registry.
-The gem's speed increases every 5 points.
-Help Screen
-Pause

TIC-TAC-TOE
--------------
This is just a basic tic-tac-toe game for two players.  There's no special features.

Penny Arcade Source:
http://www.savefile.com/files/4384284

Penny Arcade Executable:
http://www.savefile.com/files/1161445

Any graphical buttons that I put in look like crap.  Probably should just put a message that pops up to press a button to start the game.    :Stick Out Tongue:  

If you have any questions, comments, suggestions, or find any bugs that I didn't root out feel free to post them here.   :Big Grin:

----------


## Jacob Roman

It's nice but I have a few suggestions. First of all, to help decrese your file size, use mp3's instead. To play the mp3's, here are two ways (Post #2 is my way):

http://www.vbforums.com/showthread.php?t=357381

And the controls for the Air Crisis game are a bit jerky. Like when you hold down the arrow key, it'll move once, pause, then start moving in the direction consistantly. To solve this problem, take a look at this sample control program I made awhile back:

Control.zip

Although that's the pure VB method, and works nicely, I typically use DirectInput instead, which might be a bit advance for ya.

If the BitBlt API tends to be a bit slow (and it occasionally is), you should look into using DirectX. I myself am making a massive DX8 2D tutorial (soon to have 3D, DirectInput, DirectSound, DirectMusic, DirectShow, and DirectPlay) but it's far from complete. Got only 16 tutorials so far. You can get it here:

DirectXGraphics.zip

And here's another DirectX8 tutorial, only it's not mine.  :Wink: 
http://directx4vb.vbgamer.com/Direct...T_DX8Start.asp

Also, lose the command button that was on the clouds. Windows controls and graphics don't look right when together.

----------


## JQuinn

Thanks for the suggestions, I'll definately look into em.  I knew about the jerkyness with the arrow keys and wasn't sure how to fix them using the GetKeyState API, but will try the Sleep API to fix it (or can do it the hard way like the Bullet Dodger guy did   :Stick Out Tongue:  ).  I used that API because it allowed diagonal movement without alot of coding and was in the tutorial that I followed, but never really looked into DirectInput as a way to make the plane move.  The music files are MP3s that have been decompressed into .Wav format then recompressed with Sound Recorder.  I'll probably use that method for playing MP3s now that you have provided me with a way (couldn't find a way in my search so had to use the .wav).

Originally, I wanted to make Air Crisis in DirectX but most of the tutorials out there are either hard to follow or fall apart in the end.  BitBlt was pretty easy to understand using the tutorials on programmer's corner.com so I used that.  I supposed I could have done the same thing with the game using the top and left controls of the pictures, but what's the fun in doing that?  You don't learn anything new   :Big Grin:  .

----------


## Jacob Roman

I didn't use any API's to fix the control problem  :Wink:

----------


## JQuinn

Thought that Sleep was an API.  

Thanks for your help, Jacob.  I tried to make heads or tails of the control.zip stuff, but couldn't due to the lack of comments in the file.  I ended up going with DirectInput to control the plane and switched from DirectSound to DirectShow using your guide that you posted.

What bitrate do you recommend when compressing the wavs to mp3 format?

----------


## Jacob Roman

> Thought that Sleep was an API.  
> 
> Thanks for your help, Jacob.  I tried to make heads or tails of the control.zip stuff, but couldn't due to the lack of comments in the file.  I ended up going with DirectInput to control the plane and switched from DirectSound to DirectShow using your guide that you posted.
> 
> What bitrate do you recommend when compressing the wavs to mp3 format?


Sleep is an API, but had nothing to do with the control scheme. It was to help slow down my loops at a certain framerate. I no longer use the Sleep API for that. Instead I use the QueryPerformanceCounter and QueryPerformanceFrequency API's (which retrieves the time from the system and is 1 ms accurate) and use those to help lock the framerate at 60 frames per second. But whenever I work with DirectX, I don't have to cause DirectX locks it for you at the monitors refresh rate.

And the reason why it had no comments cause it was so easy to implement the control, it was unnecessary. 

I would make the mp3's 128 kbps. Since DirectShow is a separate component from DirectX, you have to reference a different object rather than DirectX for visual basic type library. So you go up to Project > References... and check off the ActiveMovie control type library. And the DirectShow code should work. Be sure you are putting my code in a module though and NOT a form or a class module.

----------


## JQuinn

I already got everything working with DirectShow by the time I posted the message.  Even though the controls code is self documenting, it's still nice to see comments in the code.  Tends to help newbies like me know exactly what is going on without having to go to other tutorials to see what the API or whatever does.  For me, it's not enough to know that the code makes the program work, I have to know what the code does for future reference.

I reduced the wav down to 48 bits.  The resulting mp3 didn't seem to have suffered any quality loss and helped to reduce the zip file containing the source code down to 3 MB.  That's an improvement over the old compressed file.  I'll post the source with the improvements after I get everything commented and clean up some of the DirectShow code that I don't need.

----------


## JQuinn

I made some necessary fixes to Penny Arcade.  You can download the updated version in the first post.

----------


## Jacob Roman

You should keep all of the DirectShow code. That module I created is known as a DirectShow engine, which contains many tools (subs/functions actually) to do whatever you wish with mp3's, even changing the speed of them. Although you aren't going to use all of the functions, you can take that same module and use it for your next project. It's pretty much reuseable.  :Wink:

----------


## JQuinn

To make life easier on myself, I tend to only add code to my programs that I absolutely need.  If I make a media player in the future and experiment with DirectShow, I'll keep the entire engine in tact.

Do you have any suggestions on what to replace the start button with?  I'm thinking about putting it in the menu, but I can do anything else.  I probably won't put a main menu in until I get Direct3D for 2D graphics figured out.

Probably should just stick with BitBlt for now and add the stuff that I wanted to in order to make the game more challenging (gunna put bombs in there that multiply depending on the timer and result in end game if the player hits one.  Should increase the fun factor of the game as well as making it fit the title better).

Question about Direct3D though.  If you put in a 2D background like I have in Air Crisis, can I just throw the in the background of the form, or do I have to treat the pic as a texture?   :Confused:

----------


## Jacob Roman

> Do you have any suggestions on what to replace the start button with?  I'm thinking about putting it in the menu, but I can do anything else.  I probably won't put a main menu in until I get Direct3D for 2D graphics figured out.


Replace it with a graphical looking start button. 




> Question about Direct3D though.  If you put in a 2D background like I have in Air Crisis, can I just throw the in the background of the form, or do I have to treat the pic as a texture?


All of your images will need to be as textures, cause DirectX swaps the backbuffer onto your window, which ends up covering all of your controls that were on the form, assuming you used the forms hWnd and not a picturebox.

----------


## JQuinn

Thanks, Jacob.  That's what I figured.  Looks like I actually have to do some real programming in DirectX and program the application to draw everything on screen instead of just placing pictureboxes and controls on the form.  It was pretty easy to figure out your DirectShow tutorial and the DirectInput tutorial that I followed, but Direct3D's gunna take a bit more to figure out.

Personally, I didn't like BitBlt to begin with.  I don't see the point in learning the ins and outs of an API that just functions to draw picture boxes on the screen (can resize em with StetchBlt, but...).  DirectX seems like it's more worth my time to learn because it's more robust.

Air Crisis is fast in BitBlt, but can probably be better in DirectX.  It's too bad that VB6 doesn't support DirectX 9 though.    :Cry:

----------


## JQuinn

I fixed a small bug with the Help screen that I missed until today.  You can download the new files in the first post.

I'll probably call this project done after today and start on a business application.  Don't want my skills there to get rusty.

With 117+ views of this post, there must be some people that actually like chasing an object around the screen to score points.  Suprised I haven't heard any feedback from anyone else besides Jacob.  Might be something in the game that still needs fixing that I haven't caught.    :Alien Frog:  

A future version of the game will probably be in DirectX.  Seems to be easy enough to figure out, just more programming involved then with BitBlt.

----------

