Is it possible to have WASD movement in a game?


#1

Okay, I have been trying to make this game where a stickman walks around the screen. I have tried to make it where you have to use (WASD) to make him move up, down, left and right but it wont work. How do I do this?


#2

Hi there Monaco1!

Here is an example project of what you’re looking to do:

WASDStickman.wick (3.3 KB)

In the project, you’ll see the stickman which I’ve made into a clip. Then I added this code to the clip:

function update() {
    if(keyIsDown('W')) {
        this.y -= 3;
    }
    if(keyIsDown('A')) {
        this.x -= 3;
    }
    if(keyIsDown('S')) {
        this.y += 3;
    }
    if(keyIsDown('D')) {
        this.x += 3;
    }
}

This code basically just says, “every time the project updates, check to see if any of the WASD keys are being pressed. If they are, change the x or y coordinates of the clip in the right direction”

Please let us know if you have any other questions, @Luxapodular and I are happy to help!


#3

Thanks, this helped alot. I love this software.