Ecceleration Problem ...?

Non-platform specific questions.

Ecceleration Problem ...?

Postby Turon » Tue Dec 17, 2013 1:13 pm

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!
Attachments
Max.zip
(29.13 KiB) Downloaded 174 times
Last edited by Turon on Sat Jan 04, 2014 11:04 pm, edited 13 times in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Ecceleration Problem

Postby barney12345 » Wed Dec 18, 2013 4:35 am

what do u mean by his limit, distance or speed
Darth Vader called... he wants his cookies back
User avatar
barney12345
 
Posts: 122
Joined: Wed Nov 07, 2012 6:52 am
Location: A land down under
Score: 4 Give a positive score

Re: Ecceleration Problem

Postby Turon » Wed Dec 18, 2013 12:06 pm

Sorry I may have not been clear about that I meant the limit of the speed.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Ecceleration Problem

Postby skydereign » Wed Dec 18, 2013 9:17 pm

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Ecceleration Problem

Postby Turon » Thu Dec 19, 2013 12:12 am

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?
Last edited by Turon on Thu Dec 26, 2013 8:12 am, edited 1 time in total.
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby Turon » Wed Dec 25, 2013 8:24 pm

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!
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby skydereign » Thu Dec 26, 2013 5:41 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby Turon » Thu Dec 26, 2013 12:18 pm

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
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby skydereign » Thu Dec 26, 2013 10:24 pm

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);
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

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

Postby Turon » Sat Dec 28, 2013 1:23 pm

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;
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby Turon » Sat Dec 28, 2013 9:05 pm

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...........
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby DarkParadox » Sat Dec 28, 2013 9:22 pm

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.
User avatar
DarkParadox
 
Posts: 457
Joined: Mon Jan 08, 2007 11:32 pm
Location: USA, Florida.
Score: 84 Give a positive score

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

Postby Turon » Sun Dec 29, 2013 10:35 am

Well the 1984 arcade game Pac-Land uses a similar acceleration system to acceleration (b) and it's still epic!
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby Turon » Mon Dec 30, 2013 12:13 pm

Well it's probable best to fix the current situation first shall we resume?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

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

Postby Turon » Thu Jan 02, 2014 9:34 pm

I'm puzzled, i suppose you guys are puzzled too? Kei i've got my ged here if you'd like to scrutinize it.
Attachments
Acceleration Problem.zip
everything we went over is recorded in this ged
(6.53 KiB) Downloaded 165 times
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest