Page 1 of 2

Ecceleration Problem ...?

PostPosted: Tue Dec 17, 2013 1:13 pm
by Turon
I am trying to make my character :arrow:accelerate twice it's normal speed :arrow: and stop when it reached it's limit speed. I have no idea on how to do this for me it's new territory!

Re: Ecceleration Problem

PostPosted: Wed Dec 18, 2013 4:35 am
by barney12345
what do u mean by his limit, distance or speed

Re: Ecceleration Problem

PostPosted: Wed Dec 18, 2013 12:06 pm
by Turon
Sorry I may have not been clear about that I meant the limit of the speed.

Re: Ecceleration Problem

PostPosted: Wed Dec 18, 2013 9:17 pm
by skydereign
You could use a variable to hold what speed the player should be moving at, and use min/max to limit it. Here's a very simple example of it.
player -> Key Down Right (repeat) -> Script Editor
Code: Select all
velocity = min(velocity+0.5, 8); // this limits velocity to 8

player -> Draw Actor -> Script Editor
Code: Select all
x+=velocity;

Re: Ecceleration Problem

PostPosted: Thu Dec 19, 2013 12:12 am
by Turon
Is this right? I agusted some of the numbers and stuff, and I had to make "velocity" a variable.
and if I follow this code exact does it make the player go back to the lowest speed after releasing the left or right key?
Key Down -> Right (repeat yes) -> Script Editor
Code: Select all
ChangeAnimation("Event Actor", "MaxWalkRight", NO_CHANGE);
velocity = min(velocity+0.90, 8); // this limits velocity to 8
x+=2;

another thing I was wondering about is how can I change animation once the player reaches max speed?

Re: Ecceleration Problem (I have NOT fixed the problem YET)

PostPosted: Wed Dec 25, 2013 8:24 pm
by Turon
I'm thinking.... wat if I cud make the running and non running sprite share the same sprite sheet only alow the running to repeat until the key is released!

Re: Ecceleration Problem (I have NOT fixed the problem YET)

PostPosted: Thu Dec 26, 2013 5:41 am
by skydereign
Turon wrote:Is this right? I agusted some of the numbers and stuff, and I had to make "velocity" a variable.

You seem to still be moving the player with x+= in that code. That could work, as long as you have the draw actor event deal with acceleration as well. I really recommend though removing the x+=2 and just deal with the velocity variable.
Turon wrote:if I follow this code exact does it make the player go back to the lowest speed after releasing the left or right key?

You just set velocity to whatever value the lowest speed is.
Turon wrote:another thing I was wondering about is how can I change animation once the player reaches max speed?

You use an if statement. You have the velocity variable, so just change the animation when you reach the top speed if(velocity>=8).
Turon wrote:wat if I cud make the running and non running sprite share the same sprite sheet only alow the running to repeat until the key is released!

You could do that but I wouldn't recommend it.

Re: Ecceleration Problem (I have NOT fixed the problem YET)

PostPosted: Thu Dec 26, 2013 12:18 pm
by Turon
K um luk at this code
Code: Select all
ChangeAnimation("Event Actor", "MaxWalkLeft", NO_CHANGE);
velocity = min(velocity-0.90, 8); // this limits velocity to 8
if(velocity>=8)ChangeAnimation("Event Actor", "MaxRunLeft", NO_CHANGE);

i have removed the *x-=* thing but now he does not move

and isnt this the code that sets the minimim speed?
Code: Select all
velocity = min(velocity-0.90, 8); // this limits velocity to 8

Re: Ecceleration Problem (I have NOT fixed the problem YET)

PostPosted: Thu Dec 26, 2013 10:24 pm
by skydereign
Turon wrote:K um luk at this code
Code: Select all
ChangeAnimation("Event Actor", "MaxWalkLeft", NO_CHANGE);
velocity = min(velocity-0.90, 8); // this limits velocity to 8
if(velocity>=8)ChangeAnimation("Event Actor", "MaxRunLeft", NO_CHANGE);

i have removed the *x-=* thing but now he does not move

Right. You need to add a line of code in the actor's draw actor event that moves the player based off of the velocity variable.
skydereign wrote:player -> Draw Actor -> Script Editor
Code: Select all
x+=velocity;


Turon wrote:and isnt this the code that sets the minimim speed?
Code: Select all
velocity = min(velocity-0.90, 8); // this limits velocity to 8

The code for setting the minimum is slightly different as it needs to use max instead of min.
Code: Select all
velocity = max(velocity-0.9, -8);

Re: Ecceleration Problem (I have NOT fixed the problem YET)

PostPosted: Sat Dec 28, 2013 1:23 pm
by Turon
Turon wrote:i have removed the *x-=* thing but now he does not move

skydereign wrote:Right. You need to add a line of code in the actor's draw actor event that moves the player based off of the velocity variable.
player -> Draw Actor -> Script Editor
Code: Select all
x+=velocity;

Hmmm So I need to figure out a code based on *x+=velocity;*?
Here my try the movements are a little rough though.
Code: Select all
x+=velocity=2;

Re: Ecceleration Problem (Hmm....?:/)

PostPosted: Sat Dec 28, 2013 9:05 pm
by Turon
Hmm... Sky what do u think will be the more easily implemented acceleration system?
(A) the one that u hold the arrow key down to accelerate
(B) or the one where the faster you tap an arrow key the more the player accelerates

hmmm...........

Re: Ecceleration Problem (Hmm....?:/)

PostPosted: Sat Dec 28, 2013 9:22 pm
by DarkParadox
Both would be about the same difficulty to code (Holding it down might be a bit easier), but I would recommend a system where you hold down the key to accelerate because hitting the key over and over again wouldn't be very fun.

Re: Ecceleration Problem (Hmm....?:/)

PostPosted: Sun Dec 29, 2013 10:35 am
by Turon
Well the 1984 arcade game Pac-Land uses a similar acceleration system to acceleration (b) and it's still epic!

Re: Ecceleration Problem (Hmm....?:/)

PostPosted: Mon Dec 30, 2013 12:13 pm
by Turon
Well it's probable best to fix the current situation first shall we resume?

Re: Ecceleration Problem ...?........?

PostPosted: Thu Jan 02, 2014 9:34 pm
by Turon
I'm puzzled, i suppose you guys are puzzled too? Kei i've got my ged here if you'd like to scrutinize it.