469,349 Members | 1,490 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,349 developers. It's quick & easy.

Picturebox Moving

Ok so far got the following:

picBall.Left = picBall.Left - 10
picBall.Top = picBall.Top - 5

If picBall.Left >= Me.Width Then

End If

The top two lines allow the picturebox to move but i now want the code for if the picturebox hits the side then goes another direction. The task is to make a breakout game. I have looked over the internet and all i can find is code from math nerds using x, y, z, a, b, c etc with numbers ranging form 1 to 99 so this is no good as i need to understand it. I have relevant knowledge but not game design.

Thanks
Nov 6 '08 #1
2 1270
smartchap
236 100+
You can make it like this:

Private Sub Command1_Click()
Picture1.Left = Picture1.Left - 10
If Picture1.Left + Picture1.Width < Me.Left Then
Picture1.Left = Me.Width
End If

End Sub

Similarly for Top also. Place the code in your program as per your need.
Nov 7 '08 #2
Hi there is a lot of ways to do what you wanna do.


I think the easy way is to compair to 0 (zero) for top, and left. These are the initial value for the left top corner.

I hope this help you

RPicilli
Nov 7 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Charles A. Lackman | last post: by
reply views Thread by Paul L | last post: by
8 posts views Thread by Yogiman | last post: by
1 post views Thread by Steven Garrad | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.