# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### Dark GDK / Another 2D collision problem

Message
Posted: 10th Jul 2012 18:42 Edited at: 10th Jul 2012 18:45
Hi guys you probably know me by now as the 2D pain

I just started a simple pong project, i made some sprites for wall barriers and stuck them in, now the problem is i had to rotate them to make my game board look the way i wanted it (hexagon shape) when i put in collision testing the map looks fine but there is invisible walls that cause the ball to bounce even though i'm using sprite collision, anyways heres my code has anyone else had these issues?

www.pricklyproductions.co.uk
Posted: 27th Oct 2012 23:46
If I was you I would make a simple back and forth collision from each
screen x. So it would be like a bouncing ball back and forth.

After that you make it just bounce off the screen y back forth.

darkvee
Posted: 31st Oct 2012 03:54 Edited at: 31st Oct 2012 04:09
The problem you're having here is that even when you rotate an image resource, the outer bounding box remains a rectangle: It doesn't rotate WITH the sprite. To remedy this, you need to think back to Algebra 1: Linear Functions. Because your map deals with straight lines, you need to create (invisible) lines that can be checked to see if a particular point is above, below, or on that line. You should remember that a line's function is Y = aX+B, where A is the slope and B is the vertical translation. All you need to do is align the linear functions (do the math yourself, lazybones!) with the inside of your outer walls, and use a simple check equation to see if a point is above or below that line, such as:

Hope this helps!

It's been fun: So long, TGC!