-- this is skeleton of memory game -- assumes all the sprites are put in order from 1 to 16 -- creates all list of all sprites to be used -- 2 copies of each member as in memory game -- temp duplicates all list -- then allocates randomly 1 from master list to each sprite -- puts them in list called grid -- deletes each as allocated fropm temp -- also empties lists choices, chosenum used lager -- also put 0 into total that will count when game is over -- temporarily assings all sprites to "mystery" member -- which is the back of all cards on shuffle global all,temp,grid, choices,choicenum,total choices =[] choicenum=[] total = 0 all = [#place1,#place1,#place2,#place2,#place3,#place3,#place4,#place4,\ #place5,#place5,#place6,#place6,#place7,#place7,#place8,#place8] temp = all grid=[] repeat with n = 1 to 16 c = temp.count r = random(c) r1 = getat(temp,r) r11 = string(r1) append (grid,r11) deleteat(temp,r) sprite(n).member="mystery" sprite(n).visible = true end repeat end -- this is the thing that checks what viewers have clicked on -- it is frame scirpt places in all frames to check what is happening -- checks first if the mouse is up (user clicked) -- the clickon tells what was last sprite clicked on -- clickon needs there to be some script on the member of that sprite -- can be empty do nothing script -- need to check if they have clicked on new sprite -- store last one in oldclick -- make sure new one is dirfferent -- if it is, then use that sprite number to see what -- the mystery card is underneath -- temporarily make that card show by setting sprite member to -- the visual assigned to that sprite in the shuffle -- add one to list choices that keeps track if they have picked 2 -- delay is routine to let the visual show for 1 second -- call the checkmatch routine to see if there is match on clicker global grid, choices,choicenum,oldclick if the mouseup = true then z = the clickon if z <> 0 and oldclick <> z then oldclick = z gridder = getat(grid,z) sprite(z).member = gridder updatestage append choices,gridder append choicenum,z if choices.count = 2 then beep delay 60 checkmatch end if end if end if end --choices contains the 2 members for the cards chose -- if they match then calls domatch routine -- if not match then calls donomatch routine on checkmatch global choices,choicenum a = getat(choices,1) b= getat(choices,2) if a = b then domatch else donomatch end if end -- if they match, get the sprites they represent -- make them invisible -- add 2 to the total -- empty out the choices and choicenum lists that keeps track of choices -- check if game over when total = 16 -- call the endgame routine if over on domatch global choices,choicenum,total z1 = getat (choicenum,1) z2 = getat (choicenum,2) sprite(z1).visible = false sprite(z2).visible = false choices=[] choicenum =[] total = total + 2 if total = 16 then endgame end --if they don't match, get the sprites they represent -- reset them to the mystery back image -- empty out the choices and choicenum lists that keeps track of choices on donomatch global choices,choicenum z1 = getat (choicenum,1) z2 = getat (choicenum,2) sprite(z1).member= "mystery" sprite(z2).member= "mystery" choices=[] choicenum =[] end --- do the endgame routine whaever it is -- here it justs starts over on endgame beep 5 shuffle -- end -- generic delay for q ticks (60ths of a second) -- starttimer resets internal variable call the timer -- the repeat loop keeps going while less than q -- when done, it exits and goes back to whatever routine called it on delay q starttimer repeat while the timer < q end repeat end