brakeout help

Started by
2 comments, last by mrshady1 15 years, 1 month ago
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
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.
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.
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

This topic is closed to new replies.

Advertisement