Gw Temp

Menu

Tutorial - 'Sliding Puzzle' by Guest

An item about RPGMaker 2000 posted on

Blurb

How to creat a sliding puzzle in your RPG

Body

This is not for beginners! You know those slide puzzles where you have a picture, but its all messed up, and you have one blank space with which to slide pieces into? Here is how to make one for rm2k or rpg maker XP. i saw a previous tutorial on this, but it required NINE pages PER event! This one requires:
9 events
8 switches
3 variables
You also need to know about passwords and fork conditions.

Ok, first off lets make our puzzle pieces. Create a new event, and call it 'Puzzle Piece 01' or similar. Make the activated by 'push key' and 'below hero'. Then, choose the graphic that will form the TOP LEFT HAND CORNER of the puzzle and set it as this.

Then, enter the following code in the event:

Enter Password: [Variable] Just choose a free variable, and call it 'direction.' For the enter password command, make sure the settings are: 'Wait Until Key Hit' and 'Direction 1,2,3,4'. The other two boxes should NOT be checked.

Then, the next lines are as follows:

FORK Optn: Varb [0001:direction]-1
Move Event...: this event, down
Else
FORK Optn: Varb [0001:direction]-2
Move Event...: this event, left
Else
FORK Optn: Varb [0001:direction]-3
Move Event...: this event, right
Else
FORK Optn: Varb [0001:direction]-4
Move Event...: this event, up
Else
End
End
End
End

This code specifies that when a key is hit, it will assign the key's value to the variable called 'direction'. Then the fork conditions will move the event accordingly. The next lines go:

Wait: 0.3 secs
Variable Ch: [0002position x] Set, this event X pos
Variable Ch: [0003position y] Set, this event y pos

This specifies that the x coordinate of the event should be stored to the variable called 'position x' (that you should make) and the y coord will be stored to variable 'position y'. The wait function is in place to prevent the operation freezing up, as i encountered when writing this code. The next part:

FORK Optn: Varb [0002: position x]-5
FORK optn: Varb [0003: position y]-5
Change switch: [0002:PIECE ONE]-ON Set
Else
Change Switch [0002: PIECE ONE]-OFF Set
End
Else
Change Switch [0002: PIECE ONE]-OFF Set
End

Now i will explain this code. The first part of the code:
FORK Optn: Varb [0002: position x]-5
FORK optn: Varb [0003: position y]-5
checks that the puzzle piece is in the position it should be to complete the puzzle. The five and five on the end of these statements are simply example numbers i have used. You need to find the coordinates of the event being edited. These can be found by looking at the bottom of the screen, where it should say 'Map Name (XXX,YYY), Puzzle Piece 01'. The X coordinate is first. IF the piece IS in the right position, the switch you have called 'puzzle piece one' should be turned on, and if it is NOT in the right position, it will be turned off. That is all the code you need for each event.

Now, to make the other puzzle pieces. You should copy the event you have just made, and make another 7, arranging them in a square like this:

+++
+++
++

rename the other pieces 'puzzle piece 2', 3, etc. Then change the graphic for each one, so that the events all make a picture. Then change the code to correspond with each piece. The code that needs to be changed is:


FORK Optn: Varb [0002: position x]-5 <----- This number
FORK optn: Varb [0003: position y]-5 <----- This number

the numbers should be changed to the current coordinates of the event as described before. In addition, ALL the existing switches should be replaced by new ones, called 'piece two', three etc, but with the same settings.

Now, you have made you pieces, but their needs to be a boundary. Place a immpassable part of the chipset around the puzzle like this:

=====
=+++=
=+++=
=++ = <---- Notice this gap, used to move.
=====

Make the hero's default graphic a target, or cursor or something and set the hero start position to the blank space in the puzzle specified above.

NOW! You have made the puzzle, and the hero, the only thing left to do is create an event that will react accordingly if the puzzle is solved!

This is VERY easy. It should be placed out of the way, and Should be a Parallel Process. The code reads:

Fork Optn: Switch[0001: Piece One]- ON
Fork Optn: Switch[0001: Piece Two]- ON
Fork Optn: Switch[0001: Piece Three]- ON
Fork Optn: Switch[0001: Piece Four]- ON
Fork Optn: Switch[0001: Piece Five]- ON
Fork Optn: Switch[0001: Piece Six]- ON
Fork Optn: Switch[0001: Piece Seven]- ON
Fork Optn: Switch[0001: Piece Eight]- ON
Messg: WELL DONE, YOU SOLVED IT!
Teleport: 002: Somewhere
End
End
End
End
End
End
End
Emd

That's it! So, if every switch is flicked on by the pieces being in their correct place, it will show the message and then teleport you. There is only ONE problem with this method. Have you spotted it? A piece CANNOT start in it's correct position, otherwise it's switch may never be turned on! To fix this, move all the pieces to different locations, making sure the player will be FORCED to move them at some stage.

Hope this helped you. If need any more:

emailstub@hotmail.com

thanks a lot!

Look out for my upcoming game, 'SUNWORSHIPPER', that has a 29 piece slide puzzle, and many other amusing mingames.