We help IT Professionals succeed at work.

Moving Multiple Pictureboxes, VB.NET

685 Views
Last Modified: 2012-05-08
I'm working on a small game in VB, and what I'd like to be able to do is move some pictureboxes around on the screen in random directions. I can get the latter to work, unfortunately I can only have it move 1 at a time in sequence.

I'd like to be able to move all 4(I'll start with 2 to make it easier) pictureboxes at once. I have some ideas, but the more pictureboxes I put on will make them seem less 'simultaneous'
Comment
Watch Question

Hi!

This does't directly answer you queston, but have you checked out XNA?
http://creators.xna.com/en-US/

It's a far better way to create games, and it's still easy. Lots of samples and a great community to help you out.

Making graphics in GDI/GDI+ is hard to make look nice.

// Johan
Melih SARICAMelih SARICA
CERTIFIED EXPERT

Commented:
create a thread for each picturebox...
It ll look like simultaneous.. If u ave more then one cpu or core then they ll be simultaneous

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
Sounds like you are using a LOOP to move the PictureBox.

Move to a Timer based approach where you update the position of all boxes in the Tick event.

If you show us your existing code then we can make suggestions on how to modify it.

Author

Commented:
XNA is not a solution, this *must* be done in a visual language such as VB or C# to start off with, maybe down the line though.

Timer sounds like it *might* work..

How do I start a thread in VB.NET?
Melih SARICA
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
If you're going the threading route then be sure to use a delegate w/ Invoke() to marhshal the calls from your created threads to the main UI thread where it is safe to move the PictureBoxes. If you have VB.Net 2005 (or above) then you can use the BackgroundControl worker to do the legwork for you.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.