Ok I am currently making a game in Visual Basic 6. Its my first game and i have some fireballs to be shooting at the enemy ships. But, too many fireballs are being shot when i press the spacebar and i need to find a way to limit this. <img src=\'http://www.killanet.net/forum3/public/s ... Debate.gif\' class=\'bbc_emoticon\' alt=\'(debate)\' /> I have this keyarray in an Array timer so it can tell when the key is pressed. I was wondering if anyone knew a way i can limit the amount of shots by hitting the spacebar. <img src=\'http://www.killanet.net/forum3/public/s ... >/blum.gif\' class=\'bbc_emoticon\' alt=\':P\' />
I can't personally help you - because I don't know how to programme - however I found this [url="http://www.vb6.us/"]open source site[/url] which has several game development tutorials for VB6, and there seem to be some tutorials which will help you.
For Example:
Understanding control arrays - This explains the very useful feature of control arrays. Control arrays allow you to create controls at runtime.
Understanding the timer control - The timer control is very useful learn how to use it effectively.
And there is this site, which is all about developing [url="http://www.vbgames.com/"]VB Games[/url]. On the front page, it appears they are also offering a free book which you might find informative:
[quote]Programming Games for Beginners - VB 6.0
Have you ever wanted to create your own game, but found it hard to learn how? This book teaches you the basic skills needed to program Visual Basic Games. The basic concepts and techniques behind creating your own Visual Basic Games can be easily learned by anyone with a little programming know-how. Price: Free![/quote]
They also offer downloadable VB games with source code.
[color=\"#41211C\"]It takes years to build up trust and only seconds to destroy it
Thank you Tami, but I have already used control arrays in this program and I already know how to use it. But, the information you provided was useful about that book so I thank you for that. That piece of code that i posted is in a timer.
Here's the full code for the timer.
[code]Private Sub tmrArray_Timer()
Dim NUM As Integer
'ARROW KEYS
If PLAYER1_EXIST Then
If KeyArray(39) = True Then
SHIP(0).X = SHIP(0).X + 25
End If
If KeyArray(37) = True Then
SHIP(0).X = SHIP(0).X - 25
End If
If KeyArray(38) = True Then
SHIP(0).Y = SHIP(0).Y - 25
End If
If KeyArray(40) = True Then
SHIP(0).Y = SHIP(0).Y + 25
End If
If KeyArray(32) = True Then 'Spacebar Shoot [This bit lets the user use the spacebar to shoot fireballs.]
Call MAKE_FIREBALL(0)
End If
End If
End If[/code]
But the bad thing is, its shooting too many at a time. I cant find a way to limit this.
Last edited by Twister on Thu Nov 08, 2007 1:54 pm, edited 1 time in total.
MAKE_FIREBALL makes the fireball paints the picture and put its into the center of the shipcraft. For the enemy ship and the player 1 & 2 ship. and i know that it has to lay with that specific part of the code but i dont know how to limit the shots... and the (0) identifies which ship its coming from (0) is 1st player (1) is second player and remaining array numbers are for enemy ships. but all i need is for 0 and 1
Last edited by Twister on Thu Nov 08, 2007 8:09 pm, edited 1 time in total.
You have a timer and I'm assuming it's set on a very low interval so the game can update fast. So every time that timer is going through the code it's looking if you're pressing that spacebar and when you press that spacebar it is to make a fireball. I don't have VB6 installed anymore so I can't play around so I'm not sure how to find a solution to this.
I remember a long time ago that I used a KeyDown event on keyboard buttons. On KeyDown I would make it execute something (such as making a fireball shoot).
Let me see if I can find my VB6 installation CD's to play around with it a bit.
[align=center]
“If you stop learning, you stop living.” ~Tami Quiring
“It's the rare man who understands the value of a single perfect rose.”
thanks dren... if you hold it down it still does the same thing but u cannot move and press the spacebar down which is a good thing so i guess this can work for now but i want it to limit the amount thats being shot but thanks for that because it can be very useful.