home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / CheckersSparse.dxr / 00011.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  2.8 KB  |  99 lines

  1. on redrawBoard
  2.   global boardData, tileSO, tileSize, pathIndex
  3.   wSprite = tileSO
  4.   repeat with whichY = 1 to count(boardData)
  5.     repeat with whichX = 1 to count(boardData[1])
  6.       wSprite = wSprite + 1
  7.       tBit = boardData[whichY][whichX]
  8.       if count(pathIndex) > 0 then
  9.         if pathIndex[1] = point(whichX, whichY) then
  10.           affix = " Lit"
  11.         else
  12.           affix = " Dark"
  13.         end if
  14.       else
  15.         affix = " Dark"
  16.       end if
  17.       case tBit of
  18.         #Na:
  19.           sprite(wSprite).visible = 0
  20.         #Rp:
  21.           set the member of sprite wSprite to "Red Piece" & affix
  22.           sprite(wSprite).visible = 1
  23.         #Bp:
  24.           set the member of sprite wSprite to "Black Piece" & affix
  25.           sprite(wSprite).visible = 1
  26.         #Rk:
  27.           set the member of sprite wSprite to "Red King" & affix
  28.           sprite(wSprite).visible = 1
  29.         #Bk:
  30.           set the member of sprite wSprite to "Black King" & affix
  31.           sprite(wSprite).visible = 1
  32.         otherwise:
  33.           sprite(wSprite).visible = 0
  34.       end case
  35.       pLoc = point(whichX * tileSize, whichY * tileSize) + the loc of sprite tileSO - (tileSize / 2)
  36.       set the loc of sprite wSprite to pLoc
  37.       set the ink of sprite wSprite to 31
  38.     end repeat
  39.   end repeat
  40. end
  41.  
  42. on initializeBoard
  43.   global boardData, tileSO, tileSize, totalpieces
  44.   squareTiles = 10
  45.   tileSize = the width of sprite tileSO / squareTiles
  46.   wSprite = tileSO
  47.   boardData = []
  48.   repeat with whichY = 1 to squareTiles
  49.     oneLiner = []
  50.     repeat with whichX = 1 to squareTiles
  51.       wSprite = wSprite + 1
  52.       puppetSprite(wSprite, 1)
  53.       case 1 of
  54.         1:
  55.           if ((whichY + whichX) mod 2) = 0 then
  56.             if whichY <= 2 then
  57.               tBit = #Rp
  58.             else
  59.               if whichY >= 9 then
  60.                 tBit = #Bp
  61.               else
  62.                 tBit = #Na
  63.               end if
  64.             end if
  65.           else
  66.             tBit = #Na
  67.           end if
  68.         2:
  69.           tBit = [#Bp, #Rp, #Na, #Na][random(4)]
  70.         3:
  71.           tBit = #Na
  72.       end case
  73.       add(oneLiner, tBit)
  74.       case tBit of
  75.         #Na:
  76.           sprite(wSprite).visible = 0
  77.         #Rp:
  78.           set the member of sprite wSprite to "red Piece"
  79.           sprite(wSprite).visible = 1
  80.         #Bp:
  81.           set the member of sprite wSprite to "Black Piece"
  82.           sprite(wSprite).visible = 1
  83.       end case
  84.       pLoc = point(whichX * tileSize, whichY * tileSize) + the loc of sprite tileSO - (tileSize / 2)
  85.       set the loc of sprite wSprite to pLoc
  86.       set the ink of sprite wSprite to 31
  87.     end repeat
  88.     add(boardData, oneLiner)
  89.   end repeat
  90.   totalpieces = 0
  91.   repeat with whichX = 1 to count(boardData)
  92.     repeat with whichY = 1 to count(boardData)
  93.       if boardData[whichY][whichX] = #Bp then
  94.         totalpieces = totalpieces + 1
  95.       end if
  96.     end repeat
  97.   end repeat
  98. end
  99.