• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows Code not working

R

r7465

Guest
So I made an object, and it uses this code:

if keyboard_check_pressed(vk_down) vspeed = 4 else
if keyboard_check_pressed(vk_up) vspeed = -4 else
if keyboard_check_pressed(vk_right) hspeed = 4 else
if keyboard_check_pressed(vk_left) hspeed = -4 else
if keyboard_check_released(vk_up || vk_down) vspeed = 0 else
if keyboard_check_released(vk_right || vk_left) hspeed = 0

When I press up or down, it stops moving - that's fine.
But when I press right or left, nothing happens. Anyone here knows what's wrong?
 

FrostyCat

Redemption Seeker
I know what's wrong --- you didn't read this article. Pay attention to the two rules near the end of the article:
  • DO NOT translate English sentences word-for-word into GML symbols.
  • If either side of an && or || operator is not meant to be treated as a Boolean value (true/false), the code is wrong.
This is what your first release check should have looked like:
Code:
if (keyboard_check_released(vk_up) || keyboard_check_released(vk_down))
Same with the line after.
 
Top