Results 1 to 3 of 3

Thread: Breakout Brick / Block Help Needed!

  1. #1

    Thread Starter
    Addicted Member ][KMX]['s Avatar
    Join Date
    Sep 2001
    Location
    20,000 Leagues under the sea
    Posts
    150

    Unhappy Breakout Brick / Block Help Needed!

    Alright, I'm trying to make a Breakout game, I have the ball moving and such, but I'm not sure of how to check if the ball has touched the brick, and if so, bounce it again and make that brick invisible.

    Get it? Got it? Good.

    now, I have this....

    VB Code:
    1. Public Sub BlockSub(Ball As Shape, brick As Shape)
    2.  
    3. If Ball.Top - Ball.Height = brick.Top And Ball.Top = brick.Top - brick.Height Then
    4.     YSpeed = -YSpeed
    5.     Ball.Top = Ball.Top + YSpeed
    6.     Paddle.Visible = False
    7. End If
    8.  
    9. If Ball.Top = brick.Top + brick.Height Then
    10.     YSpeed = -YSpeed
    11.     Ball.Top = Ball.Top + YSpeed
    12.     Paddle.Visible = False
    13. End If
    14.  
    15. 'If Ball.Top + Ball.Height < Paddle.Top And Ball.Left >= Paddle.Left Then
    16. '    YSpeed = -YSpeed
    17. '    Ball.Top = Ball.Top + YSpeed
    18. 'Paddle.Visible = False
    19. 'End If
    20.  
    21. If Ball.Left + Ball.Width = brick.Left Then
    22.     XSpeed = -XSpeed
    23.     Ball.Left = Ball.Left + XSpeed
    24.     Paddle.Visible = False
    25. End If
    26.  
    27. If Ball.Left = brick.Left + brick.Width Then
    28.     XSpeed = -XSpeed
    29.     Ball.Left = Ball.Left + XSpeed
    30.     Paddle.Visible = False
    31. End If
    32.  
    33. End Sub

    Any suggestions?
    My Philosophy on VB Programming: "If you think you can do it, you can. "

    So Says the words of Me, the all powerful. I like mooses, they are fun.

    Bad Command or File Name, Go Stand In The Corner.

    [vbcode]
    'Don't try this at home kids...
    Kill C:\Windows
    [/vbcode]

  2. #2
    Zaei
    Guest
    Dont use the "=" operator in your comparisons. The ball's values will almost never be equal to the edges of you box.

    Z.

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Instead, you should use a =< for the top and left edges, and >= for the bottom and right edges.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

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