home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM da Folhinha / cdrom-folhinha.ISO / puzzle.dir / 00820.ls < prev    next >
Encoding:
Text File  |  1997-04-07  |  7.1 KB  |  295 lines

  1. on startMovie
  2.   global posicao, lateral, pode, locali, quadro, pedras, menulat, final, inicio, programa, aparece
  3.   set the exitLock to 1
  4.   set aparece to 0
  5.   set programa to 2
  6.   puppetSprite(48, 1)
  7.   set the memberNum of sprite 48 to the number of member 19 of castLib "FOLHINHA.SRD"
  8.   set inicio to 0
  9.   set final to 26
  10.   set pedras to 0
  11.   set pode to 1
  12.   set lateral to 1
  13.   set quadro to [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  14.   set posicao to [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  15.   set locali to [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  16.   set total to 4
  17.   set menulat to posicao
  18. end
  19.  
  20. on stopMovie
  21.   global aparece, programa
  22.   set aparece to 0
  23.   set programa to 0
  24.   puppetSprite(48, 0)
  25. end
  26.  
  27. on gerapuzzle
  28.   global posicao
  29.   repeat with i = 1 to 25
  30.     set flagp to 0
  31.     repeat while flagp = 0
  32.       set nume to random(25)
  33.       set j to 1
  34.       set flag2 to 1
  35.       repeat while (j <= i) and (flag2 = 1)
  36.         set ajuda to getAt(posicao, j)
  37.         if ajuda = nume then
  38.           set flag2 to 0
  39.         end if
  40.         set j to j + 1
  41.       end repeat
  42.       if flag2 = 1 then
  43.         set flagp to 1
  44.         setAt(posicao, i, nume)
  45.       end if
  46.     end repeat
  47.   end repeat
  48. end
  49.  
  50. on geracast
  51.   global posicao, qualpuzz, numpuzz
  52.   repeat with i = 1 to 25
  53.     set the castNum of sprite (9 + i) to getAt(posicao, i) + qualpuzz
  54.   end repeat
  55.   set the castNum of sprite 9 to numpuzz + 30
  56.   set the castNum of sprite 36 to numpuzz
  57. end
  58.  
  59. on checa qu
  60.   global locali
  61.   set nloc to getAt(locali, qu - 9)
  62.   return nloc
  63. end
  64.  
  65. on sobe
  66.   global lateral, pode, final
  67.   if pode = 1 then
  68.     lche()
  69.     if lateral <= (final - 5) then
  70.       set lateral to lateral + 1
  71.       if not checa(8 + lateral) then
  72.         set the locV of sprite (8 + lateral) to -300
  73.         set the moveableSprite of sprite (8 + lateral) to 0
  74.       end if
  75.       repeat with i = 1 to 4
  76.         if not checa(8 + lateral + i) then
  77.           set the locV of sprite (8 + i + lateral) to 70 + (i * 85)
  78.           set the moveableSprite of sprite (8 + i + lateral) to 1
  79.           set the locH of sprite (8 + i + lateral) to 583
  80.         end if
  81.       end repeat
  82.     else
  83.       beep()
  84.     end if
  85.   end if
  86.   set the locV of sprite 8 to -1000
  87.   updateStage()
  88. end
  89.  
  90. on desce
  91.   global lateral, pode, inicio
  92.   if pode = 1 then
  93.     lche()
  94.     if lateral > (inicio + 1) then
  95.       set lateral to lateral - 1
  96.       if not checa(13 + lateral) then
  97.         set the locV of sprite (13 + lateral) to -300
  98.         set the moveableSprite of sprite (13 + lateral) to 0
  99.       end if
  100.       repeat with i = 1 to 4
  101.         if not checa(8 + i + lateral) then
  102.           set the locV of sprite (8 + i + lateral) to 70 + (i * 85)
  103.           set the moveableSprite of sprite (8 + i + lateral) to 1
  104.           set the locH of sprite (8 + i + lateral) to 583
  105.         end if
  106.       end repeat
  107.     else
  108.       beep()
  109.     end if
  110.   end if
  111.   set the locV of sprite 8 to -1000
  112.   updateStage()
  113. end
  114.  
  115. on lche
  116.   global locali, inicio, final
  117.   set nn to 1
  118.   set i to 0
  119.   repeat while nn = 1
  120.     set i to i + 1
  121.     set nn to getAt(locali, i)
  122.   end repeat
  123.   set inicio to i - 1
  124.   set nn to 1
  125.   set i to 26
  126.   repeat while nn = 1
  127.     set i to i - 1
  128.     set nn to getAt(locali, i)
  129.   end repeat
  130.   set final to i + 1
  131. end
  132.  
  133. on voltar
  134.   global qspr, lvant, lhant, locali, pedras
  135.   puppetSound(0)
  136.   updateStage()
  137.   puppetSound("errado")
  138.   updateStage()
  139.   setAt(locali, qspr - 9, 0)
  140.   if lvant < 0 then
  141.     set lvant to -200
  142.   end if
  143.   if lvant > 480 then
  144.     set lvant to 600
  145.   end if
  146.   set lv to the locV of sprite qspr
  147.   set lh to the locH of sprite qspr
  148.   set pedras to pedras - 1
  149.   variapeca(lv, lh, lvant, lhant, qspr)
  150. end
  151.  
  152. on checgeral
  153.   global quadro
  154.   set ff to 1
  155.   repeat with i = 1 to 5
  156.     repeat with j = 1 to 5
  157.       set linha to ((i - 1) * 5) + j
  158.       if getAt(quadro, linha) <> linha then
  159.         set ff to 0
  160.       end if
  161.     end repeat
  162.   end repeat
  163.   if ff = 1 then
  164.     set the locH of sprite 36 to 233
  165.     go(marker(1))
  166.   end if
  167. end
  168.  
  169. on menul qt
  170.   global menulat, menupos, inicio, final
  171.   set ii to 1
  172.   set menupos to 0
  173.   repeat while (ii <= 25) and (menupos = 0)
  174.     set mm to getAt(menulat, ii)
  175.     if mm = qt then
  176.       set menupos to ii
  177.     end if
  178.     set ii to ii + 1
  179.   end repeat
  180. end
  181.  
  182. on variapeca rv1, rh1, rv2, rh2, spr
  183.   set difv to abs(rv1 - rv2)
  184.   set difh to abs(rh1 - rh2)
  185.   set contv to 0
  186.   set conth to 0
  187.   repeat while (rv1 <> rv2) or (rh1 <> rh2)
  188.     if rv1 > rv2 then
  189.       set contv to contv + 3
  190.       if contv > difv then
  191.         set contv to contv - 2
  192.         set rv1 to rv1 - 1
  193.       else
  194.         set rv1 to rv1 - 3
  195.       end if
  196.     end if
  197.     if rv1 < rv2 then
  198.       set contv to contv + 3
  199.       if contv > difv then
  200.         set contv to contv - 2
  201.         set rv1 to rv1 + 1
  202.       else
  203.         set rv1 to rv1 + 3
  204.       end if
  205.     end if
  206.     if rh1 > rh2 then
  207.       set conth to conth + 3
  208.       if conth > difh then
  209.         set rh1 to rh1 - 1
  210.         set conth to conth - 2
  211.       else
  212.         set rh1 to rh1 - 3
  213.       end if
  214.     end if
  215.     if rh1 < rh2 then
  216.       set conth to conth + 3
  217.       if conth > difh then
  218.         set rh1 to rh1 + 1
  219.         set conth to conth - 2
  220.       else
  221.         set rh1 to rh1 + 3
  222.       end if
  223.     end if
  224.     set the locV of sprite spr to rv1
  225.     set the locH of sprite spr to rh1
  226.     updateStage()
  227.   end repeat
  228. end
  229.  
  230. on acabar
  231.   global quadro, menupos
  232.   set qr to [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
  233.   repeat with i = 1 to 5
  234.     repeat with j = 1 to 5
  235.       set ij to ((i - 1) * 5) + j
  236.       set mr to getAt(quadro, ij)
  237.       if mr <> 0 then
  238.         setAt(qr, mr, mr)
  239.         if mr <> ij then
  240.           menul(mr)
  241.           set vv to the locV of sprite (menupos + 9)
  242.           set vh to the locH of sprite (menupos + 9)
  243.           set xh to (mr mod 5) - 1
  244.           if xh = -1 then
  245.             set xh to 4
  246.           end if
  247.           set xh to (xh * 80) + 73
  248.           set xv to (integer((mr - 1) / 5) * 80) + 79
  249.           variapeca(((i - 1) * 80) + 79, ((j - 1) * 80) + 73, xv, xh, menupos + 9)
  250.         end if
  251.       end if
  252.     end repeat
  253.   end repeat
  254.   set quadro to qr
  255. end
  256.  
  257. on arrumar
  258.   global qspr, numv, numh, locali, quadro, rv, rh, pedras, qualpuzz
  259.   puppetSound(0)
  260.   updateStage()
  261.   puppetSound("certo")
  262.   updateStage()
  263.   setAt(locali, qspr - 9, 1)
  264.   set lv to the locV of sprite qspr
  265.   set lh to the locH of sprite qspr
  266.   set posh to 73
  267.   set numv to 1
  268.   set numh to 1
  269.   set posv to 79
  270.   repeat while (lv < (posv - 40)) or (lv > (posv + 40))
  271.     set posv to posv + 80
  272.     set numv to numv + 1
  273.   end repeat
  274.   repeat while (lh < (posh - 40)) or (lh > (posh + 40))
  275.     set posh to posh + 80
  276.     set numh to numh + 1
  277.   end repeat
  278.   set the locV of sprite qspr to posv
  279.   set the locH of sprite qspr to posh
  280.   updateStage()
  281.   set qq to ((numv - 1) * 5) + numh
  282.   if getAt(quadro, qq) <> 0 then
  283.     if rv = -1 then
  284.       voltar()
  285.     else
  286.       set the locV of sprite qspr to 79 + ((rv - 1) * 80)
  287.       set the locH of sprite qspr to 73 + ((rh - 1) * 80)
  288.       setAt(quadro, ((rv - 1) * 5) + rh, the castNum of sprite qspr - qualpuzz)
  289.     end if
  290.   else
  291.     setAt(quadro, qq, the castNum of sprite qspr - qualpuzz)
  292.   end if
  293.   updateStage()
  294. end
  295.