Ok, for a lazy Friday afternoon, here's some code I'm working on optimizing
(D8):
-- Check to see if we have a card from each list and if they match
-- The first card can be from list 1 or 2; the second card can also be
from list 1 or 2
if ((getPos(pList1, pBoard[pCard1]) > 0) AND (getPos(pList2,
pBoard[pCard2]) > 0) AND \
(getPos(pList1, pBoard[pCard1]) = getPos(pList2, pBoard[pCard2])))
OR \
((getPos(pList2, pBoard[pCard1]) > 0) AND (getPos(pList1,
pBoard[pCard2]) > 0) AND \
(getPos(pList2, pBoard[pCard1]) = getPos(pList1, pBoard[pCard2])))
then --they are a match
Yep, that's all one big bad boolean evaluation. What I'm doing:
It's a synonym matching game. I start off with the synonym pairs in
consecutive cast members, e.g., "bright" in member 1, "shiny" in member 2.
I read the cast member numbers into two lists, pList1 and pList2, so that
synonyms occupy the same position in the list. In the example above,
pList1[1] = 1, pList2[1] = 2. Or, a more complete list would be pList1 =
[1, 3, 5, 7, 9] and pList2 = [2, 4, 6, 8, 10].
I then randomly place the list members in pBoard, so pBoard ends up with
something like [4, 7, 1, 3, 9, 6...]
The user clicks on any two sprites, whose member numbers I store into
pCard1 and pCard2. I then check for a position match using the code at the
beginning.
I'm going to work on optimizing it this afternoon. In the meantime, I
thought this would give some of you other high-power minds out there a
little food for thought :-)
By the way, a tip of the hat to Gary Rosenzweig, whose "memory" game from
"Advanced Lingo for Games" inspired this.
Cordially,
Kerry Thompson
Learning Network
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]