home *** CD-ROM | disk | FTP | other *** search
- property spriteNum, pSpritePosition, pDiffX, pDiffY, pDirection, pRect, pRow, pColomn, pOverlay, pPickUpPoint, pTileProperty
- global gCurrentLevel, gSelectedTile, gTileArray, gArrayWidth, gArrayHeight, gTileWidth, gTileHeight, gTopLeftPoint, gNumTiles, gColorRequired
-
- on beginSprite me
- case spriteNum of
- 10:
- sprite(10).loc = point(139, 191)
- 11:
- sprite(11).loc = point(426, 187)
- 12:
- sprite(12).loc = point(245, 124)
- 13:
- sprite(13).loc = point(415, 342)
- 14:
- sprite(14).loc = point(320, 353)
- 15:
- sprite(15).loc = point(358, 125)
- 16:
- sprite(16).loc = point(283, 182)
- 17:
- sprite(17).loc = point(205, 264)
- 18:
- sprite(18).loc = point(67, 135)
- 19:
- sprite(19).loc = point(68, 263)
- 20:
- sprite(20).loc = point(282, 290)
- 21:
- sprite(21).loc = point(182, 348)
- 22:
- sprite(22).loc = point(363, 246)
- 23:
- sprite(23).loc = point(88, 351)
- end case
- if (spriteNum - 9) > gNumTiles then
- sprite(spriteNum).loc = point(800, 800)
- sprite(spriteNum + 23).loc = point(800, 800)
- exit
- end if
- setTileProperty()
- pRow = 1
- pColomn = 1
- dropTile()
- pRect = sprite(spriteNum).rect
- pDirection = 1
- pSpritePosition = point(sprite(spriteNum).locH, sprite(spriteNum).locV)
- end
-
- on resetTile me
- end
-
- on setTileProperty me
- case member(sprite(spriteNum).member).name of
- "hex1":
- sprite(spriteNum + 23).member = "1"
- pTileProperty = [2, 3, 1, 1, 3, 2]
- "hex2":
- sprite(spriteNum + 23).member = "2"
- pTileProperty = [1, 3, 1, 2, 3, 2]
- "hex3":
- sprite(spriteNum + 23).member = "3"
- pTileProperty = [2, 1, 3, 3, 2, 1]
- "hex4":
- sprite(spriteNum + 23).member = "4"
- pTileProperty = [1, 2, 3, 3, 1, 2]
- "hex5":
- sprite(spriteNum + 23).member = "5"
- pTileProperty = [2, 2, 1, 1, 3, 3]
- "hex6":
- sprite(spriteNum + 23).member = "6"
- pTileProperty = [2, 2, 3, 3, 1, 1]
- "hex7":
- sprite(spriteNum + 23).member = "7"
- pTileProperty = [2, 1, 3, 3, 1, 2]
- "hex8":
- sprite(spriteNum + 23).member = "8"
- pTileProperty = [2, 1, 2, 3, 1, 3]
- "hex9":
- sprite(spriteNum + 23).member = "9"
- pTileProperty = [2, 3, 1, 1, 2, 3]
- "hex10":
- sprite(spriteNum + 23).member = "10"
- pTileProperty = [3, 2, 1, 1, 3, 2]
- "hex11":
- sprite(spriteNum + 23).member = "11"
- pTileProperty = [1, 2, 3, 3, 2, 1]
- "hex12":
- sprite(spriteNum + 23).member = "12"
- pTileProperty = [1, 2, 1, 3, 2, 3]
- "hex13":
- sprite(spriteNum + 23).member = "13"
- pTileProperty = [1, 3, 2, 2, 1, 3]
- "hex14":
- sprite(spriteNum + 23).member = "14"
- pTileProperty = [3, 1, 2, 2, 3, 1]
- end case
- end
-
- on mouseUp me
- if the frame > 15 then
- exit
- end if
- if gSelectedTile <> spriteNum then
- exit
- end if
- dropTile()
- end
-
- on mouseDown me
- if the frame > 15 then
- exit
- end if
- pPickUpPoint = point(sprite(spriteNum).locH, sprite(spriteNum).locV)
- gSelectedTile = spriteNum
- pDiffX = sprite(spriteNum).locH - the mouseH
- pDiffY = sprite(spriteNum).locV - the mouseV
- sprite(spriteNum).locZ = 50
- sprite(spriteNum + 23).locZ = 51
- puppetSound(3, "pickup piece")
- end
-
- on moveTile
- if the frame > 15 then
- exit
- end if
- if gSelectedTile <> spriteNum then
- exit
- end if
- pRect = rect(mouseH() - (sprite(spriteNum).width / 2) + pDiffX, mouseV() - (sprite(spriteNum).height / 2) + pDiffY, mouseH() + (sprite(spriteNum).width / 2) + pDiffX, mouseV() + (sprite(spriteNum).height / 2) + pDiffY)
- revolvePenatration()
- sprite(spriteNum).loc = point(pRect[1] + (sprite(spriteNum).width / 2), pRect[2] + (sprite(spriteNum).height / 2))
- if sprite(spriteNum).locH < (gTopLeftPoint[1] + 2) then
- sprite(spriteNum).locH = gTopLeftPoint[1] + 2
- end if
- if sprite(spriteNum).locV < gTopLeftPoint[2] then
- sprite(spriteNum).locV = gTopLeftPoint[2]
- end if
- if sprite(spriteNum).locH > (gTopLeftPoint[1] + (gArrayWidth * gTileWidth) - gTileWidth - 5) then
- sprite(spriteNum).locH = gTopLeftPoint[1] + (gArrayWidth * gTileWidth) - gTileWidth - 5
- end if
- if sprite(spriteNum).locV > (gTopLeftPoint[2] + (gArrayHeight * gTileHeight) - gTileHeight - 5) then
- sprite(spriteNum).locV = gTopLeftPoint[2] + (gArrayHeight * gTileHeight) - gTileHeight - 5
- end if
- sprite(spriteNum + 23).loc = sprite(spriteNum).loc
- end
-
- on dropTile
- if the frame > 15 then
- exit
- end if
- sprite(spriteNum).locZ = spriteNum
- sprite(spriteNum + 23).locZ = spriteNum + 23
- gSelectedTile = 0
- diffX = (sprite(spriteNum).locH - gTopLeftPoint[1]) mod gTileWidth
- if diffX > (gTileWidth / 2) then
- sprite(spriteNum).locH = sprite(spriteNum).locH - diffX + gTileWidth
- else
- sprite(spriteNum).locH = sprite(spriteNum).locH - diffX
- end if
- theColomn = integer((sprite(spriteNum).locH - gTopLeftPoint[1]) / gTileWidth)
- if not ((theColomn mod 2) = 0) then
- diffY = (sprite(spriteNum).locV - gTopLeftPoint[2]) mod gTileHeight
- if diffY > (gTileHeight / 2) then
- sprite(spriteNum).locV = sprite(spriteNum).locV - diffY + gTileHeight
- else
- sprite(spriteNum).locV = sprite(spriteNum).locV - diffY
- end if
- else
- diffY = (sprite(spriteNum).locV - (gTileHeight / 2) - gTopLeftPoint[2]) mod gTileHeight
- if diffY > (gTileHeight / 2) then
- sprite(spriteNum).locV = sprite(spriteNum).locV - diffY + gTileHeight
- else
- sprite(spriteNum).locV = sprite(spriteNum).locV - diffY
- end if
- end if
- theRow = integer((sprite(spriteNum).locV - gTopLeftPoint[2]) / gTileHeight) + 1
- theColomn = theColomn + 1
- updateStage()
- pRect = sprite(spriteNum).rect
- sprite(spriteNum + 23).loc = sprite(spriteNum).loc
- if (pRow = theRow) and (pColomn = theColomn) then
- puppetSound(3, "rotate")
- rotateHex()
- else
- puppetSound(3, "drop piece")
- if gTileArray[theRow][theColomn] > 0 then
- sprite(spriteNum).loc = pPickUpPoint
- sprite(spriteNum + 23).loc = pPickUpPoint
- else
- gTileArray[pRow][pColomn] = 0
- pRow = theRow
- pColomn = theColomn
- gTileArray[pRow][pColomn] = spriteNum
- end if
- end if
- if checkIfPuzzleSolved() = 1 then
- if gCurrentLevel >= 10 then
- puppetSound(1, "win")
- go(19)
- else
- puppetSound(1, "levelcomplete10")
- go(34)
- end if
- end if
- end
-
- on revolvePenatration me
- if checkIfIntersection() = 1 then
- end if
- end
-
- on rotateHex me
- pDirection = pDirection + 1
- if pDirection > 6 then
- pDirection = 1
- end if
- case pDirection of
- 1:
- sprite(spriteNum + 23).rotation = 0
- 2:
- sprite(spriteNum + 23).rotation = 60
- 3:
- sprite(spriteNum + 23).rotation = 120
- 4:
- sprite(spriteNum + 23).rotation = 180
- 5:
- sprite(spriteNum + 23).rotation = 240
- 6:
- sprite(spriteNum + 23).rotation = 300
- end case
- temp = pTileProperty[count(pTileProperty)]
- deleteAt(pTileProperty, count(pTileProperty))
- addAt(pTileProperty, 1, temp)
- updateStage()
- end
-
- on checkIfIntersection me
- bool = 0
- repeat with counter = 10 to 9 + gNumTiles
- if myIntersection(pRect, counter) then
- if spriteNum <> counter then
- bool = 1
- end if
- end if
- end repeat
- return bool
- end
-
- on getHexProperty
- return duplicate(pTileProperty)
- end
-
- on checkIfPuzzleSolved
- repeat with counterX = 1 to gArrayWidth
- repeat with counterY = 1 to gArrayHeight
- if checkOutOfBounds(counterX, counterY) = 1 then
- if gTileArray[counterY][counterX] > 0 then
- firstX = counterX
- firstY = counterY
- checkX = counterX - 1
- if not ((counterX mod 2) = 0) then
- checkY = counterY
- else
- checkY = counterY - 1
- end if
- if checkOutOfBounds(checkX, checkY) = 1 then
- Prop = sendSprite(gTileArray[checkY][checkX], #getHexProperty)
- checkProp = sendSprite(gTileArray[counterY][counterX], #getHexProperty)
- if Prop[4] <> checkProp[1] then
- return 0
- end if
- end if
- checkY = counterY - 1
- checkX = counterX
- if checkOutOfBounds(checkX, checkY) = 1 then
- Prop = sendSprite(gTileArray[checkY][checkX], #getHexProperty)
- checkProp = sendSprite(gTileArray[counterY][counterX], #getHexProperty)
- if Prop[5] <> checkProp[2] then
- return 0
- end if
- end if
- checkX = counterX + 1
- if not ((counterX mod 2) = 0) then
- checkY = counterY
- else
- checkY = counterY - 1
- end if
- if checkOutOfBounds(checkX, checkY) = 1 then
- Prop = sendSprite(gTileArray[checkY][checkX], #getHexProperty)
- checkProp = sendSprite(gTileArray[counterY][counterX], #getHexProperty)
- if Prop[6] <> checkProp[3] then
- return 0
- end if
- end if
- checkX = counterX + 1
- if not ((counterX mod 2) = 0) then
- checkY = counterY + 1
- else
- checkY = counterY
- end if
- if checkOutOfBounds(checkX, checkY) = 1 then
- Prop = sendSprite(gTileArray[checkY][checkX], #getHexProperty)
- checkProp = sendSprite(gTileArray[counterY][counterX], #getHexProperty)
- if Prop[1] <> checkProp[4] then
- return 0
- end if
- end if
- checkY = counterY + 1
- checkX = counterX
- if checkOutOfBounds(checkX, checkY) = 1 then
- Prop = sendSprite(gTileArray[checkY][checkX], #getHexProperty)
- checkProp = sendSprite(gTileArray[counterY][counterX], #getHexProperty)
- if Prop[2] <> checkProp[5] then
- return 0
- end if
- end if
- checkX = counterX - 1
- if not ((counterX mod 2) = 0) then
- checkY = counterY + 1
- else
- checkY = counterY
- end if
- if checkOutOfBounds(checkX, checkY) = 1 then
- Prop = sendSprite(gTileArray[checkY][checkX], #getHexProperty)
- checkProp = sendSprite(gTileArray[counterY][counterX], #getHexProperty)
- if Prop[3] <> checkProp[6] then
- return 0
- end if
- end if
- end if
- end if
- end repeat
- end repeat
- repeat with counterX = 1 to gArrayWidth
- repeat with counterY = 1 to gArrayHeight
- if checkOutOfBounds(counterX, counterY) = 1 then
- if gTileArray[counterY][counterX] > 0 then
- firstX = counterX
- firstY = counterY
- end if
- end if
- end repeat
- end repeat
- wereDone = 0
- tileCount = 1
- Prop = sendSprite(gTileArray[firstY][firstX], #getHexProperty)
- if Prop[1] = gColorRequired then
- theNextSide = 1
- else
- if Prop[2] = gColorRequired then
- theNextSide = 2
- else
- if Prop[3] = gColorRequired then
- theNextSide = 3
- else
- if Prop[4] = gColorRequired then
- theNextSide = 4
- else
- if Prop[5] = gColorRequired then
- theNextSide = 5
- else
- if Prop[6] = gColorRequired then
- theNextSide = 6
- end if
- end if
- end if
- end if
- end if
- end if
- nextX = firstX
- nextY = firstY
- repeat while wereDone = 0
- case theNextSide of
- 1:
- if not ((nextX mod 2) = 0) then
- nextY = nextY
- else
- nextY = nextY - 1
- end if
- nextX = nextX - 1
- if checkOutOfBounds(nextX, nextY) = 0 then
- return 0
- end if
- theNextSide = 4
- 2:
- nextY = nextY - 1
- nextX = nextX
- if checkOutOfBounds(nextX, nextY) = 0 then
- return 0
- end if
- theNextSide = 5
- 3:
- if not ((nextX mod 2) = 0) then
- nextY = nextY
- else
- nextY = nextY - 1
- end if
- nextX = nextX + 1
- if checkOutOfBounds(nextX, nextY) = 0 then
- return 0
- end if
- theNextSide = 6
- 4:
- if not ((nextX mod 2) = 0) then
- nextY = nextY + 1
- else
- nextY = nextY
- end if
- nextX = nextX + 1
- if checkOutOfBounds(nextX, nextY) = 0 then
- return 0
- end if
- theNextSide = 1
- 5:
- nextY = nextY + 1
- nextX = nextX
- if checkOutOfBounds(nextX, nextY) = 0 then
- return 0
- end if
- theNextSide = 2
- 6:
- if not ((nextX mod 2) = 0) then
- nextY = nextY + 1
- else
- nextY = nextY
- end if
- nextX = nextX - 1
- if checkOutOfBounds(nextX, nextY) = 0 then
- return 0
- end if
- theNextSide = 3
- end case
- if (nextX = firstX) and (nextY = firstY) then
- if tileCount = gNumTiles then
- return 1
- else
- return 0
- end if
- end if
- Prop = sendSprite(gTileArray[nextY][nextX], #getHexProperty)
- if Prop[theNextSide] <> gColorRequired then
- return 0
- end if
- if (Prop[1] = gColorRequired) and (theNextSide <> 1) then
- theNextSide = 1
- else
- if (Prop[2] = gColorRequired) and (theNextSide <> 2) then
- theNextSide = 2
- else
- if (Prop[3] = gColorRequired) and (theNextSide <> 3) then
- theNextSide = 3
- else
- if (Prop[4] = gColorRequired) and (theNextSide <> 4) then
- theNextSide = 4
- else
- if (Prop[5] = gColorRequired) and (theNextSide <> 5) then
- theNextSide = 5
- else
- if (Prop[6] = gColorRequired) and (theNextSide <> 6) then
- theNextSide = 6
- end if
- end if
- end if
- end if
- end if
- end if
- tileCount = tileCount + 1
- end repeat
- return 1
- end
-
- on checkOutOfBounds elementX, elementY
- if (elementX < 1) or (elementY < 1) then
- return 0
- end if
- if (elementY > gArrayHeight) or (elementX > gArrayWidth) then
- return 0
- end if
- if not ((elementX mod 2) = 0) and (elementY > (gArrayHeight - 1)) then
- return 0
- end if
- if gTileArray[elementY][elementX] = 0 then
- return 0
- end if
- return 1
- end
-