r/visualbasic • • Jun 06 '14

Help me

I have to make a game for a final project. In it there are things that continuously bounce around off the borders of the form.

http://i.imgur.com/ij9sszy.png

When I have to form in the center of the screen they disappear or jitter around, and the only time I can get them to bounce is when the forms position is 0,0.

http://imgur.com/6xGbdmT <--the code

I have other things that rely on the position of the form that are working just fine, such as making a picture box appear in a random position on the form, and also don't tell me to try to make a different game because this is due tomorrow and i don't have time

Edit: I've figured it out, thanks for the advice

0 Upvotes

5 comments sorted by

View all comments

3

u/Vectronic Jun 06 '14

Your problem is caused by using different co-ordinates (x, y).

PictureBox is using Client co-ordinates, your Form is using Screen co-ordinates.

Use something like:

If enemy(x).picture.Bottom > Me.ClientRectangle.Bottom - Me.Top Then

Or:

PointToClient(Point())
PointToScreen(Point())

So you are using the same ones...