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.

Code Snippets / bouncing a ball off a brick the easy way!!

Author
Message
Raver
20
Years of Service
User Offline
Joined: 7th Dec 2003
Location: leeds
Posted: 13th Aug 2004 22:15
Hello again,I was coding my arknoid clone when i ran into the problem of how to correctly bounce the ball off a brick,depending on where it hits the brick,getting no answers from here! I worked out a simple way to do this!
What I did was place 4 sprites,just single pixels, on the top bottom left and right of the ball!Make them always equal to the balls position except offset a value to position them to the sides and above and below!Then hide these sprites and do the collisions with them instead of the main ball,changing the balls direction depending on which hit what!!
Dont worry,when I have finished I will release everything,including a tutorial on the editor and all!
If you look at the code you will see what i mean, the level is built from my level editor in case your wondering where the bricks are at!!
I am hoping to release the full source to my editor and game when i have finished!If you want the media files to this then email me and i will send em!

djwheeler
Ocean Runner
21
Years of Service
User Offline
Joined: 18th May 2003
Location: United States
Posted: 20th Aug 2004 01:59
I used the exact same thing, except in 3D with my Jezzball Clone.

"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949
http://drgames.dbspot.com

Login to post a reply

Server time is: 2024-11-23 19:43:55
Your offset time is: 2024-11-23 19:43:55