Page 4 of 5

Re: 8-puzzle game

Posted: Mon Nov 21, 2011 10:14 pm
by syedhoque1994
When creating the actual board of the 8-puzzle game, do the actual 8 tiles have to be dragged and dropped. then each assigned a unique number arranged in a 3 * 3 grid and the shuffle button placed below, the code for which controls the movement of all 8 tiles on the board to be arranged randomly, rather than calling openStack?

Syed

Re: 8-puzzle game

Posted: Mon Nov 21, 2011 10:20 pm
by bn
Hi Syed,

have you looked at the lesson?

Kind regards

Bernd

Re: 8-puzzle game

Posted: Tue Nov 22, 2011 2:16 pm
by syedhoque1994
In the 8 puzzle tutorial, does the shuffle button have to be created manually, then code for it applied to the script for that button?

Re: 8-puzzle game

Posted: Tue Nov 22, 2011 4:18 pm
by bn
Hi Syed,

I tried to recreate the 8-piece puzzle from the lesson: http://lessons.runrev.com/s/lessons/m/4 ... zzle-Game-

Unfortunately the assumption of the script that a newly created button is named "new button" is not correct. The name of button created by the "new button" command by script is "button id xxxx". Only a button created by dragging a button from the toolbar is named "new button"

I changed every reference to "new button" to "last button". That works.

I post the working example of the lesson here.
puzzle8piece.livecode.zip
(3.44 KiB) Downloaded 299 times
that should also answer your question: the shuffle button is created when the card gets an openstack message. All buttons are deleted and the game is created anew. To see this type openstack into the message box and hit return.


Kind regards

Bernd

Re: 8-puzzle game

Posted: Tue Nov 22, 2011 4:40 pm
by bn
To all,

As of Livecode version 4.6.4 a new button created by script via

Code: Select all

new button
is not named "new button" but "button id xxxx"

That was the reason the script of the lesson for the 8-piece-puzzle failed in Livecode 4.6.4 and later.

Kind regards

Bernd

Re: 8-puzzle game

Posted: Tue Nov 22, 2011 5:16 pm
by Klaus
Hi syedhoque1994,

I highly recommend that you work through these stacks here to get the basics of LiveCode!
http://www.runrev.com/developers/lesson ... nferences/


Best

Klaus

Re: 8-puzzle game

Posted: Wed Nov 23, 2011 1:29 pm
by syedhoque1994
I have created the shuffle button and the 8 tiles in the game, but when I run the code and click on either a tile or the shuffle button, there are errors in the script of which seems to be undetectable. Can you find the error in these lines of code?: (put random (sSpaceButton) - 1 into tButtonToSwap) and (put item 1 of location of button ("b" & pButton1) - \).
Thanks

Syed Hoque

Re: 8-puzzle game

Posted: Wed Nov 23, 2011 3:01 pm
by bn
Hi Syed,

in the script of the card replace every occurence of "of me" with "of this stack" if you have the script in the card script.

the three occurences are:

Code: Select all

  set resizable of this stack  to false
end openStack

Code: Select all

set the width of this stack to 60 * sTilesX + sOffset * (sTilesX - 1) + 40

Code: Select all

 set the height of this stack to 60 * sTilesY + sOffset * (sTilesY - 1) + 80
and see if it works if you start the stack anew.

By the way runrev has udated the lesson and it should work now as posted.

Kind regards

Bernd

Re: 8-puzzle game

Posted: Wed Nov 23, 2011 9:47 pm
by syedhoque1994
Thanks for your help Bernd for helping to locate the "of me" code in the card script and replacing it with "of this stack", however I still notice that errors were detected in these lines of code: (put item 1 of location of button ("b" & pButton1) - \) and (put item 1 of location of button ("b" & pButton1) - \), though these lines of code are the same, errors are present when I run the code for any of the tiles and the shuffle button, can you find any such errors here?

Warm thanks

Syed

Re: 8-puzzle game

Posted: Wed Nov 23, 2011 10:06 pm
by bn
Syed,

I append my working version of the puzzle because I don't know why your version is not running. It would help if you would post the code using the Code tab. Especially since this part of code has soft wrapps, this means what seems to be two or more lines of code are actually one. The backslash at the end of the line indicates that the line is continued on the next line.

Try this version and tell us if it works. Don't change anything yet. Only after your have a working version.
puzzle8piece.livecode.zip
(3.46 KiB) Downloaded 258 times
KInd regards

Bernd

Re: 8-puzzle game

Posted: Fri Dec 02, 2011 6:00 pm
by syedhoque1994
My 30 day LiveCode trial has expired and I am now using RevMedia to develop my 8 Puzzle game. When I run the code and click on the Shuffle button, the whole program does not respond and I have to restart my machine and any changes made to the button scripts i.e. the tiles are not saved. Can You inform me of the solution that will get my porgram in working order, so that when I do click the shuffle button, the tiles will move in random areas of the board?

Syed Hoque

Re: 8-puzzle game

Posted: Sat Dec 03, 2011 6:43 pm
by bn
Hi Syed,

I don't own RevMedia and do not know why the stack does not work.

Did you change anything in the code? If so what?

From what I see you should be able to modify code and save it.

Kind regards

Bernd

Re: 8-puzzle game

Posted: Mon Dec 05, 2011 11:07 am
by syedhoque1994
When I click on the shuffle button, the whole program does not respond to any commands that I input and that I have to force quit LiveCode. Is there any solution to this problem to enable the game itself to be in working order?

Syed.

Re: 8-puzzle game

Posted: Mon Dec 05, 2011 11:50 am
by bn
Hi Syed,

could you look up what version of Revolution RevMedia has?

I just tested with Revolution version 3 and the stack I posted worked.

I suggest you re-download a fresh copy of the stack I posted above and try again.

Kind regards

Bernd

Re: 8-puzzle game

Posted: Mon Dec 05, 2011 1:29 pm
by syedhoque1994
Hi Bernd, just got my 8 Puzzle game in working order, wondering if the game can have a high score table and timer, If so could I please see the code for the score and timer fields?

Syed.