Created
July 21, 2017 20:55
-
-
Save Zerosen/a4d2ed399871d88655d559676bf8f717 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//mario editor を作ります。 | |
広さ = 3 //ワールドの広さ | |
screen 0,640*広さ,640*広さ,0,0,0,640,640 | |
mariox = 320 : marioy = 320 : jump_sw = 0 :横=40*広さ : 縦=40*広さ : sdim masu,10,横,縦 : dim enemyx,100 : dim enemyy,100 : enemy_num=0 | |
sdim baggage,10,10 : sdim 数字,10,10 : sdim block,10 :PosX = 320 : PosY = 320:groll PosX,PosY : dim house, 40:house_num=0 : sdim masu_sub,10,横,縦 | |
dim villagerx,100 : dim villagery,100 : villager_num=0 : Lclick_sw = 0 | |
//敵座標すべてに-1をいれる 敵がいないということ | |
repeat 100 | |
ct=cnt | |
repeat 100 | |
enemyx(cnt) = -1 | |
enemyy(ct) = -1 | |
loop | |
loop | |
baggage(0)="0" | |
baggage(1)="1" | |
baggage(2)="2" | |
//メモ帳をバッファに読み込む | |
dialog "txt",16,"テキストファイル" | |
if stat = 0 : end | |
sdim buf,2,横,縦;メモ帳から読み込むためのバッファ | |
notesel buf : noteload refstr | |
//ここまででテキストファイルからbufに内容を読み込めた | |
//bufの内容をmasu(x,y)に読み込んでいく | |
count=0 : repeat 縦 : ct=cnt : repeat 横 : noteget masu(cnt,ct),count : count++ : loop : loop | |
/* | |
//木を書く | |
repeat 50 | |
tree_x=rnd(120) | |
tree_y=rnd(120) | |
if masu(tree_x,tree_y)=""{ | |
masu(tree_x,tree_y)="木";木を書く | |
} | |
loop | |
//石を書く | |
repeat 20 | |
tree_x=rnd(120) | |
tree_y=rnd(120) | |
if masu(tree_x,tree_y)=""{ | |
masu(tree_x,tree_y)="石";木を書く | |
} | |
loop | |
*/ | |
//始まる前にすでに配置済みの村人をサーチして番号を振っていく | |
flag3=0 | |
repeat 80,20 | |
ct = cnt | |
repeat 80,20 | |
if masu(cnt,ct)=="V" {;その座標に 村人 を見つけたなら 番号をつけていく | |
//その番の 村人 の座標がmasu(villagerx(villager_num), villagery(villager_num)) | |
villagerx(villager_num)=cnt | |
villagery(villager_num)=ct | |
villager_num++ | |
if villager_num==100:villager_num=0:flag3=1:break//100体見つけた時点で2重ループを脱出 | |
} | |
loop | |
if flag3=1:break | |
loop | |
*main | |
redraw 0 | |
color 0,0,0 : boxf//画面初期化 | |
color 255,255,255 | |
//家の数を数える 村人の数を数える | |
house=0 | |
villager_max =0 | |
repeat 80,20 | |
ct=cnt | |
repeat 80,20 | |
if masu(cnt,ct)="□" && masu(cnt+1,ct) ="□" && masu(cnt+2,ct)="□" && masu(cnt+3,ct)="□" && masu(cnt+4,ct)="□"{ | |
if masu(cnt,ct+1)="□" && masu(cnt+1,ct+1)="" && masu(cnt+2,ct+1)="" && masu(cnt+3,ct+1)="" && masu(cnt+4,ct+1)="□"{ | |
if masu(cnt,ct+2)="□" && masu(cnt+1,ct+2)="" && masu(cnt+2,ct+2)="" && masu(cnt+3,ct+2)="" && masu(cnt+4,ct+2)="□"{ | |
if masu(cnt,ct+3)="□" && masu(cnt+1,ct+3)="" && masu(cnt+2,ct+3)="" && masu(cnt+3,ct+3)="" && masu(cnt+4,ct+3)="□"{ | |
if masu(cnt,ct+4)="□" && masu(cnt+1,ct+4)="□" && masu(cnt+2,ct+4)="□" && masu(cnt+3,ct+4)="□"&& masu(cnt+4,ct+4)="□"{ | |
house++ | |
} | |
} | |
} | |
} | |
} | |
if masu(cnt,ct)="倉"{ | |
if masu(cnt-1,ct+1)="倉" && masu(cnt,ct+1)="倉" && masu(cnt+1,ct+1)="倉"{ | |
if masu(cnt-2,ct+2)="倉" && masu(cnt-1,ct+2)="倉" && masu(cnt,ct+2)="倉" && masu(cnt+1,ct+2)="倉" && masu(cnt+2,ct+2)="倉"{ | |
if masu(cnt-3,ct+3)="倉" && masu(cnt-2,ct+3)="倉" && masu(cnt-1,ct+3)="倉" && masu(cnt,ct+3)="倉" && masu(cnt+1,ct+3)="倉" && masu(cnt+2,ct+3)="倉" && masu(cnt+3,ct+3)="倉"{ | |
if masu(cnt-3,ct+4)="倉" && masu(cnt+3,ct+4)="倉"{ | |
if masu(cnt-3,ct+5)="倉" && masu(cnt+3,ct+5)="倉"{ | |
if masu(cnt-3,ct+6)="倉" && masu(cnt-3,ct+6)="倉"{ | |
house++ | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
if masu(cnt,ct)="V" | masu(cnt,ct)="[V]" : villager_max++ | |
if villager_max>house*5 : villager_max-- | |
loop | |
loop | |
pos PosX,PosY:mes "家"+house:pos PosX+48,PosY:mes "人口"+villager_max +"/"+ house*5 | |
pos PosX,PosY+624 :mes "□∞" | |
line ((640*広さ)-320)+16,320,320,320 :line ((640*広さ)-320)+16,((640*広さ)-320)+16,((640*広さ)-320)+16,320 | |
line 320,((640*広さ)-320)+16,((640*広さ)-320)+16,((640*広さ)-320)+16:line 320,320,320,((640*広さ)-320)+16 | |
//移動 入力受付 以下 | |
stick key, 15 | |
if ((key&1)!0)&(PosX > 0) : PosX-- : groll PosX,PosY | |
if ((key&2)!0)&(PosY > 0) :PosY-- :groll PosX,PosY | |
if ((key&4)!0)&(PosX < 1280) : PosX++ : groll PosX,PosY | |
if ((key&8)!0)&(PosY < 1280) : PosY++ : groll PosX,PosY | |
mariox = PosX + 320 //プレイヤーの中央座標の更新 | |
marioy = PosY + 320 // 〃 | |
title "BGX : "+ginfo(8)+" / BGY : "+ginfo(9)+" | |
pos mariox,marioy : mes "@"//マリオの場所 | |
//leftclickで村人を選択 | |
if ((key==256)!0) && masu(((mousex+PosX)/16),((mousey+PosY)/16))="V" && Lclick_sw = 0{ | |
masu(((mousex+PosX)/16),((mousey+PosY)/16))="[V]" | |
vil_kiokux=((mousex+PosX)/16) | |
vil_kiokuy=((mousey+PosY)/16) | |
Lclick_sw=1 | |
} | |
;何もないところをクリックすると上の選択を解除 | |
if ((key==256)!0) && masu(((mousex+PosX)/16),((mousey+PosY)/16))="" && Lclick_sw = 1{ | |
masu(vil_kiokux,vil_kiokuy)="V" | |
Lclick_sw=0 | |
} | |
;村人を選んだ状態で空のマスをクリックするとそこまで移動 | |
if ((key==512)!0) && masu(vil_kiokux,vil_kiokuy)="[V]" && masu(((mousex+PosX)/16),((mousey+PosY)/16))="" && Lclick_sw = 1{ | |
} | |
//自分の村人を選んだ座標が 番号をもつ村人の座標と同じなら表示 | |
repeat 100 | |
if masu(vil_kiokux,vil_kiokuy) == "[V]" && masu(villagerx(cnt), villagery(cnt)) == "V"{ | |
villager_num = cnt | |
pos PosX+100,PosY+624 : mes "選んだ村人の番号" + villager_num | |
break | |
} | |
loop | |
//マップを自分から距離20まで表示 | |
repeat 40,(marioy/16)-20 | |
ct = cnt | |
repeat 40,(mariox/16)-20 | |
pos 16*cnt,16*ct | |
mes masu(cnt,ct) | |
loop | |
loop | |
//衝突判定 以下 | |
箱のサイズ=14 | |
repeat 縦 | |
ct = cnt | |
repeat 横 | |
if masu(cnt,ct) = "□" || masu(cnt,ct) = "壁" || masu(cnt,ct) = "倉"{//そこにブロックがあるとき | |
//右から当たる場合 | |
if (marioy >= 16*(ct)-箱のサイズ) && (marioy <= 16*(ct)+箱のサイズ){ | |
if mariox == 16*(cnt)+箱のサイズ : PosX++ | |
} | |
//左から当たる場合 | |
if (marioy >= 16*(ct)-箱のサイズ) && (marioy <= 16*(ct)+箱のサイズ){ | |
if mariox == 16*(cnt)-箱のサイズ : PosX-- | |
} | |
//上から当たる場合 | |
if (mariox >= 16*(cnt)-箱のサイズ) && (mariox <= 16*(cnt)+箱のサイズ){ | |
if marioy == 16*(ct)-箱のサイズ : PosY-- | |
} | |
//下から当たる場合 | |
if (mariox >= 16*(cnt)-箱のサイズ) && (mariox <= 16*(cnt)+箱のサイズ){ | |
if marioy == 16*(ct)+箱のサイズ : PosY++ | |
} | |
} | |
loop | |
loop | |
//自分から3マスまで置いたり消したりできる | |
if (((mousex+PosX)/16) <= (mariox/16)+3) && (((mousex+PosX)/16) >= (mariox/16)-3) && (((mousey+PosY)/16) <= (marioy/16)+3) && (((mousey+PosY)/16) >= (marioy/16)-3){ | |
//マウスで座標を選ぶ | |
pos ((mousex+PosX)/16)*16,((mousey+PosY)/16)*16 | |
if block_count = 0 : mes "[]" | |
if block_count = 1 : mes "壁" | |
if block_count = 2 : mes "□" | |
if block_count = 3 : mes "&" | |
if block_count = 4 : mes "移" | |
if block_count = 5 : mes "飛" | |
if block_count = 6 : mes "%" | |
if block_count = 7 : mes "倉" | |
if block_count = 8 : mes "V" | |
getkey rightclick, 2 | |
if rightclick && block_count = 8 && block="V" && house*5==villager_max: goto *hata3 | |
if rightclick { | |
if block="V":goto *hata4;村人は一人ずつしか置けなくした 番号の問題 | |
masu(((mousex+PosX)/16),((mousey+PosY)/16))=block | |
//新しく生まれた村人に最大の番号を振っていく | |
*hata4 | |
if block="V" && flag9=0{;置いたのが村人なら 最大の 番号をつけていく | |
//その番の 村人 の座標がmasu(villagerx(villager_num), villagery(villager_num)) | |
villager_num++ | |
villagerx(villager_num)=(mousex+PosX)/16 ;ここにはmasu(,)の座標を入れていく | |
villagery(villager_num)=(mousey+PosY)/16 | |
masu(((mousex+PosX)/16),((mousey+PosY)/16))=block | |
if villager_num==100:villager_num=0 | |
flag9++ | |
} | |
}else:flag9=0 | |
} | |
*hata3 | |
//アイテムを拾う | |
getkey grab, 71: if grab{ | |
repeat 10:poke 数字.cnt,0,48+cnt : loop | |
repeat 10 | |
if masu(mariox/16,marioy/16)=数字(cnt) { | |
repeat 10 | |
if baggage(cnt)=""{//スペースがあるなら | |
baggage(cnt)=masu(mariox/16,marioy/16) | |
goto *spaceari//スペースが見つかった時点でループから抜け出す | |
} | |
if cnt = 9 : goto *nospace//スペースがなかったらアイテムをフィールドから消さない | |
loop | |
} | |
if hairanai=1{ | |
*spaceari | |
masu((mariox/16),(marioy/16))=""//拾ったアイテムをフィールドから消す | |
*nospace | |
break | |
} | |
loop | |
} | |
//アイテムを落とす | |
getkey drop, 68: if drop{ | |
*dropitem | |
redraw 0 | |
color 0,0,0 : boxf//画面初期化 | |
color 255,255,255 | |
repeat 10: pos PosX+16,(16*cnt)+PosY : mes baggage(cnt) : loop | |
pos PosX,(16*dropitem_y)+PosY : mes "→" | |
stick key | |
if key = 2 : dropitem_y-- | |
if key = 8 : dropitem_y++ | |
if dropitem_y<0 : dropitem_y++ | |
if dropitem_y>9 : dropitem_y-- | |
if key = 32{ | |
if baggage(dropitem_y) != ""{ | |
if masu((mariox/16),(marioy/16)) = ""{//今立ってる場所に何もないなら | |
masu((mariox/16),(marioy/16)) = baggage(dropitem_y) | |
baggage(dropitem_y) = "" | |
} | |
//今立ってる場所に何かがあるならなにもしない | |
} | |
} | |
getkey close, 27: if close:goto *main | |
redraw 1 | |
await 10 | |
goto *dropitem | |
} | |
//かばんの中のアイテムを見る | |
getkey item, 88: if item{ | |
*watchitem | |
redraw 0 | |
color 0,0,0 : boxf//画面初期化 | |
color 255,255,255 | |
repeat 10: pos PosX+16,(16*cnt)+PosY : mes baggage(cnt) : loop | |
getkey close, 27: if close:goto *main | |
redraw 1 | |
await 10 | |
goto *watchitem | |
} | |
//置くブロックを変える | |
getkey change_block, 67: if change_block : keyb++ : else : keyb=0 | |
if keyb = 1 { | |
block_count++ | |
if block_count = 0 : block = "" | |
if block_count = 1 : block = "壁" | |
if block_count = 2 : block = "□" | |
if block_count = 3 : block = "&" | |
if block_count = 4 : block = "移" | |
if block_count = 5 : block = "飛" | |
if block_count = 6 : block = "%" | |
if block_count = 7 : block = "倉" | |
if villager_sw=0{ | |
if block_count = 8 : block = "V" | |
}else{ | |
block_count = 9 : block_count = 0 : block = "" | |
} | |
if block_count = 9 : block_count = 0 : block = "" | |
} | |
//近づいてくる敵 | |
//フィールドマップすべてを敵をサーチ | |
flag=0 | |
repeat 縦 | |
ct = cnt | |
repeat 横 | |
if masu(cnt,ct)="%" {;その座標に敵を見つけたなら 番号をつけていく | |
//その番の敵の座標がmasu(enemyx(enemy_num), enemyy(enemy_num)) | |
enemyx(enemy_num)=cnt | |
enemyy(enemy_num)=ct | |
enemy_num++ | |
if enemy_num==100:enemy_num=0:flag=1:break//100体見つけた時点で2重ループを脱出 | |
} | |
loop | |
if flag=1:break | |
loop | |
enemy_counter1++ | |
if enemy_counter1 = 25 { | |
enemy_num=0 | |
while (enemyx(enemy_num)!=-1) && (enemyy(enemy_num)!=-1) | |
//敵が@から10マス以内にいるとき | |
if (mariox/16 - enemyx(enemy_num))<10 & (enemyx(enemy_num) - mariox/16)<10 & (marioy/16 - enemyy(enemy_num))<10 & (enemyy(enemy_num) - marioy/16)<10 { | |
if mariox/16 > enemyx(enemy_num) {//敵が@の左にいる つまり 敵は右に進む | |
if enemyx(enemy_num)+1>横:goto *hata1 | |
if masu(enemyx(enemy_num)+1,enemyy(enemy_num))!="":goto *hata1 ;障害物がある場合移動しない | |
masu(enemyx(enemy_num)+1,enemyy(enemy_num))=masu(enemyx(enemy_num),enemyy(enemy_num));左に移動 | |
masu(enemyx(enemy_num),enemyy(enemy_num))="";もといた場所を消す | |
enemyx(enemy_num)=-1 | |
enemyy(enemy_num)=-1 | |
goto *hata1 | |
} | |
if enemyx(enemy_num) > mariox/16 {//敵が@の右にいる つまり 敵は左に進む | |
if enemyx(enemy_num)-1<0:goto *hata1 | |
if masu(enemyx(enemy_num)-1,enemyy(enemy_num))!="":goto *hata1 ;障害物がある場合移動しない | |
masu(enemyx(enemy_num)-1,enemyy(enemy_num))=masu(enemyx(enemy_num),enemyy(enemy_num));左に移動 | |
masu(enemyx(enemy_num),enemyy(enemy_num))="";もといた場所を消す | |
enemyx(enemy_num)=-1 | |
enemyy(enemy_num)=-1 | |
goto *hata1 | |
} | |
if marioy/16 > enemyy(enemy_num) {//敵が@の上にいる つまり 敵は下に進む | |
if enemyy(enemy_num)+1>縦:goto *hata1 | |
if masu(enemyx(enemy_num),enemyy(enemy_num)+1)!="":goto *hata1 | |
masu(enemyx(enemy_num),enemyy(enemy_num)+1)=masu(enemyx(enemy_num),enemyy(enemy_num));下に移動 | |
masu(enemyx(enemy_num),enemyy(enemy_num))="";もといた場所を消す | |
enemyx(enemy_num)=-1 | |
enemyy(enemy_num)=-1 | |
goto *hata1 | |
} | |
if enemyy(enemy_num) > marioy/16 {//敵が@の下にいる つまり 敵は上に進む | |
if enemyy(enemy_num)-1<0:goto *hata1 | |
if masu(enemyx(enemy_num),enemyy(enemy_num)-1)!="":goto *hata1 | |
masu(enemyx(enemy_num),enemyy(enemy_num)-1)=masu(enemyx(enemy_num),enemyy(enemy_num));上に移動 | |
masu(enemyx(enemy_num),enemyy(enemy_num))="";もといた場所を消す | |
enemyx(enemy_num)=-1 | |
enemyy(enemy_num)=-1 | |
goto *hata1 | |
} | |
} | |
*hata1 | |
enemy_num++ | |
if enemy_num=100:_break | |
wend | |
enemy_counter1 = 0 | |
} | |
//ランダムに動く敵 | |
enemy_counter++ | |
if enemy_counter = 50 { | |
repeat 縦 | |
ct = cnt | |
repeat 横 | |
if masu(cnt,ct)="&"{;もしその座標に敵がいるなら | |
direction_teki = rnd(4) | |
if direction_teki = 0{;左 | |
if cnt-1<0: goto *hata2 | |
if masu(cnt-1,ct)!="":goto *hata2;障害物がある場合移動しない | |
masu(cnt-1,ct)=masu(cnt,ct);左に移動 | |
masu(cnt,ct)="";もといた場所を消す | |
} | |
if direction_teki = 1{;上 | |
if ct-1<0:goto *hata2 | |
if masu(cnt,ct-1)!="":goto *hata2 | |
masu(cnt,ct-1)=masu(cnt,ct);上に移動 | |
masu(cnt,ct)="";もといた場所を消す | |
} | |
if direction_teki = 2{;右 | |
if cnt+1>39:goto *hata2 | |
if masu(cnt+1,ct)!="":goto *hata2 | |
masu(cnt+1,ct)=masu(cnt,ct);右に移動 | |
masu(cnt,ct)="";もといた場所を消す | |
} | |
if direction_teki = 3{;下 | |
if ct+1>39:goto *hata2 | |
if masu(cnt,ct+1)!="":goto *hata2 | |
masu(cnt,ct+1)=masu(cnt,ct);下に移動 | |
masu(cnt,ct)="";もといた場所を消す | |
} | |
} | |
*hata2 | |
loop | |
loop | |
enemy_counter = 0 | |
} | |
//移ブロックに触るとマップを移動する | |
if masu(mariox/16,marioy/16)="移"{ | |
notesel buf | |
noteload "map2.txt" | |
count_note=0 | |
repeat 縦 | |
ct=cnt | |
repeat 横 | |
noteget masu(cnt,ct),count_note | |
count_note++ | |
loop | |
loop | |
goto *main | |
} | |
//飛ブロックに触るとワールドマップに移動する | |
if masu(mariox/16,marioy/16)="飛" : goto *worldmap | |
onexit goto *save | |
redraw 1 | |
await 10 | |
goto *main | |
*save | |
notesel buf | |
count=0 | |
repeat 縦 | |
ct=cnt | |
repeat 横 | |
noteadd masu(cnt,ct),count,1 | |
count++ | |
loop | |
loop | |
dialog "txt",16,"テキストファイル" | |
if stat = 0 : end | |
notesave refstr | |
end | |
*worldmap | |
redraw 0 | |
color 0,0,0:boxf | |
color 255,255,255 | |
line | |
redraw 1 | |
await 10 | |
goto *worldmap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment