Computer Science Canada Collisions... |
Author: | slender0123 [ Mon Sep 09, 2013 6:00 pm ] | ||
Post subject: | Collisions... | ||
Hello there person who is possibly reading this.. I am farely new to turing, i can get a jumping process going and such, so im trying to make a platformer game, kinda like IWBTG (I Wanna Be The Guy) The only problem is, I couldnt do collisions for the life of me! I can somewhat get it, but its not good enough, I want it so that if a circle hits a line ( as so shown in the program below) It would stop moving down and it could jump on the line, ONLY on the line. if it where to go off the line, it would fall back to the begging. And that if it hits the bottom of the line, it just bounces off and goes back down, I think it would probibly be easier with a Draw.FillBox so i might try that, i just need some guidence in my collisions..
im currently using 4.1.1. |
Author: | Raknarg [ Mon Sep 09, 2013 6:42 pm ] |
Post subject: | RE:Collisions... |
You could do a bunch of complex math to solve it. The easy way is to use the built in function Math.DistancePointLine (xp, yp, x1, y1, x2, y2). You give the function an x and y coordinate for the point, and then the x and y coordinates of the line. This will give you the distance between the point and the line. We can use this. Lets say you have a circle that has a radius of 10 pixels. Every frame you could check the distance between the circle and the line. If the distance is equal to or less than 10, that means they have collided. |
Author: | slender0123 [ Mon Sep 09, 2013 7:47 pm ] | ||
Post subject: | Re: Collisions... | ||
Thats what i got so far, but i find the line detection is still a little off. it doesnt go the the far left of the line, it starts maybe a quarter into the line... |
Author: | Raknarg [ Mon Sep 09, 2013 7:49 pm ] |
Post subject: | RE:Collisions... |
Well the first thing you should do is reverse the x and y coordinates, it looks like you got them backwards |
Author: | slender0123 [ Mon Sep 09, 2013 7:52 pm ] |
Post subject: | RE:Collisions... |
OH! Lol!! Now i feel just silly Lol. thanks! ![]() |
Author: | Raknarg [ Mon Sep 09, 2013 7:53 pm ] |
Post subject: | RE:Collisions... |
aha simple mistakes ![]() |
Author: | slender0123 [ Mon Sep 09, 2013 8:01 pm ] |
Post subject: | RE:Collisions... |
True that! Now, to figure out how to get it so you can jump ON the line =p |
Author: | Raknarg [ Mon Sep 09, 2013 8:03 pm ] |
Post subject: | RE:Collisions... |
Well if you have a boolean that keeps track of whether he's in the air or not, then you could just set it to false if he collides with a line |
Author: | slender0123 [ Mon Sep 09, 2013 8:05 pm ] | ||
Post subject: | RE:Collisions... | ||
OR i could simply just...
![]() Lastly, under the line.. hmm |