Hey all, I hate for my first post to be something that's probably a pretty easy problem, but I've scoured this forum and others and haven't found a good solution. This is my first time using GameMaker and I have essentially no coding/scripting experience. I've done a few tutorials, but first solo game.
I'm trying to make a top down puzzle game where you have to push blocks. Four way directional movement (udlr), pretty basic.
I can get my character to push the block, and I can get the block and player to stop when they collide with a wall, but (for example) if the block's against the left wall, and I press both left and up, the block will slide up.
I'm using the following "execute code"s for my player and my object.
Player-> Step eventif keyboard_check(vk_up) and place_free(x,y-playerSpeed ) {
y -= playerSpeed;
}
if keyboard_check(vk_left) and place_free(x-playerSpeed,y) {
x -= playerSpeed;
}
if keyboard_check(vk_down) and place_free(x,y+playerSpeed) {
y += playerSpeed;
}
if keyboard_check(vk_right) and place_free(x+playerSpeed,y) {
x += playerSpeed;
}
obj_crate -> Collision w/ obj_player
if keyboard_check(vk_up) and place_free(x,y-obj_player.playerSpeed ){
y -= obj_player.playerSpeed;
}
if keyboard_check(vk_left) and place_free(x-obj_player.playerSpeed,y) {
x -= obj_player.playerSpeed;
}
if keyboard_check(vk_down) and place_free(x,y+obj_player.playerSpeed) {
y += obj_player.playerSpeed;
}
if keyboard_check(vk_right) and place_free(x+obj_player.playerSpeed,y) {
x += obj_player.playerSpeed;
}
Any help is greatly appreciated, and if there's a better way to do my movement, I'm all ears.
Thanks in advance!
--Andy K