MODULE: JigsawModule 1.0 (for AGS 3.0+)

Started by GarageGothic, Fri 04/07/2008 22:50:50

Previous topic - Next topic

GarageGothic

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 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.

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 ;))

Rocco

great work  :o,
i guess it come in handy in one of my next games.  :)

GarageGothic

#2
Found a bug in the Jigsaw.RemovePuzzle() script. Please change:

Code: ags
if (jigsaw_draggedoverlay != null) jigsaw_draggedoverlay.Remove();


to:

Code: ags
if (jigsaw_draggedoverlay.Valid == true) jigsaw_draggedoverlay.Remove();


This will of course be fixed in the next version.

Ghost

 :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!

GarageGothic

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.

Joe

It seems cool! But I'm dying to try to download it!!!

Why don't you upload it other site?
Copinstar © Oficial Site

SSH

12

GarageGothic

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.

Joe

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...
Copinstar © Oficial Site

GarageGothic

#9
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

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:

Code: ags
//if (jigsaw_shadowsprite != null) jigsaw_shadowsprite.Delete();


SSH

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:

Code: ags
//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!)
12

GarageGothic

Yeah, I'll do that for the next version. By that time 3.03 might also be near final.

Ghostlady

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.
My Games:

Hauntings Of Mystery Manor
Intrigue At Oakhaven Plantation
Haunting at Cliffhouse

Kiah

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(); 
}

GarageGothic

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.

Kiah

#15
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

GarageGothic

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:

Code: ags
int jigsaw_won;


to:

Code: ags
bool jigsaw_won;


and see if it changes anything?

Kiah

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)' 

Goldmund

Haha, I love the contents of the letter ;-)

mrsix

This is a great module and just what I was looking for, thank you for sharing!

SMF spam blocked by CleanTalk