# Visual Basic > Games and Graphics Programming > Game Demos >  VB6: 2P Cannon Game [Source and Exe]

## metalmidget

This is a simple 2D 2P cannon game where you choose your position and angle and fire away at the enemy. Didn't take that long once I got the physics right, but I'm pretty happy with it for a first version.
I'm planning on adding powerups and the like and possibly a CPU option to play it 1P.
Any ideas for powerups etc?

PS: comments and constructive criticism are welcome and encouraged

----------


## singularis

Played it against myself  :Frown: , it was absolute madness.  :Smilie:

----------


## int3gral

i like it,
may i suggest though making it a little more visually apealing.
power ups might includes things like mines ?

----------


## metalmidget

yeah i tend to skimp a little on visuals in my games. I have a lot more fun getting the code to work so i sorta just give the visuals the bare minimum. I've yet to actually have any animation in anything. My 2D platformer uses a sprite that just glides, rather than running  :Smilie:

----------


## int3gral

great..
lol
gliding sprites

----------


## alihan1988

Good Game. I love it.

----------


## metalmidget

This is the first version of this game that I made. Go check out the red link in my sig to see the final version with powerups, AI, nicer graphics etc. Let me know what you think!

cheers,
metal

----------


## Obercoder

Very nicely coded, indented, and documented. The GUI and the code are very clean and logical. I did start making some improvements though. I put "Option Explicit" at the top of the code and declared all variables. This saves some memory and improves performance (albeit imperceptibly in this case). I changed the keyarray indexes from integers to constants: 32 to vbKeySpace, 37 to vbKeyLeft, 38 to vbKeyUp, etc. These constants are built-in, improve readability, and do not affect performance. I changed '200' to a variable named "velocity" as I plan to make this changeable. If I left it as a constant, I'd declare "Private Const VELOCITY = 200" at the top and use VELOCITY in the code, just for readability. Using all-caps for my constants is my own convention and not standard btw. I checked all of the boxes in the "Advanced Optimizations" dialog box before compiling for (slightly) better exe performance.

Anyway, this is a nice little program. Thanks for posting!  :Thumb:

----------


## Obercoder

I forgot to mention ideas for improvements:

POWER-UPS:

For power-ups or point bonuses, I'd award extra points for how close to the center of the enemy canon a shot lands - probably just one kind: "Direct Hit!" for a strike to within, say, 5 to 10 pixels from the middle of the canon. (the twips are going in favor of pixels lol)

ONE PLAYER MODE:

I'd change the controls to the arrow keys for the human. The computer could have four or five levels of difficulty. As it is, the player can move quite a bit between the time a bullet is launched and lands, so the computer cannot calculate an accurate shot, but how equally spread and close to the center of the user's field can affect the likelihood of a successful shot. It would be harder for a human if shots did not come in order (like left-to-right in sequence) but randomly.

I have no interest in writing a 2 player game (no friends), but I may write a complete one-player version of this with different difficulty levels (and real explosions probably). If I do, I will post it on this site, well-documented and hopefully quite instructive and fun! It will probably have 10+ levels of increasing difficulty (regardless of the overall difficulty level first selected). You'll probably 'die' if you're hit too many times and/or your accuracy isn't good enough.

----------

