How do I make my player move?

 

Drag and drop

Let's say you wanted to move you player left, add a keyboard <Left> event to the player object, now select the control tab and drag over If a position is collision free, this will check if where the player is about to move to is empty, if so, the player can move there. In x, place -4 and tick Relative (this means were checking 4 pixels to the left of the player).

 

Click on OK, select the move tab and drag over Jump to a given position, in the x place the same number as you did when checking for a collision (-4 in this case) and your player can now move left.

 

Do the same for a keyboard right event but just put 4, not -4, the same goes for up and down, experiment to see which is which.

 

--oOo--

 

Code

Ok, here's how do move the player using code, add a keyboard <Left> event to the player object, and select the code tab and drag over Execute a piece of code, in the code type:

 

{ x -= <speed number goes here, e.g. 6>; }

 

X is horizontal and a minus number means 'move to the left'. Do the same for keyboard <Right> event but put a plus number. Keyboard <Up> is a Y number.

 

Or

 

Add a Step event and place the following code:

 

if (keyboard_check(vk_left)) x -= 6;

if (keyboard_check(vk_right)) x += 6;

if (keyboard_check(vk_up)) y -= 6;

if (keyboard_check(vk_down)) y += 6;