Thank you so much! I will try implementing a method like that, and post my results, when completed.
Did you get everything figured out there Radica1Faith?
The main problem for me with xerus's method is that I don't know how I would find the points on the ground.
I have a nice little code snippet for finding the edges of things and moving objects there which I can reproduce here. It may work with modification.
//Increment = distance to look at
increment_y = argument0;
if(unit_y > 0){
increment_y = -increment_y;
movedistance_y = increment_y;
}
if(unit_y < 0){
movedistance_y = increment_y;
}
if(place_free(x,y-increment_y)){
while(!place_free(x,y+movedistance_y+unit_y)){
movedistance_y += increment_y;
}
y += unit_y + movedistance_y;
movedistance_y = 0;
}
For those of you who want to use this for its intended purpose, unit_y is the distance you want to move. It's defined in a separate script in my engine.
Here's what I would do:
1. Create a code block which runs to find the points on each side (here is one):
//Increment = distance to look at
unit_y = sprite_height;
increment_y = argument0;
if(unit_y > 0){
increment_y = -increment_y;
movedistance_y = increment_y;
}
if(unit_y < 0){
movedistance_y = increment_y;
}
if(place_free(x,y-increment_y)){
while(!place_free(x,y+movedistance_y+unit_y)){
movedistance_y += increment_y;
}
//y += unit_y + movedistance_y;
point_on_ground1 = unit_y+move_distance
movedistance_y = 0;
}
2. Find the distance between them:
distance = sqrt((xleftside+xrightside)^2 + (point_on_ground1+point_on_ground2)^2);
3. Trig for the win.
cosign_of_angle = sprite_width/distance
sprite_angle = arccos(cosign_of_angle);
There's my $0.02.