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.

Newcomers DBPro Corner / breakout x and y colllision

Author
Message
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 8th Oct 2009 02:21 Edited at: 12th Oct 2009 18:56
I just have a question about how to implement collision on the bricks in the game breakout. I have come up with a system for the Y axis but everytime I try something for the X asist the ball just goes inside the brick and comes out on the other side. Does anyone have a way to do this, i saw on the community procject of breakout that they used gradients but it just confused me.



Thats the community project code but I have no idea how to change that so it applies my project at least the gradient part. Got it, i just had to wrap my head around what they ment by gradients. updated code to make more sense.

Thanks, Stefan
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 9th Oct 2009 02:24
Bump =>

Thanks, Stefan
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 9th Oct 2009 21:34
I recently made a breakout game and what I did was used this:

So i created the sprites using the same method and then ran that code in the loop. I think its pretty much self explanatory.

TheCleverGuyz
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 12th Oct 2009 18:54
Yea That works put, I wanted X plus Y collision which is what the first post gives you.

Thanks, Stefan
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 13th Oct 2009 15:05
I don't get what you mean? Are you making a non-sprite game?

TheCleverGuyz
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 14th Oct 2009 15:00
That means the ball if it hits the right or left side of a brick bouces the oppiste way.

Thanks, Stefan
Gingerkid Jack
19
Years of Service
User Offline
Joined: 15th May 2005
Location: UK
Posted: 16th Oct 2009 10:03
Then turn the movement speed of the ball to negative or positive depending on the side hit?

For Example:

The ABS command changes the number to positive.
To change it to negative do: Speed# = Speed# - (Speed#*2)

TheCleverGuyz
Stefan p
16
Years of Service
User Offline
Joined: 2nd Nov 2008
Location: Online
Posted: 17th Oct 2009 18:33
You can change a number to flip between postive and negative by using *-1

Thanks, Stefan

Login to post a reply

Server time is: 2024-11-25 01:27:39
Your offset time is: 2024-11-25 01:27:39