• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [SOLVED] I'm kinda new and i'm not sure what to do here.

J

Joky

Guest
I might sound pretty stupid asking this so sorry about that.
But I'm trying to do this:

Player obj walks to vault obj and presses z and it changes (escapedoorlocked = true) - (escapedoorlocked = false)
But it doesn't work for me. So can someone help me?
I'll post code if needed.
 

obscene

Member
Always post code, else there's nothing to do but guess. Include what code is in what object and what event.
 
J

Joky

Guest
ok so the player (obj_robot) has just easy walking codes

the vault has these codes:
"create" event and a "key press z" event

create event:

vaultlocked = false

key press z event:

if(obj_robot.x = 60 && obj_robot.y < 370 and obj_robot.y > 290 && vaultlocked = false)
{
escapedoorlocked = false;
}

The Door has these codes:
"create" event and a "key press z" event

create event:

escapedoorlocked = true

key press z event:

if(obj_robot.x = 60 && obj_robot.y < 270 and obj_robot.y > 150 && escapedoorlocked = false)
{
game_end()
}

Sorry if I do this wrong.
 

zATARA_0

Member
Im assuming the vault is an object as well, if thats the case then you can use point_distance to see if you are close enough to the safe, rather then checking if you are at a specific x or y. It looks like escapeldoorlocked is just stored on the door, and when you set it to false on the vault you arent specifying that it is the doors code.

make the vault code like this maybe.

if(obj_robot.x = 60 && obj_robot.y < 370 and obj_robot.y > 290 && vaultlocked = false)
{
var _door = instnace_nearest(x,y,obj_door);
_door.escapedoorlocked = false;
}
 
J

Joky

Guest
how does "point_distance" work because I just found out there's a mistake in the if statement.
 
J

Joky

Guest
I did some research and finally got it to work. Thank you everyone for the help!
 
Top