ジグソーパズル

ジグソーパズル

12644bytes(殆ど画像データ量です)

ジグソーパズルです
きちんと配置されると、固定されます。

ジグソーパズルをつくってみました。

◆ピースが配置された後、他のピースよりも後ろに表示されなければ操作性が悪くなります。そこで、チャンネルを複数用意し、移動用のスプライトと表示用のスプライトを分けています。移動用のスプライトが特定の位置に配置されたときに、そのスプライトの表示をOFFにし、表示用のスプライトをOnにします。ただそれだけのことですが、操作性が一段と向上するはずです。
◆また、移動用のピースを半透明にすることにより、他のピースとの重なりも解消されました(たぶん)。
◆一枚の画像から複数のピースを作成する方法は、森さんのアイディア「アップルメニューの”ジグソーパズル”を使う」というアイディアを拝借いたしました。こりゃ便利ですわ。
◆こんな程度で必要ないかもしれませんが、GIVE UPボタンを作りました。画面効果に凝ってみましたが、如何でしょうか?
以下スクリプトを掲載します。めんどくさいので段付けはしていません。このままコピーペーストして使えますよ。 --正しい位置にスプライトを配置したときに、その座標を
--メッセージウィンドウに表示させるためのプログラム
on test
set HList=[]
set VList=[]
repeat with m=20 to 34
setAt HList,m-19,the locH of sprite m
setAt VList,m-19,the locV of sprite m
end repeat
put HList
put VList
end

--ムービー開始時の色々な設定です
on startMovie
--HListとは正解の位置の水平座標を格納するリストです。
global HList,VList,flag
--flagとは正解の位置にたどりついたピースの数を示します
set flag to 0
set HList= [90, 200, 142, 85, 139, 87, 141, 312, 260, 257, 204, 316, 312, 196, 258]
set VList=[130, 69, 135, 68, 200, 198, 67, 64, 129, 67, 200, 130, 201, 129, 195]
repeat with a=2 to 34
puppetSprite a,TRUE
end repeat
--2から16のチャンネルは表示用(正解の表示の為のチャンネル)です。
--最初は見えないようにするためにvisibleをFALSEにしておきます
repeat with b=2 to 16
set the visible of sprite b to FALSE
end repeat
repeat with c=20 to 34
set the visible of sprite c to TRUE
end repeat
--以下の3つはボタンのチャンネルです。
set the visible of sprite 40 to FALSE
set the visible of sprite 41 to TRUE
set the visible of sprite 42 to FALSE
end

--最初にピースを散らばらせるハンドラです
on shaffle
repeat with m=20 to 34
set the locH of sprite m to random (400)
set the locV of sprite m to random (320)
--この部分で半透明にします
set the blend of sprite m to 75
puppetSound "card"
updatestage
end repeat
set the visible of sprite 42 to TRUE
end

--それぞれのピースに書き込まれたスコアスクリプトです
on mouseDown
global HList,VList,flag
--クリックされたスプライト番号を格納します。
put the clickOn into mySpNum
repeat while the mouseDown
--ピースを移動させるのですが、ステージ外に行ったときの処理です
--或程度以上は行かないように設定しておきます
if the mouseH >400 then
set the locH of sprite mySpNum to 390
else if the mouseH <0 then
set the locH of sprite mySpNum to 10
else
set the locH of sprite mySpNum to the mouseH
end if
if the mouseV >320 then
set the locV of sprite mySpNum to 310
else if the mouseV <0 then
set the locH of sprite mySpNum to 10
else
set the locV of sprite mySpNum to the mouseV
end if
updatestage
end repeat
--ボタンが離された時
--正解の位置よりプラスマイナス10ピクセルの場合……
if the locH of sprite mySpNum +10 > getAt(HList,mySpNum -19) and the locH of sprite mySpNum -10 < getAt(HList,mySpNum -19) and the locV of sprite mySpNum +10 > getAt(VList,mySpNum -19) and the locV of sprite mySpNum -10 < getAt(VList,mySpNum -19) then
--背景色を赤にして
set the foreColor of sprite 1 to 35
updatestage
puppetSound "card"
--そのスプライトを見えなくします
set the visible of sprite myspNum to False
--表示用のスプライトを表示さえます
set the visible of sprite mySpNum-18 to TRUE
set the forecolor of sprite 1 to 255
set flag to flag+1
updatestage
end if
--全部所定の位置に納まったときには
--replayのボタンを表示させます
if flag =15 then
set the visible of sprite 40 to TRUE
end if
end


© Akira SAno 1996
一応こんなページでも著作権は佐野彰に存在します
リンクフリーですが、メールでご連絡頂けたら嬉しいです。
97/1/24更新 home32Kの世界に戻る