how do I tell something to do something between variables,
like so:
if shpball is less than (variable) and greater than (variable) then.........
thanks.
Printable View
how do I tell something to do something between variables,
like so:
if shpball is less than (variable) and greater than (variable) then.........
thanks.
oh so you were looking for the code..
VB Code:
If (shpball.left < x2) and (shpball.left > x1) then End If
for some reason this aint working:
(membottomx1 and membottomx2 are the edges of the paddle, membottomx1 being the start of the paddle, membottomx2 being the end of the paddle)Code:'Bouncing ballz code
If (shpBall.Top <= 5000) And (shpBall.Left >= membottomx1) And (shpBall.Left <= membottomx2) Then
lblballhit.Caption = "Ball hit: " & Val(1)
End If
the ball is moving using this code:
Code:'Ball move code
shpBall.Top = shpBall.Top + memTopMove
shpBall.Left = shpBall.Left + memLeftMove
'If/Then statement for getting the ball moving once
If memSpeed = Val(0) Then
memSpeed = Val(50)
memTopMove = Val(0) - Val(memSpeed)
memLeftMove = Val(0) - Val(50)
End If
'By default it will move the ball up at 50 speed.
'memSpeed = Val(50)
'memTopMove = Val(0) - Val(memSpeed)
'If/Then for if the ball goes out of bounds.
'Top/Bottom only.
If shpBall.Top < 120 Then
memTopMove = 0
memTopMove = Val(memTopMove) + Val(memSpeed)
End If
If shpBall.Top >= 5280 Then
memTopMove = 0
memTopMove = Val(memTopMove) - Val(memSpeed)
End If
'Left/Right ball out of bounds.
If shpBall.Left > 9120 Then
memLeftMove = 0
memLeftMove = Val(memLeftMove) - Val(memSpeed)
End If
If shpBall.Left < -120 Then
memLeftMove = 0
memLeftMove = Val(memLeftMove) + Val(memSpeed)
End If
it seems to me as if you are not moving the ball at all..
it needs to be moved go like this
ball.y = ball.y + yspeed
ball.x = ball.x + xspeed
now if the ball its the right or left wall go like
xspeed = -xspeed
and if it hits the paddle
yspeed = -yspeed
and you don't need all those val things...