Computer Science Canada Collisions with a platform |
Author: | Adaub7282 [ Sun Feb 15, 2009 1:42 pm ] | ||
Post subject: | Collisions with a platform | ||
Alright, the above code is an attempt at a simple program. All it is supposed to do is have a moveable ball, that can jump and land on a platform. The platform, however, is still not "solid" and the ball passes through. I have read through my code several times and can't find out what I have done wrong. Help would be much appreciated. On a side note, how do I make the screen move with the character? Example: Mario for the NES. |
Author: | Scott [ Sun Feb 15, 2009 9:14 pm ] | ||||
Post subject: | Re: Collisions with a platform | ||||
Your math is making the ball jump through the platform. See your ball is moving 2 at a time, that way it passes right through the 1 pixel you are checking for.. Instead of
try
That way it will stop if it passes through your 10 pixel thick platform, not just the 1 pixel thick surface. With this you are stopping and the ball will be half in the platform, try and make it so the ball stops when its edges hit to make up for the help we gave you. Good luck ![]() edit : better explanation. |
Author: | Adaub7282 [ Sun Feb 15, 2009 9:56 pm ] |
Post subject: | RE:Collisions with a platform |
Thank you, I wasn't sure if it would still pass throught the correct pixel, it would just spend 1/2 the time at that pixel then if gravity were set to 1. |