Platform: is accelerating/decelerating event?

Get help using Construct 2

Post » Thu Oct 31, 2013 9:06 pm

What would be the best way to monitor if a player is accelerating or decelerating? Basically, something equivalent to the "is jumping/is falling" events but horizontally (for walking & running)?

I know there is the "compare speed" Platform event. Would I just set that to run globally every tick and compare to the last tick? Seems like that would work but probably not be the most processing-efficient way to do it.

Thanks in advance for any help.
B
5
Posts: 20
Reputation: 1,015

Post » Thu Oct 31, 2013 10:03 pm

Well, if no physics are used, you could basically monitor if keys are not held down + if the player is not jumping/falling (if you care about vertical speed too) - if both are true, then the player is not accelerating. Without external factors that affect the speed, this would be accurate until the moment when the player reaches the maximum speed (e.g. moving at the maximum velocity, which is constant), perhaps adding a "is speed < maximum speed" check could prevent this.

However, these checks probably would be less efficient than just updating a single variable (e.g. "PreviousTickSpeed").

Then again, none of this should be too important, as drawing processes usually take up most of the CPU / GPU resources (usage commonly said to be around ~90%).Stiivais2013-10-31 22:04:42
B
10
S
1
Posts: 163
Reputation: 1,436

Post » Tue Nov 05, 2013 5:02 pm

(sorry for the "test"; I'm having login issues that erase my posts!)

Thanks for the quick reply and sorry for the slow one on my end. Your suggestion worked perfectly. I have an IsAccelerating and IsDecelerating variable that are set by a PreviousTickSpeed variable and it all works :)

Also, that's great to hear that drawing is 90% of the resources. I've made a lot of game-spec art so I'm not worried about that but I don't know much about optimizing routines and such. Good to know it's more forgiving.switchblade3272013-11-05 17:05:35
B
5
Posts: 20
Reputation: 1,015


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 3 guests