rookie asks for help part III

netoxinaa

Member
i want to make a small square menu pop in the screen when the user hits enter, i created and object for the menu and i was thinking in addin a "key pressed" event in the player object, but is there a way to place an object in the current room from simple code? or do i need to place it in the room and deactivate it before running it? or does anyone has a better idea about how to make this happen? peace
 

samspade

Member
Any of those things would work. Some are better ideas than others.

Don't put it in the player object. There's no technical reason you can't, it's just bad design to lump a bunch of things into unrelated things. In a small project you'll be able to keep track of things, but in a larger project you won't and it also creates needless dependencies like needing to have a player object present to have the menu pop up.

My design for similar things is have some type of controller or handler object. How general you want this can be up to you. For gameplay stuff I generally have an obj_pause_controller or obj_in_game_menu_controller persistent object that gets created when the 'gameplay' starts. This object monitors things relevant to it - like pausing or entering a menu - and then spawns in other things as needed - e.g. if enter is pressed, create an instance of obj_menu.
 

netoxinaa

Member
Any of those things would work. Some are better ideas than others.

Don't put it in the player object. There's no technical reason you can't, it's just bad design to lump a bunch of things into unrelated things. In a small project you'll be able to keep track of things, but in a larger project you won't and it also creates needless dependencies like needing to have a player object present to have the menu pop up.

My design for similar things is have some type of controller or handler object. How general you want this can be up to you. For gameplay stuff I generally have an obj_pause_controller or obj_in_game_menu_controller persistent object that gets created when the 'gameplay' starts. This object monitors things relevant to it - like pausing or entering a menu - and then spawns in other things as needed - e.g. if enter is pressed, create an instance of obj_menu.
thank you man thats what i wanted to hear!
 
Top