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
I always use the easiest way where is impossible to do something wrong
if keyboard_check(ord("W")) vspd = -4;
if keyboard_check(ord("S")) vspd = 4;
if keyboard_check(ord("A")) hspd = -4;
if keyboard_check(ord("D")) hspd = 4;
y += vspd;
x += hspd;
But even if we look aside from the directions being the opposite of what they probably should be and the lack of a "don't move if not pressing anything" thing, you also have it set up so if pressing both A and D, you'll move by the direction of D, not not move, which is also something done wrong.
Edit: After you posted your comment, you did edit your comment to fix the directions being opposite (even before I finished writing and posting this comment), but you haven't fixed the rest of the things I mentioned.
if keyboard_check(ord("W")) vspd = 4;
if keyboard_check(ord("S")) vspd = -4;
if keyboard_check(ord("A")) hspd = 4;
if keyboard_check(ord("D")) hspd = -4;
if !keyboard_check(ord("W")) and !keyboard_check(ord("S")) vspd = 0;
if !keyboard_check(ord("A")) and !keyboard_check(ord("D")) hspd = 0;
y += vspd;
x += hspd;
Now its correct.
Besides that, while you've made it so not holding A while not holding D makes you not move horizontally, you haven't made it so holding both A and D at the same time makes you not move horizontally.