PDA

Click to See Complete Forum and Search --> : defining between.


Interesting
Jun 1st, 2002, 04:49 PM
how do I tell something to do something between variables,

like so:

if shpball is less than (variable) and greater than (variable) then.........

thanks.

/\/\isanThr0p
Jun 1st, 2002, 04:56 PM
oh so you were looking for the code..

If (shpball.left < x2) and (shpball.left > x1) then
End If

Interesting
Jun 1st, 2002, 05:51 PM
for some reason this aint working:


'Bouncing ballz code
If (shpBall.Top <= 5000) And (shpBall.Left >= membottomx1) And (shpBall.Left <= membottomx2) Then
lblballhit.Caption = "Ball hit: " & Val(1)
End If

(membottomx1 and membottomx2 are the edges of the paddle, membottomx1 being the start of the paddle, membottomx2 being the end of the paddle)

the ball is moving using this 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

/\/\isanThr0p
Jun 1st, 2002, 06:11 PM
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...