Jump to content
  • Advertisement
Sign in to follow this  
mrshady1

brakeout help

This topic is 3473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi im using vb.net and need a little advice about removing the bricks from the array once a collition has occurd... i have the ball bouncing off the brick but cant figure how to make the block disapear i think i have to have a for loop to go throgh the array and check for the collition, then - 1 and redim preserving the array but cant seem to get the syntax right... im not at home so unable to post code at the moment will do when i get back but if theres any advice would be cool to see any sergestions thx in advance j

Share this post


Link to post
Share on other sites
Advertisement
First, some vocabulary. brakeout = breakout, collition = collision, occurd = occurred, throgh = through, sergestions = suggestions

Now, you didn't mention how your game is build, we know you use vb.net but not the gfx api used (not really important in this case). More important, how are your bricks defined. You have an array of (booleans?) saying if the brick is present or not? How do you place them? My suggestion would be to create a class brick with property like x,y,size,color,bonus,etc and then use a list or vector of bricks to keep track of them in your main game. You can easily delete something from a list or vector without having to redimension an array yourself.

Share this post


Link to post
Share on other sites
Simplest way I can think of is to have an isVisible boolean member variable in your Brick class (assuming you have a Brick class). Then, when you detect a collision between the ball and a brick, set isVisible to false. Then you just need to include a check to the isVisible variable of every brick before you render it.

Share this post


Link to post
Share on other sites
why is it the first thing people go on at me for on all these forums is my spelling.... u might wanna check your english m8 b4 u make statements like that (is buid) lol think you mean built :) but we all take it on the chin.... but thankyou for the spelling lesson.. this is what i have done

"

Dim row1(14) As Sprite
Dim i As Integer


For i = 0 To row1.Length - 1
row1(i) = Graphics.CreateSprite(GameImage("pBrick"))
row1(i).X = (i * 50) + 45
row1(i).Y = 50
Next i


'check collision between the ball and the brick and remove the brick and reverse movment of the ball
For i = 0 To row1.Length - 1

If Physics.HaveSpritesCollided(ball, row1(i)) Then
performCollision(ball, row1(i))
Audio.PlaySoundEffect(GameSound("paddleHit"))

End If


Next i

'draws the bricks to the screen
For i = 0 To row1.Length - 1
Graphics.DrawSprite(row1(i))

Next i


it's the swingame sdk im using and yes iv asked on there forums but no luck :( so i am not expecting much.

thankyou anyway

j

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!