Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

[GM7P] Restoring angles


Recommended Posts

Yeah.. Might be one hell of a newb question, but I've just started on a lil' project (One which I'll work on my spare time, really, as most others.), who's engine is based off Damizean's 360° one from the GM tutorial page on SFGHQ.

Right now, there's not a lot of things to tweak with the engine now, except for one thing.

return round( point_direction(x1,y1,x2,y2));

See that? Yeah.. We'll get to that soon enough.

My 'game' uses 16x16 tiles and the game is slightly picky about it, but I'm fixing the issues as I go. Here's the deal..

When going just to the edge of a tile, the character's sprite tilts - normally, since it would do the same while being on a slope. However, the result is.. Once stepping off said edge and onto flat terrain, the sprite's angle still remains and doesn't reset to normal. That's what I'm trying achieve. I know I can apparently do something with the above mentioned piece of code to reset the angle, however, it also messes up slope detection, so I can't use it in any way that I can conjure up from my mind.

As hinted at the thread, it's being made in Game Maker 7 (Pro), since I wholesomely prefer coding over the system that MMF2/TGF2 and it's older versions use.

Any ideas?

In a nutshell:

Player goes to the edge, his angle modifies. He steps off edge onto flat terrain, his angle doesn't change back to normal, jumping does. Help?

Link to comment
Share on other sites

Can you include the conditions that prompt the angle return command, as well as the jump code?

Without that info...hmm. Perhaps you have it so the return angle command is only issued when the ground isn't flat; so it doesn't fix itself once you're on level surfaces again?

Link to comment
Share on other sites

angle=round(argument0/8)*8;
hspace=argument1;
check=argument2;

dcos=cos(degtorad(angle));
dsin=sin(degtorad(angle));

x1=round(x-( dcos * hspace ));
y1=round(y+( dsin * hspace ));

x2=round(x+( dcos * hspace ));
y2=round(y-( dsin * hspace ));

done1=0;
done2=0;

i=2.35;


while(i) {
    if (!done1) {
        if ((check&obstacle_layer) && collision_point(x1,y1,obj_walls,true,true)>0) done1=1;
        if (layer==0 && (check&high_layer) && collision_point(x1,y1,obj_hlayer,true,true)>0) done1=1;
        if (layer==1 && (check&low_layer) && collision_point(x1,y1,obj_llayer,true,true)>0) done1=1;
        x1+=dsin;
        y1+=dcos;
    }
    if (!done2) {
        if ((check&obstacle_layer) && collision_point(x2,y2,obj_walls,true,true)>0) done2=1;
        if (layer==0 && (check&high_layer) && collision_point(x2,y2,obj_hlayer,true,true)>0) done2=1;
        if (layer==1 && (check&low_layer) && collision_point(x2,y2,obj_llayer,true,true)>0) done2=1;
        x2+=dsin;
        y2+=dcos;
    }
    if (done1 && done2) break;
    i-=1;
}

return round( point_direction(x1,y1,x2,y2));

   //Jump!
   if (KEY_A && ground)
   {
     ground=0;
     vsp=dcos*jmp-dsin*hsp;
     hsp=dcos*hsp+dsin*jmp;
     angle=0;
     dcos=1;
     dsin=0;
     action=1;
   }

Here is all of it.

Link to comment
Share on other sites

Yeah, I was just throwing that out.

Could you do me a favor and put a textbox or something that prints out the values of round, angle, x1-2, and y1-2? Tell me what happens to them when Sonic's tilted correctly versus what they say when he's tilted on flat ground?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...