0 Favourites

# A basic Puzzle example (Now it even swaps back!)

This forum is currently in read-only mode.
• 35 posts
• Due to popular request: This is a tutorial/example from which you can learn how to make a puzzle game in Construct. One of the kind where you have to match three or more blocks horziontally or vertically.

Let me briefly mention that I wouldn't recommend this for absolute beginners. So if you installed Construct just yesterday, you should probably get a little more familiar with it before you check out this tutorial.

This is just my personal approach and doesn't claim to be the way to go.

<font size="5">Part 1 - Playfield Generation</font>

<img src="http://dl.dropbox.com/u/2306601/puzzexam1.png" border="0">

First things first. So we start out with the generation of the playfield. Simply randomized blocks won't do, because we don't want three or more blocks being matched in the beginning.

So let's use an array, some sweet sweet loops and basically crazy stuff.   <img src="smileys/smiley17.gif" border="0" align="middle">

All in the cap, all commented, there you go:

<font size="2">(File created with version 0.99.42 of Construct)</font>

<font size="5">Part 2 - Swapping, Matching & Destroying</font>

<img src="http://dl.dropbox.com/u/2306601/puzzexam2.png" border="0">

Now we get to the really important stuff. After all a cool puzzle game can't work if matching blocks aren't even recognized. It's not quite as simple this time, but nothing to worry about either.

Expect more loops, crazy Else events and... you name it! <img src="smileys/smiley1.gif" border="0" align="middle">

<font size="2">(File created with version 0.99.42 of Construct)</font>

Oh, this time you will really need the Contrast Plus effect. Go get it here:

http://scirra.com/phpbb3/viewtopic.php?f=16&t=4835

<font size="5">Part 3 - Spawning</font>

<img src="http://dl.dropbox.com/u/2306601/puzzexam3.png" border="0">

What's left to do is filling up those unwanted gaps with brand-new blocks.

How is it done? Of course with some nasty events, featuring loops and all the other stuff your parents warned you about! <img src="smileys/smiley4.gif" border="0" align="middle">

<font size="2">(File created with version 0.99.42 of Construct)</font>

<font size="5"><font color="red">Part 3.1 - Now it even swaps back!</font></font>

Here's the functionality some of you have been yearning for: blocks are swapped right back if there hasn't been a match. Thank sweet baby jesus!

Note: All of the newly added comments have green text color on black ground, so you can easily spot them.

<font size="2">(File created with version 1.2 of Construct Classic)</font>

Also still available: alternative first part

<font size="2">(File created with version 0.99.42 of Construct)</font>

• when i try to open it an error comes up saying

[quote:230emgzx]The effect file 'Constrast Plus.fx' is required to open this file. Please locate it and put it in your effects directory under your Construct installation.

what is this.

• Oh, great that you mention this. I don't know why it is in there. Removed and updated.

Btw Contrast Plus is a very good FX by jeffro11 you should get it asap!

http://69.24.73.172/scirra/forum/viewtopic.php?f=16&t=4835

• Thank you. This is a nice start. I can't wait to see more.

• Wow! Great tutorial!

Thank you!

I'm looking forward for the next part <img src="http://i987.photobucket.com/albums/ae352/constructgame/ev.gif">

• PixelRebirth is the man, beat me to posting. I did a similar exampling using what he taught me in my thread and what was written in mary jane's.

Just went through it, I noticed you referenced an object as to where to start creation, not totally necessary if you're designing with a grid, you can just do array's current x + 32 for example and it will fill in every spot until it runs out of space. Though your method works just as easily, I don't think one way is better than the other. The tiled bg does make it more 'mobile' for editing where it lays in the layout.

Thanks a ton for the tutorial. It's gonna help me get my 'action' puzzler finished up. Just need to figure out if an array is the right way to create my blocks since there will be a constant generation going on from the bottom.

• Thx to everybody for commenting.

Just went through it, I noticed you referenced an object as to where to start creation, not totally necessary if you're designing with a grid, you can just do array's current x + 32 for example and it will fill in every spot until it runs out of space. Though your method works just as easily, I don't think one way is better than the other. The tiled bg does make it more 'mobile' for editing where it lays in the layout.

You're totally right. It's just the way I prefer to do it. You could get rid of the tiled bg with some adjustments anytime.

Thanks a ton for the tutorial. It's gonna help me get my 'action' puzzler finished up. Just need to figure out if an array is the right way to create my blocks since there will be a constant generation going on from the bottom.

Spawning of blocks will be the topic of the third part. It should be adjustable to a constant spawning too, depending on the game mechanics you aim for. I don't think an array will pose a problem with that, at least not the (pretty limited) way I use it.

Expect the second part to be online later today or at least tomorrow.

• Awesome, lookin forward to it.

• Okay folks, part 2 is online now!

I hope there are not too many typos or even crude mistakes in there.

• Completely awesome pixel. Thanks a ton for sharing.

I'd say for that type of matching puzzle, in a finished version you should disable swaps that don't result in a match. Obviously it's up to the mechanics you want, but being able to move them freely takes some challenge out.

• I'd say for that type of matching puzzle, in a finished version you should disable swaps that don't result in a match. Obviously it's up to the mechanics you want, but being able to move them freely takes some challenge out.

You have a good point there. I wonder if I should include it in the third part. It wouldn't be terribly difficult to add yourself for somebody who checked out all the examples.

Actually I'm on the verge of rebooting this whole tutorial in favor of a more array-based approach. While I was creating the first two parts I realized that, while it still worked fine, it is the same old engine I used for Crypta more than half a year ago after all, just a little pimped. So I created a new engine for my game, making much better use of the array.

I'm uploading now a replacement for the first part of the tutorial. Let me know what you think. Array all the way or rather the third part of the original examples or both?

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• yeah it's pretty simple to say if there isn't a match, slide em back rather than just not allow for a little extra effect. these examples have been great in showing how to properly use the array inside of construct. I couldn't find a good explanation of it's implementation in construct so i had to totally guess when i first gave it a shot. This obviously would smooth out that process.

I look forward to seeing what's been updated in the first one when I get home from work (can't install construct here )

• It appears I was a little bit too forward with my reboot of this. As it turns out it doesn't appear to be as much of an advantage to do everything with the values inside the array as I had hoped (or the way I tried it wasn't adequate). Because I had still to move the visual blocks on top of that, which kind of ended up in being double the work. That's why I didn't go through with it after all. Never change a winning team I guess.

Anyway, I finally uploaded the third part. Now there's all the info needed to create a basic puzzle game, although it's by far the crudest one of the examples regarding the events.

Again all feedback is appreciated.

• Why isn't this on the wiki tutorials? Lots of nice concepts and ideas here.

• Why isn't this on the wiki tutorials? Lots of nice concepts and ideas here.

I was thinking the same thing when I saw this pop up. never even knew it was here!

If no one beats me to it, I'll put it up on the wiki sometime tomorrow.

• 35 posts