Re: i need help with my game
Well for starters, its never a good idea to use Timers for games. Timers are bad and get worse the more timers you use because all of the code in one timer must complete before the next one can even fire. If you need help constructing a realtime game loop. I can help you with that. As for your code. If you want all of them to move, use a For loop to loop through all of the barrels you want to move. The number of barrels could actually be placed in the Form_Load statement with the "Dim Number_Of_Barrels As Long" declared on top in the General Declarations.
vb Code:
Private Sub tmrbarrel_Timer()
Dim Number_Of_Barrels As Long
Number_Of_Barrels = 10
For i = 0 to Number_Of_Barrels - 1
If Image3(i).Visible = True Then
Image3(i).Left = Image3(i).Left + 25
End If
Next i
End Sub
Re: i need help with my game
i typed in that code. however only 1 barrel will move now.
btw thanks for helping
Re: i need help with my game
Why only one barrel? Probably has to do with the visible tag. Plus you may wanna stop that other timer.
Re: i need help with my game
idk all that happens is one of the images will continue to increase its left value to the end of the screen.
the other images in the array dont do anything
Re: i need help with my game
Are all of your barrels visible? Basically assuming they were (you may wanna comment that visible line out as a test) it should have moved 10 of your barrels to the right. Plus if you need collision when it collides into something, let me know cause I dont know how your games played. Better yet, could you upload your entire project in a zipfile so I can see?
Re: i need help with my game
Quote:
Originally Posted by
Jacob Roman
Plus you may wanna stop that other timer.
tmrcounter, why?
Re: i need help with my game
Oh i found out whats wrong. when i run this it moves all of the images at the same time. So since they all start off in the same place, it just looks like one object is moving. i wanted to move 1 every time tmrcounter runs. sry i should have specified.
Re: i need help with my game
Because the other timer is using a For loop. Timers must complete the code before the next timer can fire, thats why timers are horrible and should never be used for games. Instead its better to use a realtime game loop.
Basically this is what the codes doing I gave you for tmrbarrel_Timer:
For i = 0 To Number_Of_Barrels - 1 'Loops through all 10 barrels.
If Image3(i).Visible = True Then 'Checks if they are Visible. If they are, move them
Image3(i).Left = Image3(i).Left + 25 'Moves all the barrels to the right
End If
Next i 'Goes back up to the for loop to the next barrel until it completes the entire duration.
If you want it to move it one at a time and have the next one move along with the others in sequence, start the Number_Of_Barrels = 1, and have your other timer
do Number_Of_Barrels = Number_Of_Barrels + 1 instead of i.
Re: i need help with my game
Re: i need help with my game
Out of curiosity, what game are you making? Donkey Kong? :ehh:
Re: i need help with my game
Re: i need help with my game
Hmmm interesting. But for the real thing, try playing my Nintendo Emulator I wrote in VB6 and download Donkey Kong like off of www.coolrom.com. You can find my emulator in my signature.