Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi! I am creating a code, how do you make a WASD function? The game I'm making is a copy of the snake game. How do you make a WASD function in C?

I have been learning about the 'case' function, can someone tell me more?

What I have tried:

I have learned a lot by researching.
Posted
Updated 6-Mar-21 7:05am
Comments
KarstenK 3-Mar-21 13:42pm    
please learn the basics. It also lets you ask better questions which will lead to better answers for you ;-)

By writing the code to perform the required actions depending on which key is pressed. If you have an actual programming problem then please provide the details.

[edit]
I am reminded of my answer to your previous question at How do I create a if up key pressed, go up code?[^].

As mentioned in your later question today, actually learning the language would be a better use of your time than posting all these questions here.
[/edit]
 
Share this answer
 
v2
I was assume that WASD refers to the keyboard's keys used for directions in games. You obtain input from the user and translate W to a value that means up to you, A will mean left, D will mean right, etc. That means you have to define values for the four directions that mean something to your code and return one of those depending on which key the user presses. You have not specified an OS and that will make a difference to your implementation.
 
Share this answer
 
Quote:
Hi! I am creating a code, how do you make a WASD function? The game I'm making is a copy of the snake game. How do you make a WASD function in C?

When I played 'Snake][' on Apple ][, I used to use 2 keys only.
1Key is 'turn left', the other is 'turn right'
The advantage, only 2 finger needed and no need to check if doing a 'U turn'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900