• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Object slide on ice in x and y

N

Nikolai4

Guest
Hello! Newbie here. Top down game, object can move in X and Y, 360°
"Step" is motion_set(image_angle+90, 1);
and
"key down" is image_angle+=3;

So it always move forward and turn left when key press.

I need to make object slide like on ice little forward of it previous direction while key down, but continue to rotate. Any ideas? I am confused, dont know where to look.
 

Zaxtor99

Member
Set a variable for your object to set your ice slipping motion..
something like:

ice_movement = speed / 3; < this needs to be in your step event and make sure you slowly reduce your speed in your step event as long as you aren't holding W or whatever key you use to thrust or give your object "gas"

Add your ice_movement variable to whatever direction you face.

For your turning on ice, you'll again need a variable that you can slowly reduce over time..
You'll have to play with the numbers but maybe something like this:

ice_turn = 3 <--- set this at the same time you press your key to turn
turned = true <--- also set this variable when you press your key to turn so you can use it in your step sliding code (seen below)

once you've started a turn, slowly add the ice_turn to your image_angle but slowly reduce it even if no key is pressed

so in your step event, you use something like this:

if turned = true
{
image_angle + ice_turn
ice_turn -= .1;
if ice_turn <= 0
{
ice_turn = 0;
turned = false;
}
}

That's the basic idea, I hope it helps. You'll likely have to play with the values as I just made stuff up to give you a basic idea of one way to make a sliding feel.
 
N

Nikolai4

Guest
Thanks for help, but still no luck. What I did at the moment
ice_movement = speed / 3; does not make anything, so I changed it for -0.01;

Step event

Code:
direction=image_angle+90;
ice_movement = -0.01;

if turned=true{
speed += ice_movement;
image_angle+=ice_turn;
}
else{
    speed=1;
}
if speed <=0{
speed=0;
}
if ice_movement <= 0
{
ice_movement = 0;
turned = false;
}
Key down event

Code:
turned=true;
ice_turn=3;

I little changed your code, because I don't need to stop rotate object while key is pressed. But just because image_angle makes new direction every moment, my object turning to stop by spiral. I need to get an old direction to move object straight while it rotate around its axis.

Add your ice_movement variable to whatever direction you face.
How can I add speed variable to direction? Or what did you mean?
 
Top