|
-
Jan 17th, 2002, 07:30 AM
#1
Thread Starter
Addicted Member
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:
Public Sub BlockSub(Ball As Shape, brick As Shape)
If Ball.Top - Ball.Height = brick.Top And Ball.Top = brick.Top - brick.Height Then
YSpeed = -YSpeed
Ball.Top = Ball.Top + YSpeed
Paddle.Visible = False
End If
If Ball.Top = brick.Top + brick.Height Then
YSpeed = -YSpeed
Ball.Top = Ball.Top + YSpeed
Paddle.Visible = False
End If
'If Ball.Top + Ball.Height < Paddle.Top And Ball.Left >= Paddle.Left Then
' YSpeed = -YSpeed
' Ball.Top = Ball.Top + YSpeed
'Paddle.Visible = False
'End If
If Ball.Left + Ball.Width = brick.Left Then
XSpeed = -XSpeed
Ball.Left = Ball.Left + XSpeed
Paddle.Visible = False
End If
If Ball.Left = brick.Left + brick.Width Then
XSpeed = -XSpeed
Ball.Left = Ball.Left + XSpeed
Paddle.Visible = False
End If
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]
-
Jan 17th, 2002, 07:41 AM
#2
Dont use the "=" operator in your comparisons. The ball's values will almost never be equal to the edges of you box.
Z.
-
Jan 17th, 2002, 08:23 AM
#3
Good Ol' Platypus
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|