PDA

Click to See Complete Forum and Search --> : 1-Twip vs. 3-Pixel HELP!


Dude1
Aug 12th, 2002, 03:48 PM
Sub DoBall()

Speed = 5
xFlag = 1
yFlag = 1

If xFlag = 1 Then
Ball.X = Ball.X + Speed
Else
Ball.X = Ball.X - Speed
End If

If yFlag = 1 Then
Ball.Y = Ball.Y + Speed
Else
Ball.Y = Ball.Y - Speed
End If

If Ball.X >= Form1.width Then
xFlag = 0
End If

If Ball.X <= 100 Then
xFlag = 1
End If

If Ball.Y >= Form1.height Then
yFlag = 0
End If

If Ball.Y <= 100 Then
yFlag = 1
End If

End Sub

The above code works when Form property is set to 1-Twip, but when I change it to 3-Pixel the code no longer works. The ball flies of the form. Why? Please help!

Thanks

jim mcnamara
Aug 12th, 2002, 04:13 PM
The number of pixels is the resolution like 768 X 1024.

Twips are fixed at 1440 per inch. As you change resolution you get a different number of twips per pixel. Pixels are always much bigger than twips. So if you move your ball 150 twips - it isn't far, but 150 pixels can be 1/6 of the entire screen width, nearly as big as a form.

Dude1
Aug 12th, 2002, 04:46 PM
Oh ok. Thanks for clearing that up for me. Yeh, I just change all my numbers to much lower numbers and everything works!