G
General Woodchuck
Guest
Making a top down RPG. I've got it set up right now where if you hold the action button, he will slowly peak through the door and open it more and more until it's fully open.
This works fine, however if I go to close it while I'm standing right in the middle of the door, my character gets stuck inside it.
The code for my character is shown below. This is just an example for when he is using a door that is to his left, and opens outward.
The way the door works is if it's "open" (or image_index = 5 <-- which is the frame where the door looks open) then solid = false (can walk through it), else: solid = true (can't walk through it). So if my character closes the door on himself he gets stuck in it and can't move until he open's it again.
Ideally I'd like to do this:
If my character is touching the center of the door object, bump him over so that the left side of the character object is touching the right side of the door. I still haven't completely grasped the bbox_left, bbox_right thing and I've also experimented with the "sprite_width" but can't figure out a good way to use that either.
I hope I asked that in a way that makes sense.... Any help is very much appreciated!
This works fine, however if I go to close it while I'm standing right in the middle of the door, my character gets stuck inside it.
The code for my character is shown below. This is just an example for when he is using a door that is to his left, and opens outward.
The way the door works is if it's "open" (or image_index = 5 <-- which is the frame where the door looks open) then solid = false (can walk through it), else: solid = true (can't walk through it). So if my character closes the door on himself he gets stuck in it and can't move until he open's it again.
Ideally I'd like to do this:
If my character is touching the center of the door object, bump him over so that the left side of the character object is touching the right side of the door. I still haven't completely grasped the bbox_left, bbox_right thing and I've also experimented with the "sprite_width" but can't figure out a good way to use that either.
I hope I asked that in a way that makes sense.... Any help is very much appreciated!
Code:
{
if (keyboard_check_pressed(vk_alt)){show_message(string(obj_doorP_w.bbox_right))}
}
//wDoor to the left, open outward
if ((distance_to_object(obj_doorP_w)<=6)&&(obj_doorP_w.x<=x)&&(keyboard_check(keyAction))&&!(distance_to_object(obj_doorP_w)>6)&&(!keyboard_check(keyRun)))
{
{if (obj_doorP_w.doorOpen==true&&place_meeting(x,y,obj_doorP_w)&&facing=="w"){x = x + 10}};
{if (sign(obj_doorP_w.bbox_bottom)>1&&place_free(x-speed,y)){x += sign(obj_doorP_w.x)} {y += sign(obj_doorP_w.bbox_bottom - bbox_bottom)}}; //if not close to knob, move closer
if (place_meeting(x-1,y,obj_doorP_w)) //doorW to the west, open OUTWARD(to the west)
{speed=0}
{openingDoor = true}
{image_speed = 0}
{sprite_index=openDoorW}
{image_index = obj_doorP_w.openness}
{if (keyboard_check(keyLeft)){obj_doorP_w.openness = obj_doorP_w.openness + .5}}
{if (keyboard_check(keyRight)){obj_doorP_w.openness = obj_doorP_w.openness - .5}}
}
else
{
if (keyboard_check_released(keyAction) or (keyboard_check_pressed(keyRun)))
{
openingDoor = false
image_speed = def_imgSpeed
if (sprite_index=openDoorW or sprite_index=pullDoorW){sprite_index=idleW}
if (sprite_index=openDoorE or sprite_index=pullDoorE){sprite_index=idleE}
if (sprite_index=openDoorN or sprite_index=pullDoorN){sprite_index=idleN}
if (sprite_index=openDoorS or sprite_index=pullDoorS){sprite_index=idleS}
}