物体の落下

落下運動


簡単な落下運動です
跳ね返り計数は1に設定してあります

なかなか落下運動のスクリプトは難しいものです。
試行錯誤の段階ですが、ひとまず現時点で公開しておきます。

スクリプトは以下の通りです。(もっと簡単な記述方法もあると思うのですが……)

property myV,myH,dirH,dirV,acH,acV,firstV

on new me
global steps
set steps to 0
set the myV of me to 50
set the myH of me to random(10)*18
set the dirH of me to 1
set the dirV of me to 1
set the acH of me to 10
set the acV of me to 1
set the firstV of me to 40
return me
end

on move me
global steps,oldV
set steps to steps +0.6
set the height of sprite 1 to 24
set the width of sprite 1 to 24
if the locV of sprite 1 >265 then
set the height of sprite 1 to 20
set the dirV of me to -1
set the firstV of me to random(10)+30
set steps to 0
end if
if the locH of sprite 1 >180 or the locH of sprite 1 <0 then
set the dirH of me to the dirH of me*(-1)
set the width of sprite 1 to 20
end if
if the dirV of me =1 then
set the acV of me to (the firstV of me +0.9*power(steps,2))*0.8
else
set the acV of me to (the firstV of me -0.9*power(steps,2))*0.8
end if
set the myV of me to the myV of me + the acV of me * the dirV of me
set the myH of me to the myH of me + the acH of me * the dirH of me
set the locV of sprite 1 to the myV of me
set the locH of sprite 1 to the myH of me
end

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