why won't my character move in this script.

Twisty

Member
// get players input

jump_key = keyboard_check_pressed (vk_space);
dkey = keyboard_check(vk_right);
akey = keyboard_check(vk_left);


// d key = right movement
{
if (place_free(x+4, y)) && keyboard_check(ord('d'))
x += 4
}

// a key = left movement
{
if (place_free(x-4, y)) && keyboard_check(ord('a'))
x -= 4
}
 
You need to check for capital letters. I also believe that single quotation marks aren't valid anymore within ord(), but I may be mistaken.
 

Twisty

Member
You need to check for capital letters. I also believe that single quotation marks aren't valid anymore within ord(), but I may be mistaken.
but if i deleted
// a key = left movement
{
if (place_free(x-4, y)) && keyboard_check(ord('a'))
x -= 4
}

the first one would work perfectly in the direction of right
 

Tony Brice

Member
It looks if there is free space 4 pixels to the left of the current x position, if the player is pressing A on the keyboard. If it's ok then it moves x -4 pixels.
 

chamaeleon

Member
It looks if there is free space 4 pixels to the left of the current x position, if the player is pressing A on the keyboard. If it's ok then it moves x -4 pixels.
Nothing is moving because you are not assigning x-4 to anything. That is what @Nidoking means with no-op. You are performing a mathematical operation whose value is tossed away due to lack of assignment.
 
Top