Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
if keyboard_check(ord('B'))
{
motion_add(image_angle, 10);
if speed > 10 speed = 10;
}
This way you will sprint at a speed of 10, but not exceed a speed of 10.
I always keep track of an objects max_speed, acceleration, braking, momentum loss, and whether or not its moving with a boolean variable.
So for example maybe something like...
To control and manage my speed every step I'd limit it from going over my maximum speed, limit it from going below zero, and if I'm not moving I'd subtract my momentum loss from it.
So...
If I was going to add sprinting to this I'd probably use a boolean variable to flag whether or not I'm sprinting and have a variable to keep track of how much faster I go while sprinting. I'd probably change my max_speed to be base_max_speed and then have a total_speed amount to factor everything off of.
So...
Then my speed management every step would probably look something like this...
There may be some errors or typos in that and I don't have the code where I check what keys are pressed to flag sprinting or moving as true or false nor checking if I'm pressing keys to accelerate or brake, but overall it should be functional, or close to it.
I haven't had a need to do sprinting or boosting of any kind in any of my projects so far, but the above is roughly how I'd approach it.
try this:
Keypress event: speed = speed + bonusX;
keyup event: speed = speed - bonusX;
Where bonusX = your run boost. Make bonusX a global variable and you can adjust the value using equipment/powerups/adjustable-piece-of-gear