Skip to main content
GameDev.net gamedev.net
🔒 Locked

VB question

Started by Gamerman25 Sep 21, 2000 at 8:25 PM 3 replies 200+ views
Original Post
Gamerman25
Gamerman25
I am trying to make a Visual Basic pong game. How do I stop the paddle from going off the screen when the player moves it.
Bad pizza good Andy
nes8bit
nes8bit
Depends on how you do it. If you''re using controls, you do this.

Assuming that the controls are in a picture box:

If Paddle.Left < 0 then Paddle.Left = 0
If Paddle.Left > PictureBox.ScaleWidth - Paddle.Width then Paddle.Left = PictureBox.ScaleWidth - Paddle.Width

---------------------------
"Don't die for your country, make some other dumb bastard die for his" -General George S. Patton
Quantum
Quantum
this is what i used for my formula:

if the top of the paddle is <= top of screen, top of paddle = top of screen
if the bottom of the paddle + paddle width >= bottom of screen, top of paddle = bottom of screen - paddle width
Gamerman25
Gamerman25
Thanks, also I''m using the shape control in the tool box for the paddles and stuff, would it be better to use bitmaps?
Bad pizza good Andy
vbisme
vbisme
depends on what better is, do you want a good looking paddle?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.