drawing - Ball to brick collision in c# -


i writing program has ball moving around picturebox , have set of bricks @ top of picturebox.

i have used array location of bricks using:

int[,] bricklocation = { { 0, 0 }, { 30, 0 } } 

i have used drawrectangle construct each brick within picturebox. exist within timer1_tick event. ball drawn, picturebox cleared , x , y coordinate change.

when ball "collides" brick, want way in brick disappear because there brick behind it.

[brick0]

[brick1]

at moment, code collision between ball , brick1 is:

if ((yball > bricky) && (yball < bricky + 25) && (xball > brickx) && (xball < brickx + 80))             {                 yballchange = -yballchange;             } 

where xball, yball x , y coordinate of ball , brickx , bricky coordinate bricks.

so when ball coordinates within bounds of brick1 y-direction change.

is there way in can redraw [brick1] in new position no size eliminate there can collision between ball , [brick0]? or there else do?


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -