home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1996 August / WPCAUG96.ISO / multi / singing / baritone.dxr / 00024_Pile.ls < prev    next >
Encoding:
Text File  |  1996-06-12  |  1.8 KB  |  72 lines

  1. property pileSize, pileList, firstSocket, x, y
  2.  
  3. on birth me, socket, px, py
  4.   set the firstSocket of me to socket
  5.   set the x of me to px
  6.   set the y of me to py
  7.   reset(me)
  8.   return me
  9. end
  10.  
  11. on push me, castName
  12.   if the pileSize of me = maxPileSize() then
  13.     beep()
  14.     put "error: pile full"
  15.   else
  16.     append(the pileList of me, castName)
  17.     set the pileSize of me to the pileSize of me + 1
  18.     set spriteNo to the firstSocket of me + the pileSize of me - 1
  19.     set totalDepthOffset to PageDepthOffset() * (the pileSize of me - 1)
  20.     InstallBitMap(spriteNo, castName, the x of me, the y of me + totalDepthOffset)
  21.   end if
  22. end
  23.  
  24. on pop me
  25.   if the pileSize of me = 0 then
  26.     beep()
  27.     put "error: Popping from empty pile"
  28.     set sendBack to EMPTY
  29.   else
  30.     set sendBack to getAt(the pileList of me, the pileSize of me)
  31.     deleteAt(the pileList of me, the pileSize of me)
  32.     set spriteNo to the firstSocket of me + the pileSize of me - 1
  33.     KillBitMap(spriteNo)
  34.     set the pileSize of me to the pileSize of me - 1
  35.   end if
  36.   return sendBack
  37. end
  38.  
  39. on TopPage me
  40.   if the pileSize of me = 0 then
  41.     set sendBack to EMPTY
  42.   else
  43.     set sendBack to getAt(the pileList of me, the pileSize of me)
  44.     deleteAt(the pileList of me, the pileSize of me)
  45.   end if
  46.   return sendBack
  47. end
  48.  
  49. on TopSprite me
  50.   set theSpr to -1
  51.   if the pileSize of me > 0 then
  52.     set theSpr to the firstSocket of me + the pileSize of me - 1
  53.   end if
  54.   return theSpr
  55. end
  56.  
  57. on reset me
  58.   set the pileList of me to []
  59.   set the pileSize of me to 0
  60.   repeat with i = 1 to maxPileSize()
  61.     set spriteNo to the firstSocket of me + i - 1
  62.     KillBitMap(spriteNo)
  63.   end repeat
  64. end
  65.  
  66. on FreeSprites me
  67.   repeat with i = 1 to maxPileSize()
  68.     set spriteNo to the firstSocket of me + i - 1
  69.     puppetSprite(spriteNo, 0)
  70.   end repeat
  71. end
  72.