Results 1 to 4 of 4

Thread: defining between.

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2002
    Posts
    57

    defining between.

    how do I tell something to do something between variables,

    like so:

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

    thanks.
    Maxtech Computing
    Maxtech Computing Forums

    Now try this on your school network kids!
    Code:
    Call Shell("net send * hey goto www.maxtechcomputer.net !", vbHide)

  2. #2
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    oh so you were looking for the code..
    VB Code:
    1. If (shpball.left < x2) and (shpball.left > x1) then
    2. End If
    Sanity is a full time job

    Puh das war harter Stoff!

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2002
    Posts
    57
    for some reason this aint working:

    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
    (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:

    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
    Maxtech Computing
    Maxtech Computing Forums

    Now try this on your school network kids!
    Code:
    Call Shell("net send * hey goto www.maxtechcomputer.net !", vbHide)

  4. #4
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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...
    Sanity is a full time job

    Puh das war harter Stoff!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width