A
Aidan Carter
Guest
I am trying to make a player move around freely on the x and y axis (kinda Undertale style for reference) while also not moving through various objects like walls and platforms. I've got the X axis down but when I test the Y movement It doesn't work.
Any help would be greatly appreciated!
Here is the Code:
up = keyboard_check(ord("W"))
left = keyboard_check(ord("A"))
right = keyboard_check(ord("D"))
down = keyboard_check(ord("S"))
xspeed = 0
if(left){
if(place_meeting(x-movespeed,y,Obj_Wall)||place_meeting(x-movespeed,y,Obj_Platform)||place_meeting(x-movespeed,y,Obj_Moving_Platform)){
while(!place_meeting(x-1,y,Obj_Wall)&&!place_meeting(x-1,y,Obj_Platform)&&!place_meeting(x-1,y,Obj_Moving_Platform)){
x = x-1
}
}
else{
x = x - movespeed
}
}
if(right){
if(place_meeting(x+movespeed,y,Obj_Wall)||place_meeting(x+movespeed,y,Obj_Platform)||place_meeting(x+movespeed,y,Obj_Moving_Platform)){
while(!place_meeting(x+1,y,Obj_Wall)&&!place_meeting(x+1,y,Obj_Platform)&&!place_meeting(x+1,y,Obj_Moving_Platform)){
x = x+1
}
}
else{
x = x + movespeed
}
}
//yspeed = yspeed + g
//if(yspeed > 10){
// speed = 10
//}
if(up){
y = y+1
if(place_meeting(x,y+1,Obj_Wall)|| place_meeting(x,y+1,Obj_Platform)||place_meeting(x,y+1,Obj_Moving_Platform)){
while(!place_meeting(x,y+1,Obj_Wall)&& !place_meeting(x,y+1,Obj_Platform)&& !place_meeting(x,y+1,Obj_Moving_Platform)){
y = y + 1
}
yspeed = 0
}
}
if(down){
y = y - 1
if(place_meeting(x,y+yspeed,Obj_Wall)|| place_meeting(x,y+yspeed,Obj_Platform)|| place_meeting(x,y+yspeed,Obj_Moving_Platform)){
while(!place_meeting(x,y-1,Obj_Wall)&& !place_meeting(x,y-1,Obj_Platform)&& !place_meeting(x,y-1,Obj_Moving_Platform)){
y = y - 1
}
yspeed = 0
}
}
vspeed = yspeed
hspeed = xspeed
Any help would be greatly appreciated!
Here is the Code:
up = keyboard_check(ord("W"))
left = keyboard_check(ord("A"))
right = keyboard_check(ord("D"))
down = keyboard_check(ord("S"))
xspeed = 0
if(left){
if(place_meeting(x-movespeed,y,Obj_Wall)||place_meeting(x-movespeed,y,Obj_Platform)||place_meeting(x-movespeed,y,Obj_Moving_Platform)){
while(!place_meeting(x-1,y,Obj_Wall)&&!place_meeting(x-1,y,Obj_Platform)&&!place_meeting(x-1,y,Obj_Moving_Platform)){
x = x-1
}
}
else{
x = x - movespeed
}
}
if(right){
if(place_meeting(x+movespeed,y,Obj_Wall)||place_meeting(x+movespeed,y,Obj_Platform)||place_meeting(x+movespeed,y,Obj_Moving_Platform)){
while(!place_meeting(x+1,y,Obj_Wall)&&!place_meeting(x+1,y,Obj_Platform)&&!place_meeting(x+1,y,Obj_Moving_Platform)){
x = x+1
}
}
else{
x = x + movespeed
}
}
//yspeed = yspeed + g
//if(yspeed > 10){
// speed = 10
//}
if(up){
y = y+1
if(place_meeting(x,y+1,Obj_Wall)|| place_meeting(x,y+1,Obj_Platform)||place_meeting(x,y+1,Obj_Moving_Platform)){
while(!place_meeting(x,y+1,Obj_Wall)&& !place_meeting(x,y+1,Obj_Platform)&& !place_meeting(x,y+1,Obj_Moving_Platform)){
y = y + 1
}
yspeed = 0
}
}
if(down){
y = y - 1
if(place_meeting(x,y+yspeed,Obj_Wall)|| place_meeting(x,y+yspeed,Obj_Platform)|| place_meeting(x,y+yspeed,Obj_Moving_Platform)){
while(!place_meeting(x,y-1,Obj_Wall)&& !place_meeting(x,y-1,Obj_Platform)&& !place_meeting(x,y-1,Obj_Moving_Platform)){
y = y - 1
}
yspeed = 0
}
}
vspeed = yspeed
hspeed = xspeed