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
create event
This works well for acceleration but how could I have it decelerate, so that when the key is released the character slowly stops moving, or do I need to use physics for that?
friction=1; // how many pixels per step to make hspeed/vspeed come to zero
EDIT:
check if hdir==0 if so set friction to positive value, else set friction to zero
friction = 1; into the create block and step block but neither added any decceleration :/
Thanks for your help though I appreciate it :)
It's just part of being a programmer. Learning the code is the easy part, learning how to put code together so the computer does exactly what you want it to when you want it to do it? Well my friend, that is a life time job LOL.
Sometimes older code can conflict with things making it hard to understand what goes wrong. Learning to use the debugger can help a lot. Especially with the function
I also sometimes type in wrong bits of code which are ment for different programming languages, which confuses me even more xD
But hey I'll get there soon.
Thanks again for your help and support :D
try changing the accl value to something smaller than 1
and then try changing the friction value where we say -> friction=1 <- in the step event? to a value smaller than the value you have accl.
example
Thank you for helping me out, it was really kind of you.
I see what you mean by the values being too large, though I don't understand how the median function works :P (well I know what a median is but I don't know why it is used). So I think I'm going to mess with it for a while to get used to what it can be used for.
I won't forget you helping me like this dude ty alot ;u;
the function itself returns the value that is in the middle of all the values you give it
so let's say spd=5
that means -spd would be -5
let's say hspd = 2
if we check for the median value of all three of those
value=median(spd,-spd,hspd)
then it would return the value that it is in the middle or in between the largest or smallest
-5, 2, 5 -> which turns out to be (2)
the way we are using it in the hspd function is we are keeping 2 values the same (maximum speed going left (-5) and maxium speed going right (5), and changing one value (hspd) what ever is the middle value between those three will be what hspd will be. hspd will never go left faster than -5, nor will it go faster than 5 to the right
lets say that hspd+hdir*accl came out to be -6? let's see it
median(-5,5,-6) what is the middle value of -6,-5, and 5? it's -5 so it's a way to maximize a range with a dynamic variable. It's kind of like a volume knob. The knob set's how loud you can hear something but the median() function limits the knob to a minimum(which in our case is the maxium negative speed or left side speed) and a maximum (which is our maxium right side speed)