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

How to do Diagonal Springs In Sonic Dash?


StealthyMC

Recommended Posts

I thought it was simple, but it's not. I'm trying to make diaganol springs. But the problem is, when Sonic hits the spring, he only goes up, not diagonally. I put the new constants in and added it into the spring collision script. Any suggestions?

I don't use Game Maker, but surely it'd be a case of telling it to change your XSpeed AND YSpeed at the same time?

Link to comment
Share on other sites

scrPlayerHandleObjectsSprings()

_RelativeSpringOrientation = (_ObjectHandle.SpringOrientation-round(global.GravityAngle/90)) mod 4;

An example:

_ObjectHandle.SpringOrientation = 1;
global.GravityAngle = 0;
_RelativeSpringOrientation = (1-round(0/90)) mod 4;
_RelativeSpringOrientation = (1-0) mod 4;
_RelativeSpringOrientation = 1 mod 4;
_RelativeSpringOrientation = 1;
consSpringOrientationLeft = 1;
_RelativeSpringOrientation = consSpringOrientationLeft;

EDIT: Assuming you did what I think you did...

_ObjectHandle.SpringOrientation = 4;
global.GravityAngle = 0;
_RelativeSpringOrientation = (4-round(0/90)) mod 4;
_RelativeSpringOrientation = (4-0) mod 4;
_RelativeSpringOrientation = 4 mod 4;
_RelativeSpringOrientation = [b]0[/b];
consSpringOrientationUp = 0;
[b]_RelativeSpringOrientation = consSpringOrientationUp;[/b]

To add more axis, you need a larger sample:

_RelativeSpringOrientation = (_ObjectHandle.SpringOrientation-round(global.GravityAngle/[b]45[/b])) mod [b]8[/b];

... Understand? :o

Link to comment
Share on other sites

scrPlayerHandleObjectsSprings()

_RelativeSpringOrientation = (_ObjectHandle.SpringOrientation-round(global.GravityAngle/90)) mod 4;

An example:

_ObjectHandle.SpringOrientation = 1;
global.GravityAngle = 0;
_RelativeSpringOrientation = (1-round(0/90)) mod 4;
_RelativeSpringOrientation = (1-0) mod 4;
_RelativeSpringOrientation = 1 mod 4;
_RelativeSpringOrientation = 1;
consSpringOrientationLeft = 1;
_RelativeSpringOrientation = consSpringOrientationLeft;

EDIT: Assuming you did what I think you did...

_ObjectHandle.SpringOrientation = 4;
global.GravityAngle = 0;
_RelativeSpringOrientation = (4-round(0/90)) mod 4;
_RelativeSpringOrientation = (4-0) mod 4;
_RelativeSpringOrientation = 4 mod 4;
_RelativeSpringOrientation = [b]0[/b];
consSpringOrientationUp = 0;
[b]_RelativeSpringOrientation = consSpringOrientationUp;[/b]

To add more axis, you need a larger sample:

_RelativeSpringOrientation = (_ObjectHandle.SpringOrientation-round(global.GravityAngle/[b]45[/b])) mod [b]8[/b];

... Understand? :o

I somewhat understood it, I'll try out your suggestion.

Link to comment
Share on other sites

My spring code looks like this:

// ==== FUNCTION ====================================================================

// scrPlayerHandleObjectSpringDRight()

// ==================================================================================

//

var _ObjectHandle;

// ---- Spring --------------------------------------------------------------------

_ObjectHandle = instance_nearest(x, y, objSpringDRight);

if(Action = consActionDead)

exit;

if( scrPlayerCollisionLeftObject(sprPlayerMask13, 1, _ObjectHandle) || scrPlayerCollisionBottomObject(sprPlayerMask15, 1, _ObjectHandle))

{

Action = consActionNormal;

FlagsAllowCommonInput = true;

Ground = false;

Gravity = _ObjectHandle.SpringPower*-1;

Speed = _ObjectHandle.SpringPower;

SpringVariable = true;

sound_play(sndSpring);

_ObjectHandle.image_speed = .2;

}

SpringPower is just a variable I'd set in the room editor instant creation code. So each spring could have its own speed.

Its in the old STT gmk if you want to have a look http://dl.dropbox.com/u/5170721/Old_Gmk.rar

Link to comment
Share on other sites

My spring code looks like this:

SpringPower is just a variable I'd set in the room editor instant creation code. So each spring could have its own speed.

Its in the old STT gmk if you want to have a look http://dl.dropbox.com/u/5170721/Old_Gmk.rar

Okay, thank you very much. This problem has been irratating me for the past couple of days.

EDIT: I tried out your suggestion, but it gives me an error saying "unknown variable: SpringPower". Before you ask, I did right click on the spring and put in the room creation code: SpringPower. It still gave me an error.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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