J
Jeshuakrc
Guest
I was looking for a way to make a "perfect" platform collisions code. I found this in this comunity:
And it worked realy well, but I didn't have got in touch with trigonometry since secundary, so I searched in Google and freshened my memory, but I don't understand the math in the code. Why convert the degrees to radians? Why x+xdir / y+ydir? I realy can't get that code.
Code:
dist=point_distance(x,y,xprevious,yprevious);
dir=degtorad(point_direction(xprevious,yprevious,x,y));
xdir=cos(dir);
ydir=-sin(dir);
x=xprevious;
y=yprevious;
repeat dist{
if place_meeting(x+xdir,y,all){
hsp=0;
}else{
x+=xdir;
}
if place_meeting(x,y+ydir,all){
fall=0;
}else{
y+=ydir;
}
}