Want to add a puzzle where the player has to assemble a torn up photo, a shredded document or a jigsaw puzzle? Then this could be the module for you!
After Ghostlady posted in the beginner's tech forum (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=34861.0) asking how to make a jigsaw puzzle in AGS without running into object limits, I came up with a concept for how to do it using a struct and DrawingSurface routines. Originally this module was developed exclusively for Ghostlady's game, but we figured that others could also find it useful, so we decided to add some more functionality and make it public.
The module allows you to create a puzzle either from similarly sized sprites in a View or from individual sprites, which can be any size and have any final coordinates but need to be set up one by one. To help you do this, the game features a debug mode where you can position each sprite pixel perfect and then output their setup script to an external text file for cut-n-paste.
Ghostlady has been testing earlier versions, but this is the first public beta. I'd love to hear any feedback on bugs, usability and feature requests. Thanks for trying it out! See module documentation for description of functions and their proper usage.
10 May 2009 Update: Problems have been reported when setting "Use low-res co-ordinates in script" to false (AGS 3.1 and later). I will look into this as soon as possible.
11 Jul 2008 Update: No bugs (except the one I found myself) or feature requests were reported for the BETA, so I'm declaring this slightly updated version the official 1.0. The download link should work directly. Many thanks to Joe Carl for suggesting googlepages.
JigsawModule 1.0 including demo game (http://shadowplaygame.googlepages.com/JigsawModule_100.zip).
The demo game was developed in AGS 3.02 SP1. The module itself should be backwards compatible down to 3.0 (which introduced Dynamic Arrays), but you will have to turn on "Left-to-right Precedence" in the game settings because of a bug in 3.0.1 and earlier.
(The author of this module does not condone the excessive use of gratuitous logic puzzles in adventure games. For everybody's sanity, please limit the use of this module to one or two puzzles per game ;))
great work :o,
i guess it come in handy in one of my next games. :)
Found a bug in the Jigsaw.RemovePuzzle() script. Please change:
if (jigsaw_draggedoverlay != null) jigsaw_draggedoverlay.Remove();
to:
if (jigsaw_draggedoverlay.Valid == true) jigsaw_draggedoverlay.Remove();
This will of course be fixed in the next version.
:o Amazing work!
I'm pretty sure this will prove useful- and the debug mode is a coder masterpiece.
Thanks a lot for sharing this!
Glad to see that someone is giving it a try. Criticism or feature requests are more than welcome. I'd especially like to hear from someone using it with 320x240 graphics - I'm bound to have missed a hi-res check somewhere in the debug code but didn't have time to create lo-res puzzle pieces to try it out.
It seems cool! But I'm dying to try to download it!!!
Why don't you upload it other site?
I downloaded it OK a few minutes ago...
http://ssh.me.uk/others/JigsawModuleBETA0.81.zip
Thanks for mirroring it, SSH. I didn't have any problems either, but downloading from the free host IS quite cumbersome, I agree. Does anyone have a better suggestion for a host? I know there's a whole thread for this, but that's where I found the current host, which sounded like one of the better ones.
Thanks for mirroring!
GG Get a google account and then search for "page creator" in google. All what you upload there will be direct download...
11 Jul 2008 Update: No bugs (except the one I found myself) or feature requests were reported for the beta, so I'm declaring this slightly updated version the official 1.0. The download link should work directly. Many thanks to Joe Carl for suggesting googlepages:
JigsawModule 1.00 including demo game (http://shadowplaygame.googlepages.com/JigsawModule_100.zip)
Edit: If you're using AGS 3.03 beta 1, it fixes a bug in the handling of DynamicSprites as object graphics, so you should be able to uncomment this line which creates problems in older AGS versions:
//if (jigsaw_shadowsprite != null) jigsaw_shadowsprite.Delete();
Quote from: GarageGothic on Thu 10/07/2008 21:00:26
Edit: If you're using AGS 3.03 beta 1, it fixes a bug in the handling of DynamicSprites as object graphics, so you should be able to uncomment this line which creates problems in older AGS versions:
//if (jigsaw_shadowsprite != null) jigsaw_shadowsprite.Delete();
You could surround that with #ifver 3.03...#endif to make that happen automatically (check the syntax cause that's off the top of my head!)
Yeah, I'll do that for the next version. By that time 3.03 might also be near final.
There are five sounds that come with this module: pickupsound, dropsound, snapsound, completesound and lockedsound. They are in .ogg format. When I converted them to .mp3's, not all the sounds played and some of them would use the same sound file. For example, for the puzzle piece pickup, it would play the pickupsound and for the puzzle piece drop, it would also play the pickupsound. When I went back to the .ogg format, all the sounds played correctly. I am using the .ogg files, but thought I report the problem.
Hey i used your module to make a puzzle just to see if i could do it... so i worked it all out and made one like this.... but the only thing i cant figure out is how to make things happen when its completed.
Like change Room or remove puzzle or give inventory upon completion. I tried tonz of stuff if you could help it'd be much appreciated... i'm a nub... haha
function oCup_AnyClick()
{
Jigsaw.CreatePuzzleFromSprites(4, 0, 0, 640, 480, false);
Jigsaw.CreatePuzzlePiece(9, 0, 0);
Jigsaw.CreatePuzzlePiece(10, 160, 0);
Jigsaw.CreatePuzzlePiece(11, 0, 120);
Jigsaw.CreatePuzzlePiece(12, 160, 120);
Jigsaw.SetupPuzzleTray(10, 10, 300, 200);
Jigsaw.SetupPuzzleMovement(10, 8, true, -1, 2);
Jigsaw.SetupPuzzleObjects(object[1], object[2]);
Jigsaw.SetupScoreLabel(lblPuzzleScore, "@SCORE@% complete.", "Congratulations, you completed the puzzle!");
Jigsaw.SetupGraphics(14, 13);
Jigsaw.StartPuzzle();
}
Hi Kiah. Unless you want to add code to the module itself, the one way to do stuff upon completion is to check the state of Jigsaw.GetPuzzleComplete() in your puzzle room's repeatedly_execute. Like so:
Quotefunction repeatedly_execute() {
if (Jigsaw.GetPuzzleComplete() == true) {
Jigsaw.RemovePuzzle();
player.AddInventory(iKey);
player.ChangeRoom(5, 120, 64);
}
}
Let me know if you experience problems.
It's still doing the same thing everything stays there and nothin happens the message says completed! and stuff...i dont have any sound in it or anything... would that change things?... i feel dumb :-\ it seems like it would work grrrr
Hmm, strange. I haven't done much testing of this functionality, but Jigsaw.GetPuzzleComplete() should work. But I see that I defined the variable jigsaw_won as an int instead of a bool. Perhaps this could cause weirdness.
Could you please try to change the line:
int jigsaw_won;
to:
bool jigsaw_won;
and see if it changes anything?
Hey i got it to work! ;D I put
function repeatedly_execute() {
if (Jigsaw.GetPuzzleComplete() == true) {
Jigsaw.RemovePuzzle();
player.ChangeRoom(1);
}
}
In the global script and it works... these both worked so i don't think that it was that
int jigsaw_won;
bool jigsaw_won;
Still curious why it did'nt work when the repeatedly execute was in the room script
But anyway... thanks for the help and quick responses mate(cheers)'
Haha, I love the contents of the letter ;-)
This is a great module and just what I was looking for, thank you for sharing!
I'm glad you found my module useful. Let me know if you have any problems with it, as I haven't really tested the module with the native hi-res coordinates of AGS 3.1+.
This is brilliant -- thanks!
We did find it didn't work when we set "use low res coordinates in script" to false, in AGS 3.1.1. However, setting it to true worked fine. :)
You saved us TONS of work.
I'm glad you found it useful. I'll have to fix the coordinate issue when I get the time, thanks for letting me know about it. Unfortunately the module was written just a week or two before hi-res coordinate support was introduced in AGS, so I never really tested it for compatibility.
:o :o :o That is soo awesome. I've just found that module. The thing with the letter - quite useful for some kind of a game with a crime plot or/and treasure huntin' with a map torn to pieces. ;D
Thanks!
PS: Can we use it to make a puzzle game. I mean the same like the demo but with more options and more puzzles of course? :)
Of course you can. There's no limit on how many jigsaw puzzles you can use in a single game - you just need to initialize a new one from a different set of puzzle pieces. The only problem would be that the state of the previous puzzle would be lost, so the player can't move back and forth between puzzles in different stages of completion. This could be solved by moving the module code to the room script and using a different room for each puzzle. But if each puzzle needs to be solved before moving on to the next, this won't be necessary. Feel free to modify the module in any way you want.
:P Thanks. I didn't quite get the thing with "the state of the previous puzzle would be lost". ??? Can't the state of puzzle X be stored (like saving the game state) and then restored by the player with a load function?
What I meant is that if the player has half-completed one puzzle and decides to leave it and start another, the position of the pieces in the first one will be reset if he returns to that later. This is because the module was only scripted to keep track of one puzzle at a time. If you move the code to your room scripts however, the code in each room will keep track of one puzzle, allowing you to move freely between them.
Ah, thanks a lot! ;D
I wanted to add -- I've made a game with 26 puzzles included (36 pieces each puzzle), and it still works just perfectly.
I love this module, and thanks a lot for creating this great module. However, I've encountered some problems trying to incorporate the torn letter in my game. When I used my cursor to pick up the pieces, the pieces could only be picked up if I clicked somewhere above the piece and when I released it, it fell to a location one or two inches under my cursor. I couldn't figure out how to solve the problem. Please help. Also, does the position of the pixelperfect object in the room matters? and what if I don't have any shadow sprites for the puzzle?
I'm happy to hear that you're finding the module useful. As for your problems, are you running AGS with the "Use low-res co-ordinates in script" property set to true or false? I haven't had time to test the module since the hi-res screen coordinates option were introduced, so there's likely to be some conflict - I will fix this as soon as I can. I don't think the shadow sprite is necessary for the module to work, nor should the original coordinates of the pixelperfect object make any difference.
;D ;D
I changed "Use low-res co-ordinates in script" to true and everything works perfect now!!! Thank you so much!
The debug functionality to find coordinates of the puzzle pieces is extremely helpful. All I need to do is to drag the pieces in debug mode to the proper positions and press Ctrl+J to get the coorindates.
Why when i am running my game it says undefined symbol "lblPuzzleScore" at
Jigsaw.SetupScoreLabel(lblPuzzleScore, "@SCORE@% complete.", "Congratulations, you completed the puzzle!");
You also have to import the GUI.
Well, you could export the GUI from the demo game and import it into your own. But it would be easier to either create a GUI with a label named lblPuzzleScore, or change "lblPuzzleScore" to the name of your own label where you want the score to be displayed.
I have a strange problem. I am making my game were there is a puzzle during the whole game with pieces added as you go along. The Puzzle is working fine, but you can not click on anything in the game. Also if I add a puzzle piece in the middle of the game and click on anything, it shows the error "SetObjectPosition: Invalid Object Number" and cites this portion of the script:
line 207 jigsaw_pixelperfectobject.X = spritedetectx;
The puzzle is in one room separate from the others.
I hope I've made my problem clear.
Hey, GG. This module is excellent and seems like it could be very useful!
Sadly, I, too, have run into the glitch when using hi-res coordinates. A quick check of the forum time/date stamp reveals that it's been quite some time since you last touched this module, and I was just curious whether you still intended to address that particular bug?
Either way, Nice job. ;D
Sorry, didn't notice you reply until now, AGD2. Yeah, the whole module needs an overhaul now that AGS has true high-res coordinates. It was scripted during the brief period when DrawingSurface.UseHighResCoordinates could be used as a workaround, and apparently some of the double-pixel multiplications are now creating problems.
I'll get around to it eventually, but please DO let me know if you need the module for a game in active development, then I'll bump fixing it to the top of my priority list.
Quote from: GarageGothic on Sun 28/03/2010 12:10:42
Sorry, didn't notice you reply until now, AGD2. Yeah, the whole module needs an overhaul now that AGS has true high-res coordinates. It was scripted during the brief period when DrawingSurface.UseHighResCoordinates could be used as a workaround, and apparently some of the double-pixel multiplications are now creating problems.
I'll get around to it eventually, but please DO let me know if you need the module for a game in active development, then I'll bump fixing it to the top of my priority list.
I would adore a bump to get this working on the latest AGS. Starting development on a game course with a young theatre company to create a video game and this module would fit perfectly =)
Sorry I keep missing your posts guys - I don't normally follow the module and plugins forum, but if the "notify of replies" feature works I should get PMs whenever someone posts in this thread from now on.
I'll start working on an AGS 3.2 version of the module very soon. But before I begin scripting, I'd like to hear if there are any more feature requests? It's always good to have all features in mind from the get-go rather than have to use hacks to add them on later.
Some things I plan on adding:
* Rotation of puzzle pieces (user can decide whether they want full 360 degree rotation or only allow 90-degree increments)
* Slider puzzle support - pieces can only move where there isn't already a piece. Randomization of initial position will be limited so the puzzle is always solvable.
* State-saving for multiple puzzles without having to move module code to room script.
* Easier triggering of scripts from win event.
* Adding puzzle pieces during gameplay - e.g dragging pieces from your inventory onto the board.
Anything else you can think of?
Thanks for the offer, but it's alright now. The puzzle I needed to implement wasn't overly complex so I was able to script it from scratch.
As for the 3.2 compatible version: nothing comes to mind in terms of new features, aside from perhaps having the ability to alternatively pick up jigsaw puzzle pieces by single-clicking them and then single-clicking again to drop them (i.e. so that the mouse button doesn't need to be held when dragging them around).
this is a great module.
But I found that you can only leave the puzzle room once the puzzle is completed. After that I run the Jigsaw.RemovePuzzle(); function to make the screen clickable again.
I tried using a gui (as hotspots under the puzzle are not clickable) and made a button to leave the puzzle minigame but i have to call the Jigsaw.RemovePuzzle(); function from the global script, where the button is defined and get an error:
Error: Null Pointer referenced
and the error message shows line 481 of the JigsawModule_100.asc
which is
if (jigsaw_draggedoverlay.Valid == true) jigsaw_draggedoverlay.Remove();
Well, it is possible to leave the puzzle while the puzzle is unsolved but then clicking on the screen has no effect, only GUIs accept clicks. Must be a z-order thing of the overlay. It doesn't matter where I call the Jigsaw.RemovePuzzle(); function I always gets this error except in room_RepExec() if (Jigsaw.GetPuzzleComplete()==true).
Very Useful, thanks! :-D
Hi!
I know it's a very old topic, but I hope somebody can help me. I use AGS 3.4.0.6 and the resolution is 1280x720. The co-ordinates are crazy now, because of hi-res. I know it's working if "Use low-resolution co-ordinates in script" is true in general settings, but I have a half-finished game and I don't want to re-create all former co-ordinates. It would be a too long and hard work. What can I do?
Thank you in advance for your help.
I realize this thread is quite dormant, but does anyone have a link to this module?
Edit: I had bad forum etiquette and missed the sticky that has a list of all modules, and what to do if a link doesn't work (which it still doesn't but I've sent the appropriate IM now). Apologies.