Dead end with Memo game

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Gurki
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 27
Joined: Wed Jul 10, 2013 6:34 pm

Dead end with Memo game

Post by Gurki » Sun May 03, 2020 8:53 pm

For many years Cyril Pruszko used LiveCode in the school until his retirement. He has documented a large part of his lessons on the Internet; a great treasure: https://sites.google.com/a/pgcps.org/livecode/.
I have now come across an exercise there, where I am stuck (and it's just one of the few that are only partially documented).

The Match Game*. The idea is that the children check and complete the given code. Either it is really extremely difficult (which I don't believe) or I am struck by blindness or after x attempts I just go round in circles. Has anyone here ever programmed such a game and could help me? (There is a similar game here in the forum with code to download, but it has a completely different approach behind it). Maybe I just didn't try enough, but computer science is one of twelve school subjects I have to teach, and now with home schooling (a.k.a video conferencing), preparation takes twice as long and I still have to coach the overstrained parents.

Stay in good health and best regards,
G.

*https://sites.google.com/a/pgcps.org/li ... e/matching
Start of the Logic
See if you can follow the logic of the game as it is written below. This is a start. It may not work and it will give you some practice debugging. The rest of the code also has to be written...

adding the code to the card:

Code: Select all

                         global card1, card2
                         global numLeft, numClicked

                         on openCard
                            put empty into card1
                            put empty into card2
                            put empty into numClicked
                            put 12 into numLeft
                        end openCard
               
                        on mouseUp
                           if the first char of the short name of the target is "b" then
                                if Card1 is empty then
                                    turnCardOver
                                    put currCard into card1
                                else
                                    if card2 is empty
                                         turnCardOver
                                        put currCard into card2
                                        if card1 is equal to card2 then
                                                subtract 2 from numLeft
                                               if numLeft = 0 then
                                                        answer "Game over"
                                               end if
                                        else
                                               turnCardBack card1
                                               turnCardBack card2
                                       end if                       
                             end if   
                         end if   
                     end mouseUp
      
                  command turnCardOver
                            hide the target
                            put the second char of the short name of the target into currCard
                            put "A" & currCard into x
                            show button x
                  end turnCardOver

                 command turnCardBack cardNum
                          hide button "A" & cardNum
                          show button  "B" & cardNum
                          Add 1 to numLeft
                 end turnCardBack


Now test the code, debug it and add additional logic to make the game better
see https://sites.google.com/a/pgcps.org/li ... e/matching for further details

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Dead end with Memo game

Post by Mark » Sat May 09, 2020 1:25 pm

This script needs a teacher that prepared the kids and makes them realize what to look for. An experienced coder can make a game from this script within an hour. The approach is correct, but it contains a few small problems. Try to compile the script and solve the errors you see. Then try to make it work and adjust as needed to make it work.

Markl
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 12010
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Dead end with Memo game

Post by Klaus » Sat May 09, 2020 1:53 pm


Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5145
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Dead end with Memo game

Post by Mark » Sat May 09, 2020 2:46 pm

Yes, but that discussion is about a different memory game and not specifically about this (above ⬆) script.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Klaus
Posts: 12010
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Dead end with Memo game

Post by Klaus » Sat May 09, 2020 2:47 pm

Ha, true that! :D

kdjanz
Posts: 227
Joined: Fri Dec 09, 2011 12:12 pm
Location: Fort Saskatchewan, AB Canada

Re: Dead end with Memo game

Post by kdjanz » Mon May 11, 2020 4:44 am

Hi Gurki

Your post intrigued me as a LiveCode beginner, so I decided to try something like that for my grandson.

I have attached my finished version for you to take a look at. I changed quite a bit of their code because I added a few enhancements to allow various kinds of game play.

Have fun and enjoy. If you have questions, feel free to follow up here.

Kelly
Sam's game.livecode.zip
(4.19 KiB) Downloaded 36 times

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”