Sawnik":2ygv03yq said:
Sure, show me some screenshots. I didn't understand how to make it check the location... :P
Righto. Warning: Lots of screenshots.
Further warning: This is pretty much intended to be a teaching tool-- in an actual game, parts of it would be structured differently. I'll try to point these bits out.
This here is the overall map. The object of the puzzle is to push the boulder onto the little patch of grass. When there's a weight on top of the patch of grass, whether it's boulder or player, the door is open. Otherwise, it's shut.
Here's the boulder. Very simple.
Here's the door, page one. It does nothing until page two's conditions are met.
And here's page two of the door, activated by a switch that will be covered later.
These two events are how the game tracks the location of both player and boulder. Note that it is
not necessary to actually make two different events-- I just did that to show each step. (Obviously, you also don't need to make them visible.)
Note that they are parallel process events without conditions-- they run the entire time that the player is on the map, in the background. Using too many of these will cause lag.
This event is tracking whether or not the boulder or the player is on the patch of grass, by comparing their map coordinates to the coordinates of the patch of grass. If either one is, it opens the door by turning the "Door Open" switch ON.
The Door Open switch being ON activates the second page of that event...
This bit of code is trickier. What it's doing is checking to see if either the boulder or the player is on the switch. If neither is, it shuts the door again, resetting the event.
Want to make a simpler version? You can eliminate a lot of code if you don't want the player to be able to trigger the switch, and eliminate those last two screenshots entirely if the door doesn't close again.
On the other hand, I like this version of the puzzle-- it's a fair logic puzzle. The player can deduce that weight needs to stay on the switch, and thus can work out that the boulder can be pushed onto it.
Was that helpful enough?