Cursor Movement using 'AWSD' keys in C

Preet Rajpara Mar 02, 2021

Movement of a specific character using the keyboard keys A, W, S and D in C language.

This can be used in small projects as well as in large projects as a module. This allows the user to move the cursor in the console, So in games characters can be moved using this module.

The project is written in C language. And uses three header files.

First standard stdio.h for standard input-output.

The second is windows.h for accessing Win32 API functions.

And the third is conio.h for console input-output.

Other than the main function there is goto_x_y_coordinate(x,y) function which basically places the cursor of the console to the x,y position on the console.

And in the main function, it runs a while loop until the ESC button is pressed and inside while it takes input from the keyboard and accordingly compares the input with a, w, s and d and then moves the course in that direction by either incrementing or decrementing the value of x or y.

Project Files

Loading...
..
This directory is empty.

Comments (0)

Leave a Comment