Memory example

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Memory example

Post by Klaus »

Hi friends,

found some very old stacks of mine on my HD today and thought I could share them here.

In the ZIP archive you will find two stacks:
1. simple_memory1.livecode
I used this stack for a demonstration at the European Revolution Conference (ERC) in Malta in 2004.
(For the youngsters, the former names of "Livecode" were "Runtime Revolution" and later just "Revolution"!)
It explains the LOGICS behind a memory game, so you understand what is going on in my scripting.

2. memory1.livecode
An actual memory game with timer etc.
The script can be used with ALL kind of memory games from two tiles (rather boring 8) ) to an unlimited number of tiles.

Take a look and enjoy! :D
I saved the stacks in 2.4 format, so everyone should be able to open them.

Thanks to Klaus Junghans for the great cartoon pics!


Best

Klaus
Attachments
memory.zip
(188.75 KiB) Downloaded 1023 times
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Memory example

Post by bogs »

Interesting stuff Klaus. I did find I had one square with no mate (all others were cleared off), but still very nicely done :)
Image
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Memory example

Post by Klaus »

Strange, I played the memory a couple of times before I posted it here and all images where in place!?
If it happens again, could you please take a look if the button with the missing icon HAS infact an assigned icon?

Thanks!
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Memory example

Post by bogs »

I would be happy (if it happens again) to do anything I can to assist you Klaus :)

Nothing was missing a picture, btw, all the buttons (including the last one on the board) had pictures. The part that was missing was any more buttons, so I couldn't mate the last button to anything. I did find this doesn't happen all the time (6 attempts this morning), so maybe it was a fluke.

Joke time -
A programmer, an engineer, and a manager were riding through the Alps, when the brakes in their car failed and they careened down the mountains roads, nearly going over the edge several times before coming to a stop where they all got out of the car.

The manager said "We need to call a meeting, define our objectives, come to a solution, and initiate our plan! Who brought doughnuts and coffee?"

The engineer said "Look, I have my swiss army knife with me, I can rebuild the braking system in about 10 minutes and we can be on our way."

The programmer looks at both of them and says "Well, before we do anything else, I think we should drive it a little longer and see if it happens again, it might have just been a bug..."
Image
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Memory example

Post by Klaus »

You mean you ended with on ONE button left?
Well, that MUST be a fluke :D
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Memory example

Post by bogs »

Yah, that is my thinking as well. I haven't been able to reproduce it no matter how far I drove :D
Image
ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: Memory example

Post by ValiantCuriosity »

Klaus,
This is nice. Thank you for posting it. I have a memory game in my current app-->sort of a little learning add on. It was done in javascript.It is not really necessary in the app, but some people enjoy it. Memory games were one of the pieces of the puzzle that I needed to see in order to find out if I could program a piece of one of my apps in LC.

BTW, I think that you have used very pretty colors. The characters are cute too.

Is it OK to dissect and also, maybe use some of the coding in my app? That is, if I need to use it? I might also like to ask questions (what else is new?) about the code.

So far, other than my lack of languages, the scripting makes perfect sense. :D

gezeigt = shown
Babelfish is my friend. Wish I could have been born a savant in many areas. Language is one. Alas...

-Rachel
May I never be cured of my curiosity! :D
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Memory example

Post by Klaus »

Hi Rahel,
Is it OK to dissect and also, maybe use some of the coding in my app? That is, if I need to use it?
just send me a gazillion bucks and there you go! :D
No, just kidding, do whatever you want to with the code.
I might also like to ask questions (what else is new?) about the code.
Sure, just ask.

Best

Klaus
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Memory example

Post by bogs »

Klaus wrote: Sun Feb 24, 2019 10:51 pm just send me a gazillion bucks and there you go!
It is a DEAL! (Might take a moment to get it all into the crate though)
Image
Image
ValiantCuriosity
Posts: 128
Joined: Thu Jun 30, 2016 3:08 am

Re: Memory example

Post by ValiantCuriosity »

@Bogs,
You are something else! :lol: :lol: :lol:

Now, on to another question:

In the game simple_memory1 stack, I see:

Code: Select all

on preopenstack
  ##
end preopenstack

on openstack
  ##
end openstack

on preopencard
   set the visible of fld "textd" to (the sprache of this stack = "d") //sprache means language in English
end preopencard

on opencard
  ##
end opencard
Should I be using empty commands like this in LC? I don't understand a lot about the memory game yet, but I did wonder about these empty commands in the mainStack.

:?:
-Rachel
May I never be cured of my curiosity! :D
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Memory example

Post by Klaus »

Hi Rachel,

to be honest, I have no idea why I put them there!?
That were my first steps in Metacard almost 20 years ago... 8)


Best

Klaus
bogs
Posts: 5480
Joined: Sat Feb 25, 2017 10:45 pm

Re: Memory example

Post by bogs »

Well, there are 3 reasons you might use a message handler (that I can think of).
1. You need something done when that message fires...
2. You are *planning* to do something when that message fires, but haven't worked out what exactly (same as inserting a TODO clause)...
3. You want to block that message from going farther.
4. There may be reasons I don't know yet :P

Since these are in the 'mainStack', it doesn't make sense to think they are 'blocking the messages', the message if it got this far is one step from the engine anyway (of course, there could still be reasons to stop it, just less likely at this point).

Now, I wasn't there when Klaus wrote this, and he has said that it was towards the beginning of his use of the language. Looking at the handlers listed, my guess would be he was trying that script in those handlers to see where it would work best, if it didn't work out as desired it was commented and moved, and finally settled on the 'preopencard' handler.

I could be WAY off on that guess, though :D
Image
Post Reply