這次是【遇怪】以及【地圖行走】
不過遇到怪物這個很容易而已。
若是像精靈寳可夢的話簡單的放個 if 和 intrandom 就行了。
[eval exp="f.encounter=intrandom(2000,2500)"]
以上的意思就是:f.encounter的數值是2000與2500之間的一個數字。
然後[if exp="f.encounter == 2222"]進入戰鬥[endif]
完成。
不過問題是,if該放在哪兒?
就是執行每一步的代碼後面就行。
然後一下將開始【地圖行走】的教程。
*moving
[call target=*up cond="System.getKeyState(VK_UP)"]
[call target=*down cond="System.getKeyState(VK_DOWN)"]
[call target=*left cond="System.getKeyState(VK_LEFT)"]
[call target=*right cond="System.getKeyState(VK_RIGHT)"]
[wait time=20]
[jump target="*moving"]
以上是讓你能夠利用上下左右的按鈕的代碼。
放入wait time的理由是防止無限Loop導致程式當機。你可以改變它的速度不過不能放入0。
不過就算你按了“上”,你的人物也不會上去,還缺少了一些東西。不過在那之前,你必須要有一個圖案讓你知道你的人物的行動。
在*moving前放入
[eval exp=f.top=0]
[eval exp=f.left=0]
[eval exp=f.bgtop=260]
[eval exp=f.bgleft=0]
[image layer=1 storage="character" page=fore left=&f.left top=&f.top clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
character是你的人物圖案,left=&f.left 代表圖案的X位置是f.left,也就是(現在)0。
Clipheight是圖案的高度,Clipwidth則是長度。
f.bgleft是背景的X位置,之後會用到。
這個是初始化的代碼,一旦開始你的人物就會出現與畫面中。
那麼,我們來試試看按一按“上”吧。
*up
[if exp="f.top == 0"]
[image layer=1 storage="character" page=fore left=&f.left top=0 clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
[return]
[else]
[er]
[nowait]
[if exp="f.top >= 261"]
[eval exp="f.top=f.top-10"]
[image layer=1 storage="character" page=fore left=&f.left top=&f.top clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
[endif]
[if exp="f.top <= 260"]
[eval exp="f.top=f.top"]
[eval exp="f.bgtop=f.bgtop+10"]
[image storage="bg" page=fore layer=0 visible=true left=&f.bgleft top=&f.bgtop]
[endif]
[if exp="f.bgtop>=0"]
[eval exp="f.top=f.top-10"]
[image layer=1 storage="character" page=fore left=&f.left top=&f.top clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
[eval exp="f.bgtop=0"]
[image storage="bg" page=fore layer=0 visible=true left=&f.bgleft top=&f.bgtop]
[endif]
[return]
[endif]
很亂吧?不過掌握了這一點后就行了。我們慢慢從一行一行地理解下去
當你的人物的位置(這兒即f.top)是0的話,代表你無法再繼續走上去。
然後return,返回*moving
而若是相反的話(else f.top是1以上的話),我們就進入“行走”代碼。
(先等一等,我必須交代一件事情就是:
f.top的畫面位置。若是0的話,就是最上一邊,數字越大的話你的人物位置就離上面越遠)
當你的人物的位置超過261(也就是我畫面的高度的一半)f.top將減與10(即走上去)。
這兒的圖案是“更新用”的,每當行走一步就更新一下圖案(若是動態的話),順便更新位置。
然後若是少於260的話,人物的位置保持不變,相反這次輪到背景更新位置。
f.bgtop+10也就是讓背景“下去”,這裏的目的是讓在比較長的背景中使人物看來在行走。
而當f.bgtop到達0的時候(也就是圖片的高度上限),我們繼續執行人物的行走。
於是繼續f.top-10。然後為保持背景不少於0,而加入f.bgtop=0。
最後不忘了return,返回*moving,然後從此無限來回。
行走篇完結。
遇怪呢?
在最后一個return前放入“[if exp="f.encounter == 2222"]進入戰鬥[endif]”下去。
這樣在返回前你就能被送到戰場去了。
戰鬥篇臭長,超不想做的(喂
那麼下次再見。盡量在一星期前後更新
不過遇到怪物這個很容易而已。
若是像精靈寳可夢的話簡單的放個 if 和 intrandom 就行了。
[eval exp="f.encounter=intrandom(2000,2500)"]
以上的意思就是:f.encounter的數值是2000與2500之間的一個數字。
然後[if exp="f.encounter == 2222"]進入戰鬥[endif]
完成。
不過問題是,if該放在哪兒?
就是執行每一步的代碼後面就行。
然後一下將開始【地圖行走】的教程。
*moving
[call target=*up cond="System.getKeyState(VK_UP)"]
[call target=*down cond="System.getKeyState(VK_DOWN)"]
[call target=*left cond="System.getKeyState(VK_LEFT)"]
[call target=*right cond="System.getKeyState(VK_RIGHT)"]
[wait time=20]
[jump target="*moving"]
以上是讓你能夠利用上下左右的按鈕的代碼。
放入wait time的理由是防止無限Loop導致程式當機。你可以改變它的速度不過不能放入0。
不過就算你按了“上”,你的人物也不會上去,還缺少了一些東西。不過在那之前,你必須要有一個圖案讓你知道你的人物的行動。
在*moving前放入
[eval exp=f.top=0]
[eval exp=f.left=0]
[eval exp=f.bgtop=260]
[eval exp=f.bgleft=0]
[image layer=1 storage="character" page=fore left=&f.left top=&f.top clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
character是你的人物圖案,left=&f.left 代表圖案的X位置是f.left,也就是(現在)0。
Clipheight是圖案的高度,Clipwidth則是長度。
f.bgleft是背景的X位置,之後會用到。
這個是初始化的代碼,一旦開始你的人物就會出現與畫面中。
那麼,我們來試試看按一按“上”吧。
*up
[if exp="f.top == 0"]
[image layer=1 storage="character" page=fore left=&f.left top=0 clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
[return]
[else]
[er]
[nowait]
[if exp="f.top >= 261"]
[eval exp="f.top=f.top-10"]
[image layer=1 storage="character" page=fore left=&f.left top=&f.top clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
[endif]
[if exp="f.top <= 260"]
[eval exp="f.top=f.top"]
[eval exp="f.bgtop=f.bgtop+10"]
[image storage="bg" page=fore layer=0 visible=true left=&f.bgleft top=&f.bgtop]
[endif]
[if exp="f.bgtop>=0"]
[eval exp="f.top=f.top-10"]
[image layer=1 storage="character" page=fore left=&f.left top=&f.top clipleft=0 cliptop=0 clipheight=100 clipwidth=100 visible=true]
[eval exp="f.bgtop=0"]
[image storage="bg" page=fore layer=0 visible=true left=&f.bgleft top=&f.bgtop]
[endif]
[return]
[endif]
很亂吧?不過掌握了這一點后就行了。我們慢慢從一行一行地理解下去
當你的人物的位置(這兒即f.top)是0的話,代表你無法再繼續走上去。
然後return,返回*moving
而若是相反的話(else f.top是1以上的話),我們就進入“行走”代碼。
(先等一等,我必須交代一件事情就是:
f.top的畫面位置。若是0的話,就是最上一邊,數字越大的話你的人物位置就離上面越遠)
當你的人物的位置超過261(也就是我畫面的高度的一半)f.top將減與10(即走上去)。
這兒的圖案是“更新用”的,每當行走一步就更新一下圖案(若是動態的話),順便更新位置。
然後若是少於260的話,人物的位置保持不變,相反這次輪到背景更新位置。
f.bgtop+10也就是讓背景“下去”,這裏的目的是讓在比較長的背景中使人物看來在行走。
而當f.bgtop到達0的時候(也就是圖片的高度上限),我們繼續執行人物的行走。
於是繼續f.top-10。然後為保持背景不少於0,而加入f.bgtop=0。
最後不忘了return,返回*moving,然後從此無限來回。
行走篇完結。
遇怪呢?
在最后一個return前放入“[if exp="f.encounter == 2222"]進入戰鬥[endif]”下去。
這樣在返回前你就能被送到戰場去了。
戰鬥篇臭長,超不想做的(喂
那麼下次再見。盡量在一星期前後更新