M
MrSanfrinsisco
Guest
I'm very new at coding this so this might be an obvious mistake and I apologize but I'm trying to make it so my player cannot walk outside of the room. I created a sprite for the wall which I don't think was necessary actually considering there is no picture for the wall and I created an object for the wall called "obj_wall". Maybe its as simple as the obj NEEDS a picture? I'm not too sure but here's the code I have for the player movement.
If you need any other information just let me know and I'll gladly provide it.
Code:
if (keyboard_check(ord("W"))) {
if (!place_meeting(x, y-runspeed, obj_wall)) {
y = y - runspeed;
}
}
if (keyboard_check(ord("A"))) {
if (!place_meeting(x-runspeed, y, obj_wall)) {
x = x - runspeed;
}
}
if (keyboard_check(ord("S"))) {
if (!place_meeting(x, y+runspeed, obj_wall)) {
y = y + runspeed;
}
}
if (keyboard_check(ord("D"))) {
if (!place_meeting(x+runspeed, y, obj_wall)) {
x = x + runspeed;
}
}