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

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -