Game programming...multiple timers

Javawag

New member
Joined
Dec 16, 2005
Messages
2
Programming Experience
1-3
Hiya!!

I'm quite new to VB.NET and to prove to my friend that I can use it, I am trying to go against what he said about not making games with it! Anyways, getting to the point, it's a simple breakout game using PictureBoxes for the bat and the ball, which I have programmed correctly, and a button for a brick to hit. This is where the problem lies! I have a button for the brick, and a timer which checks periodically for collisions between the ball and the brick. This works fine, but I want to add more bricks (as abviously a breakout game with one brick is kinda lame).. but this would mean adding a new timer for every brick etc, etc... is there any way around this?? My friend said uttered something about object parents and I know how they work in GML (a programming language I am actually good at), but I didn't think VB.NET had an equivalent other than containers like the tab containers etc...

Anywho sorry about the whole essay I've got going on up there and hopefully I posted this in the right place in the forum!! Please reply if you have any suggestions which don't involve flaming me or making a new timer for each brick :p

-Javawag
 
Just to clarify

My button object is currently doing nothing in the way of events, it is only the timer which does things with it... is there a way for this timer to, instead of addressing the "brick" object, address every button on the form and perform the same events?
 
Buttons are for clicking. I'd suggest that you don't use Buttons in this situation. I would think that you could just use Labels with the BackgroundColor set, or PictureBoxes that contain a brick image. I would also think that you would want to act on a collision when it occurred, not the next time a Timer Ticked. You could have a multidemensional array containing your bricks and then Handle the LocationChanged event of the PictureBox that represents the ball. If its Y coordinate is such that it has reached a row of bricks the check the bricks in that row to see if the X coordinates of any match the location of the ball. If they do then hide that brick and bounce the ball back. If not, let the ball keep going until it reaches the next row of bricks.

This is all pretty simplistic. Here are a couple of links that might give you some good info on proper game programming with VB.NET:

http://msdn.microsoft.com/coding4fun/gamedevelopment/beginning/default.aspx
http://vbprogramming.8k.com/tutorials/main.htm
 
Back
Top