|
Lingo Game: Jigsaw Puzzle READING: Read pages 280-282 in D8D File "arkas.dir"Contains
the basic pieces for making a 4x4 puzzle: on mouseUp put sprite(the ClickOn).locH put sprite(the ClickOn).locV end
has
the programming of the puzzle complete. on mouseUp finH = 267 -- inserted manually finV = 147 -- inserted manually currH = sprite(the ClickOn).locH currV = sprite(the ClickOn).locV if (abs(currH - finH) < 20) and (abs(currV - finV) < 20) then sprite(the ClickOn).locH = finH sprite(the ClickOn).locV = finV beep end if end
is a little prettier in terms of interface and less cumbersome to replicate using the moveAndCheck() function: on mouseUp finH = 267 -- needs to be inserted manually finV = 147 -- needs to be inserted manually moveAndCheck(finH, finV) end
on startMovie
global success
success = 0 -- counts correctly placed pieces
member("banner").text = "Assemble the puzzle"
end
on checkIfDone
global success
if success = 4 then
member("banner").text = "Success!"
-- here you should play a sound and/or go to another frame
-- to celebrate success!
end if
end
Note that there are a couple problems with the game presentation: First, if you accidentally move a piece out of its position, the counter of successes will not decrease. So, you can "cheat" by moving a single piece in and out of position 4 times. It would be better to have a piece "stick" to its final place once it has moved there. You can do that by setting to false the moveableSprite property of a sprite. Next, when a piece moves on top of another, you cannot see the one below. That makes it difficult to move sprites on top of a congested stage. To avoid that you can move the sprite you are currently clicking on at the top channel available to your application. You can do that by setting the locZ property of a sprite to the highest channel available. locZ works like locH and locV, but it has only a temporary effect. After the end of the event handler it is in, it will go back to its original position. The file at the header of this section implements both of these improvements.
|
|
|
Maintained By: Takis Metaxas
|
|