Triangle puzzle like in openquest

Started by Buckethead, Sat 12/01/2008 17:36:22

Previous topic - Next topic

Buckethead

Hey,

I want to make a puzzle similiar to the one with the green triangle in openquest. Now I know the author of open quest has probably put alot of efford in making this puzzle and showing how to do it.... But I just don't understand how it works. All I can figure out it was the piece of code does... But not why it's written like that.

Could someone provide me a little more info?  :)

Thanks

Galen

It basically checks if the peices are close to where they should be coordinate wise.

Buckethead

I know what it does. But I have no idea how to do it myself.  :(

Galen

Hmm.... I can't see a simpler way to teach you rather than using the OpenQuest.

Khris

Oh my. I've taken a look at the code and while it's solid it's also done in the probably most unwieldy way imaginable.

So, you figured out what the code does but not why it's written like that? I'm not following you. Are you talking about the necessary "any click on object" events? ???

Giddy Plant

The author of the "unwieldy way" was me, and yes it is. There's no need to do it all manually like that but it got the job done at the time!

Buckethead

Well I know what the codes does because they have green lines of comments but for the most part I'm clueless on how to make this puzzle myself.  ???

Khris

Ok, I'll try to break it down for you:

- the puzzle pieces are objects. GI 13 is used to store which piece is currently attached to the mouse; if it's 0, no piece is attached.

- every object/piece has its on click event set to do the following:
if (GI 13 == 0 [no piece attached]), set GI 13 to the clicked object's number and the object's baseline to 200 so it's displayed above all other objects
if (GI 13 != 0 [object x is attached]), set GI 13 to 0 i.e. drop the piece. Compare it's current position to the target position and move it there if it's in the vicinity.

- the room's rep_exe centers the currently attached piece (if there is one/GI 13 != 0) at the mouse's coords. This also makes sure that if a piece is attached, the player can only click that piece, none other, which'll result in it being dropped.

So far so good.

As for doing that puzzle yourself, add the pieces as objects to your room.
Then add the elements from the OpenQuest room script to your own room.
Alternatively, copy the room to your own game and reset the sprites of the objects.
If you want to use fewer pieces, you're fine, just delete the superfluous objects.
If you want to use more pieces, add the "any click" event to each new object.

Buckethead

Thanks, I think I get it now  :D

Will be some trial and error to get it right but I think I see how it works now  :)

SMF spam blocked by CleanTalk