Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
In response to this request, this tutorial shows you how to set up a sliding picture puzzle in Ace.


Step 1


Resize and/or crop your image so the width and height are a multiple of 32x32 pixels.


Then change the canvas size to 384x256 so the image will fit, unchanged, on a default-sized character sheet. Keep the image in the top left corner, and save into your Graphics/Characters folder with a ! prefix.


For my example, I used one of Ace's RTP title screen images, resized to 167x128, and then cropped to 160x128 (to make a 5x4 tile puzzle).


With Tsukitsune's help, I even managed to pretty it up with bevelled edges for each piece (but since I'd already taken some screenshots for the tutorial before I did this, some images will sho the bevel, and others won't - hopefully it won't be too confusing).

01_CharacterSheet.png
Step 2


Create a common event in your project, and call it Move Slider. Leave the trigger as None. We'll come back to this later.


Step 3


Create an event on your map for each piece of the puzzle, except the lower right piece, and set the graphic to the appropriate part of your image. Initially, we'll place the events so the pieces are in the correct places (the image is complete). This tutorial assumes you have NO other events on your map yet, so the top left event will be EV001, the one to the right of it will be EV002, etc (place them from left to right, completing a row at a time).


Give the event the following settings:


Walking Anim - OFF


Direction Fix - ON


Priority - Below Player


Trigger - Action Button


Command - Call Common Event - Move Slider (the common event you created in the previous step)


You may also want to increase the movement speed to the highest value.

02_TileEvent.png
Here's how it will look in the editor, and in-game, when all the events have been set up:

03_EventPositions.png
Step 3


Use a region to draw over the area occupied by your puzzle (including the missing piece in the lower right corner). Make a note of the region id, as we'll use it in the common event. This is how we'll know whether a piece can be moved to an empty slot.

04_Regions.png
Step 4


Set up the common event.


We are going to check one direction at a time - if the tile in that direction is in the puzzle region and there is not already an event there, that means this tile can be moved there.


As soon as we find a valid move, we'll make it, then check if all the pieces are in the correct place. If they are, we'll process the "puzzle complete" logic.


If no moves can be made in any direction (either the tile under the player cannot be moved because there are other tiles in all 4 directions, or if the only places it can be moved would put it outside of the puzzle area), we'll play a buzzer.

05_CommonEvent.png
In addition to the variable and switch IDs, you will need to change these values in the Call Script command at the bottom of the event:


- top - the y coordinate of EV001, the first tile in the puzzle


- left - the x coordinate of EV001, the first tile in the puzzle


- width - the number of tiles going across the puzzle


- the id of the switch that indicates the puzzle has been solved


Step 5


Test your game and ensure you can walk over the puzzle pieces and move them around by pressing the space bar. Any tile that is adjacent to the empty spot should move into that empty spot when you stand on it and press space. Any tile that is not adjacent to the empty spot should give you a buzzer SE when you stand on it and press space. If this does not happen, go back and recheck your event settings and the common event.


Step 6


Now you have to move the pieces to their real starting position. You cannot just move them around randomly and put them in any position - that will give you a 50% chance of ending up with a puzzle that's correct apart from two pieces that need to be swapped, which is an impossible move. So you have to begin with a completed puzzle, and move pieces around until you have it as mixed up as you need it to be.


To do this, simply click and drag the events around in the editor, as if you were actually playing the puzzle, only making valid moves. So only move an event that is adjacent to the empty spot, into the empty spot, until the puzzle is as mixed up as you want it to be.


Here's the puzzle, ready to be solved:

08_PuzzleToSolve.png
Where to go from here?


Well, you might want something a bit more special to happen when the puzzle is solved, instead of just showing a text message. Just replace the Show Text command with whatever you want to happen instead.


You might want to stop the player from moving the pieces around after the puzzle has been solved. In that case, turn on a new switch, then for each puzzle piece event, add a second event page conditioned by that switch, with all the same settings, but no event commands.


You might want to fill in the missing piece when all the others are in the correct place. If you want to do that, add an extra event that contains the missing piece and is conditioned by the new switch used above. Put it out of the way (if you put it in its correct position, the "blank" spot will be occupied, and no pieces will be able to be moved), and in the "puzzle complete" section of the common event, do a Set Event Location to move it to its correct spot, before turning on the new switch.


It might be nice to visually change the puzzle once it's been solved. If you've set up your image so each individual piece is bevelled, you could create a second image of the "completed" puzzle, where the image as a whole has a bevel, but the individual pieces do not. They can fit onto the same character sheet. Then on the second tab of each event (conditioned by the new "puzzle complete" switch), take the graphic from the second version of the image.


If you want to change the player's graphic while over the puzzle pieces (let's say instead of the player's sprite, you just want a 'selector' type sprite), add a new event somewhere out of the way and give it 3 event pages:


Page 1 will be set to parallel process, and will repeatedly check the region id of the tile the player is on. If it's the puzzle's region id, change the player sprite and turn on self switch A.


Page 2 will be set to parallel process and conditioned by self switch A, and will repeatedly check the region id of the tile the player is on. If it's NOT the puzzle's region id, change the player sprite back to the original one, and turn off self switch A.


Page 3 will be conditioned by the new "puzzle solved" switch and will be set to Action Button.


Make sure you change the player's graphic back to the original one in your common event's "puzzle solved" logic - AFTER you turn on the new switch that prevents the pieces from being moved.


If you want to be able to return to this map again later and don't want the puzzle to be reset, you'll need to use a script like this one, and write a little Call Script command to make each event remember its position.
 
Last edited by a moderator:

baka

Villager
Member
Joined
Jan 22, 2013
Messages
22
Reaction score
1
First Language
English
Primarily Uses
This a little confusing.

A demo( with project file ) would probably help :) .

Good work, nonetheless.

Never thought the tiles can be done for such purpose, lol. Can make up a good minigame anytime ^_^.
 

monkeyintartan

TartanMonkey
Veteran
Joined
Nov 13, 2013
Messages
195
Reaction score
122
First Language
english
Primarily Uses
Hi I was wondering if you could help me with this.

I have set the events up and everything moves correctly and if I had a buzzer sound it would go off if I couldn't move, also placed sound at the start of the label to check that the event was processing to that point which it was.

But no matter what I try I can't get the completion "event" part to activate. (eg.show a message) any chance you could have a look and see what I am doing wrong

Common Event.png
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
Ugh! That's a long way back for me to remember!


Are you able to zip up your project and load it up somewhere so I can check it out?
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
You have missed a couple of key points/requirements in the tutorial and compensated incorrectly.

This tutorial assumes you have NO other events on your map yet, so the top left event will be EV001, the one to the right of it will be EV002, etc
id MUST start at 0 for the final position checking to work. You've got it set to 69, which is incorrect.

Change this:

Code:
top=7; left=21; width=5for id in 69..91 e = $game_map.events[id+1] if e.x != left + id % width or    e.y != top  + id / width   $game_switches[16]= false  endend
to this:
Code:
top=7; left=21; width=5for id in 0..23 e = $game_map.events[id+69] if e.x != left + id % width or    e.y != top  + id / width   $game_switches[16]= false  endend
 
Last edited by a moderator:

monkeyintartan

TartanMonkey
Veteran
Joined
Nov 13, 2013
Messages
195
Reaction score
122
First Language
english
Primarily Uses
Ohhhh I get it, thank you very much :D what a silly thing for me to miss haha :D
 

VillainIsLemony

Villager
Member
Joined
Jun 9, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
Hello! Thank you so much for this, I love sliding block puzzles! It works very well so far, I only have one concern. Whenever I move a piece, it always registers each movement as a "puzzled finished" and gives me the finished text. For each movement, even if the puzzle isn't 'complete'
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
You must have done something wrong. Check the tutorial again VERY closely. If you can't find out what you've done wrong, zip up your project's folder, load it up somewhere, and provide a link.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
Yeah, you've placed your events incorrectly.


To start with, you have to have them numbered EV001 in the top left corner, going across, then adding rows, until you get EV019 just to the left of the bottom right corner. EV020 is the one that needs to be missing. And when you set their sprites, the picture should look as if it's finished.


You've got the events MOSTLY positioned correctly, but you've removed EV004 instead of EV020, and when you gave them sprites, you made it look like a messed up image.


Check the spoilers in step 3 to see how it should look AT FIRST.


Once you've got that, you need to play the game and walk over the pieces moving them around, until they are sufficiently messed up. Take a screenshot of that. Then go back to the editor and MOVE the events so they are in the right place, according to your screenshot. You are not changing the sprites - you are changing the position of the events.


What you will end up with is events that are NOT in the correct order anymore, and an image that's messed up.


You CAN'T just move them to random positions - you MUST set it up as a finished image first, then play to move them around / mess the image up, then move the events to match your messed up screenshot. If you just place them randomly, there's a good chance you'll end up with a puzzle that can't be solved.
 

VillainIsLemony

Villager
Member
Joined
Jun 9, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
Thank you, I'll go back and try that. I think everything went fine until I tried to shuffle them around.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
By "shuffled them around", do you mean you actually edited each one and changed the images? That's what it looks like you've done, which is not what you're meant to do. You're actually meant to move the entire event to where its current tile is on your screenshot.


I'll also say when I played your puzzle, it was REALLY hard to see where the empty slot was. I suggest you put a different background down, so the spot where the tile is missing is very clear.
 

VillainIsLemony

Villager
Member
Joined
Jun 9, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
By "shuffled them around", do you mean you actually edited each one and changed the images? That's what it looks like you've done, which is not what you're meant to do. You're actually meant to move the entire event to where its current tile is on your screenshot.

I'll also say when I played your puzzle, it was REALLY hard to see where the empty slot was. I suggest you put a different background down, so the spot where the tile is missing is very clear.
I'm pretty sure I moved the entire event, yet I ended up with 20. So I'm going to check out the entire thing again. Thank you so much for the help.

Edit: Hm, even with starting the entire thing over, the blocks slide just fine and everything works, again except that it tells me it's 'complete' every single time I move a piece. Same problem.
 
Last edited by a moderator:

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
Send me JUST the Mapxxx.rvdata2 file from your Data folder this time. I'll take a look at what you've changed, and see if I can see the issue.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
lol!

The script portion has this:

e=$game_map.events[id+82]Where did the 82 come from? It should be this:
Code:
e=$game_map.events[id+1]
However, that's not the BIG problem. The BIG problem is that for some reason you have deleted the script eval command from Game_Interpreter! So NO script commands called from events are running!Here is what yours looks like:

Code:
  #--------------------------------------------------------------------------  # * Script  #--------------------------------------------------------------------------  def command_355    script = @list[@index].parameters[0] + "\n"    while next_event_code == 655      @index += 1      script += @list[@index].parameters[0] + "\n"    end  end
Here is what it SHOULD look like:
Code:
  #--------------------------------------------------------------------------  # * Script  #--------------------------------------------------------------------------  def command_355    script = @list[@index].parameters[0] + "\n"    while next_event_code == 655      @index += 1      script += @list[@index].parameters[0] + "\n"    end    eval(script)  end
So fix that up, and change the +82 to +1, and it'll all be good to go. You still have to "play" to mess up the tiles, take the screenshot, and then move the events to where they need to go based on the screenshot.
 

VillainIsLemony

Villager
Member
Joined
Jun 9, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
Whoa wtf why is my Game Interpreter broken up!?!? Hahaha thank you.

Oh sorry, that was my mistake. I thought id + 1 meant literally, the id number for the map +1

Edit: It works! Thank you SO MUCH!
 
Last edited by a moderator:

VillainIsLemony

Villager
Member
Joined
Jun 9, 2014
Messages
16
Reaction score
0
First Language
English
Primarily Uses
Well, it was working. Now that I've jumbled it, like you said, it gives me this message every time I move a piece.

Script 'Game_Interpreter' line 1411: NoMethodError occured

undefined method `x' for nil:NilClass

But on line 1411, it's exactly as you had me replace: eval(script) So I'm not sure how to fix the `x'
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,083
Reaction score
15,498
First Language
English
Primarily Uses
RMMV
Can you show a screenshot of the script call?


What did you do to jumble it? Are they all still on the correct tiles (region)?
 
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

Sizzle sizzle sizzle...
zbf1dCZ.gif
Sharing my past was a mistake. Will delete the post when I get access to a working internet connection again.
TFW you get a plugin working correctly with your other plugins ♡\( ̄▽ ̄)/♡

(CW for minor gore - Einar's Y incision is gone for his test portrait)

Cs5kAbZ.png
Doing some winter related edits for a cozy cottage!
I think it's the third time I am changing my skill info plugin, but as I get better at programming, I want to fix the trash I made earlier :p

Streaming while I am programming the plugin. Join in if you wish :)

Forum statistics

Threads
116,984
Messages
1,103,515
Members
152,849
Latest member
Minty16
Top