I started working with GameMaker Studio last night. I had to get a few ideas out on the screen that were cluttering up my brain.
I'm doing a remake of AutoDuel by Origin systems. Why remake an old game? I want to get to the programming portion and not spend time on design. Also, I liked this game but could never get anywhere with it. It's 80's style programming. There's not a lot of space on the old systems so they replaced content with repetitive game-play. In AutoDuel, when you character dies, the save file is deleted. Start from square one.
Last night I achieved moving the player around, player collisions, and room transitions. Today my focus was making the player sprite show up in the same position that it had left the city overview. i.e. The player should show up at the door of the the building that they entered, not at the start point. This would be easy if I set the player sprite to persistent but the building interiors are actually just menus. I didn't want the player sprite showing up walking around the menu. Also, when a key is pressed on the menu to exit, the player would show up in the city overview where they where standing on the menu. A messy situation.
I spent a lot of time going through other people's code trying to determine how to set the player position to the building that they entered. From large RPG frameworks to very simple games I could not find what I was looking for. Finally, I decided to just think it through.
The solution is as follows. Set up a global variable that stores the player objects x and y postion when they hit the room change object. Then when they leave the room, set the player object x and y to what the global position was. Easy enough, but what is the equivalent code that replicates the action of the Jump To logic block. After poring through the scripting language documentation for a half hour or so I could not find what I was looking for. Then I had an Aha! moment. Simple assignment. obj_player.x = global.playerx and the same for y in the city room create code. Done.