HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2010
0322
くるりスタック領域のオーバーフローです6解決


くるり

リンク

2010/3/22(Mon) 23:05:27|NO.31481


screen 0,1000,400 title "es-2" *hajime repeat redraw 1:redraw 0 color 45,45,45:boxf pos 0,0 color 255,255,255 font "@DotumChe",350,0 mes "ES-" pos 0,0 color 0,100,255 mes " 2" if (mousex>=725)and(mousey>=30)and(mousey<=80){ color 255,255,255:boxf 750,30,1000,80:circle 725,30,775,80 font "@DotumChe",50,0 pos 800,30 color 45,45,45:mes "START" pos 800,30 color 0,100,255:mes " !"} else{ color 80,80,80:boxf 750,30,1000,80:circle 725,30,775,80 font "@DotumChe",50,0 pos 800,30 color 45,45,45:mes "START" pos 800,30 color 100,100,0:mes " ?"} if (mousex>=725)and(mousey>=100)and(mousey<=150){ color 255,255,255:boxf 750,100,1000,150:circle 725,100,775,150 font "@DotumChe",50,0 pos 800,100 color 45,45,45:mes "QUIT" pos 800,100 color 0,100,255:mes " ..."} else{ color 80,80,80:boxf 750,100,1000,150:circle 725,100,775,150 font "@DotumChe",50,0 pos 800,100 color 45,45,45:mes "QUIT" pos 800,100 color 100,100,0:mes " ?"} stick key if key=256{ if (mousex>=725)and(mousey>=30)and(mousey<=80){ break} if (mousex>=725)and(mousey>=100)and(mousey<=150){ end}} await 5 loop mouse -1 dim eney,100 dim enex,100 dim enes,100 dim enel,100 dim exc,100 dim ex,100 dim dflug,100 lv=1 shield=3 shieldmax=3 score=0 lvscore=0 lvmax=10 val=30 energy=100 energymax=100 muteki=0 scc=80 olv=1 nlv=2 tx=1000 die=0 randomize repeat 30 eney(cnt)=rnd(385) enex(cnt)=rnd(200) enex(cnt)+=1000 enes(cnt)=rnd(10) enes(cnt)+ enel(cnt)=1 ex(cnt)=255 loop repeat redraw 1:redraw 0 color 45,45,45:boxf if lvscore>=lvmax{ lvc+ lvscore=score-lvmax lvupflug=1 if lvc=1{ lvmax=lvmax*2 lv+ shadd=1 switch lv case 10 shieldmax+ swbreak case 30 shieldmax+ swbreak case 50 shieldmax+ swbreak case 65 shieldmax+ swbreak case 80 shieldmax+ swbreak case 90 shieldmax+ swbreak case 95 shieldmax+ swbreak case 101 clear=1 break swend}} if lvupflug=1:gosub *lvup color 0,50,100 boxf 0,20,energymax,30 circle energymax-5,20,energymax+5,30 color 0,100,255 boxf 0,20,energy,30 circle energy-5,20,energy+5,30 pos 0,0 font "@DotumChe",20,0 mes "ENERGY:" pos 0,30 mes "SHIELD:" color 0,100,255 if shield<1{circle 10,50,25,65,0} else {circle 10,50,25,65,1} if shield<2{circle 35,50,50,65,0} else {circle 35,50,50,65,1} if shield<3{circle 60,50,75,65,0} else {circle 60,50,75,65,1} if shieldmax>=4{ if shield<4{circle 85,50,100,65,0} else {circle 85,50,100,65,1}} if shieldmax>=5{ if shield<5{circle 110,50,125,65,0} else {circle 110,50,125,65,1}} if shieldmax>=6{ if shield<6{circle 135,50,150,65,0} else {circle 135,50,150,65,1}} if shieldmax>=7{ if shield<7{circle 160,50,175,65,0} else {circle 160,50,175,65,1}} if shieldmax>=8{ if shield<8{circle 185,50,200,65,0} else {circle 185,50,200,65,1}} if shieldmax>=9{ if shield<9{circle 210,50,225,65,0} else {circle 210,50,225,65,1}} if shieldmax>=10{ if shield<10{circle 235,50,250,65,0} else {circle 235,50,250,65,1}} shield=limit(shield,0,shieldmax) if shield=0{ die=1} if die=1:gosub *gameover color scc,scc,scc boxf 0,350,200,400 circle 175,350,225,400 color 0,100,255 pos 0,380 font "@DotumChe",20,0 mes "SCORE:" pos 65,355 font "@DotumChe",50,0 mes score if shadd=1{ randomize addx=rnd(200) addx+=1000 addy=rnd(584) addy+=8 shadd=2} if shadd=2{ color 0,255,100 circle addx-8,addy-8,addx+8,addy+8 addx-=7 dstaddx=abs(addx-mousex) dstaddy=abs(addy-mousey) dstadd=dstaddx*dstaddx+dstaddy*dstaddy if dstadd<=256{ if shield!=shieldmax{ shadd=0 shield+} else { score+=10}}} gosub *enemy if die!=1{ if muteki=0:color 0,100,255 if muteki=1:color 0,50,100 circle mousex-8,mousey-8,mousex+8,mousey+8} ;主人公機 16*16画像で置き換え stick key,768 if die=1:key=0 if (key=256)and(energy>=2){ line mousex+8,mousey,1000,mousey energy-=2} if (key=512)and(energy>=5){ circle mousex-val,mousey-val,mousex+val,mousey+val,0 energy-=5} if key&16:gosub *pause if key<256:energy+ energy=limit(energy,0,energymax) if scc!=80{ scc-=5} await 5 loop goto *out *lvup pos tx,100 color 100,100,0 font "@DotumChe",200,0 mes "Lv UP! "+olv+">>"+nlv tx-=5 if tx<=-1500{ olv+ nlv+ lvupflug=0 tx=1000 lvc=0} return *enemy repeat lv if (key=256)and(energy>=2){ if (eney(cnt)-8<=mousey)and(eney(cnt)+8>=mousey)and(enex(cnt)>mousex)and(enel(cnt)=1){ enel(cnt)=2 score+=enes(cnt) lvscore+=enes(cnt) dflug(cnt)=1 scc=255 energy+=4}} xdst=abs(enex(cnt)-mousex) ydst=abs(eney(cnt)-mousey) dst=xdst*xdst+ydst*ydst if (key=512)and(energy>=5){ if (dst<=(val+8)*(val+8))and(enel(cnt)=1){ enel(cnt)=2 score+=enes(cnt)*2 lvscore+=enes(cnt)*2 dflug(cnt)=2 scc=255 energy+=10}} else { if (dst<=256)and(muteki=0){ shield- muteki=1 mutekic+ }} if mutekic!=0{ mutekic+ if mutekic=150{ mutekic=0 muteki=0}} if enel(cnt)=1{ color 255,255,255 pos enex(cnt),eney(cnt) circle enex(cnt)-8,eney(cnt)-8,enex(cnt)+8,eney(cnt)+8 enex(cnt)-=enes(cnt)} if enel(cnt)=2{ color ex(cnt),ex(cnt),ex(cnt) ex(cnt)-=14 exc(cnt)+=5 circle enex(cnt)-exc(cnt),eney(cnt)-exc(cnt),enex(cnt)+exc(cnt),eney(cnt)+exc(cnt),0 pos enex(cnt),eney(cnt) font "@DotumChe",enes(cnt)*10*dflug(cnt),0 mes "+"+enes(cnt)*dflug(cnt) if ex(cnt)=45{ ex(cnt)=255 exc(cnt)=0 enel(cnt)=0}} if enex(cnt)<0:enel(cnt)=0 if enel(cnt)=0{ eney(cnt)=rnd(385) enex(cnt)=rnd(200) enex(cnt)+=1000 enes(cnt)=rnd(10) enes(cnt)+ enel(cnt)=1 ex(cnt)=255 dflug(cnt)=0} loop return *pause mouse repeat redraw 1:redraw 0 color 255,255,255:boxf 295,95,705,305 color 45,45,45:boxf 300,100,700,300 color 255,255,255 pos 410,105 font "@DotumChe",50,0 mes "-PAUSE-" pos 425,150 font "@DotumChe",30,0 mes "RETURN TO" if (mousex>=300)and(mousex<=700)and(mousey>=180)and(mousey<=230){ color 255,255,255:boxf 300,180,700,230 color 45,45,45 font "@DotumChe",45,0 pos 370,180 mes "BATTLEFIELD" pos 370,180 color 0,100,255 mes " !"} else {color 80,80,80:boxf 300,180,700,230 color 45,45,45 font "@DotumChe",45,0 pos 370,180 mes "BATTLEFIELD" pos 370,180 color 100,100,0 mes " ?"} if (mousex>=300)and(mousex<=700)and(mousey>=250)and(mousey<=300){ color 255,255,255:boxf 300,250,700,300 color 45,45,45 font "@DotumChe",45,0 pos 420,250 mes "TITLE" pos 420,250 color 0,100,255 mes " ..."} else {color 80,80,80:boxf 300,250,700,300 color 45,45,45 font "@DotumChe",45,0 pos 420,250 mes "TITLE" pos 420,250 color 100,100,0 mes " ?"} stick key if key=256{ if (mousex>=300)and(mousex<=700)and(mousey>=180)and(mousey<=230){ flug=0 break} if (mousex>=300)and(mousex<=700)and(mousey>=250)and(mousey<=300){ flug=1 break}} getkey esc,27 await 5 loop if flug=0:return if flug=1:goto *hajime *gameover diec+ if diec<=1000{ color 255,255,255 pos 270,50 font "@DotumChe",300,0 mes "OUT"} if diec>200:goto *out return *out mouse redraw 1 color 45,45,45:boxf hscores="oh" bload "hiscore.dat",hscores,7,0 bload "hiscore.dat",namelongs,2,7 namelong=int(namelongs) name="oh" bload "hiscore.dat",name,namelong,9 hscore=int(hscores) color 255,255,255 font "@DotumChe",30,0 pos 300,0 mes "Your score is "+score+" points." if score>hscore{ color 0,100,255 pos 200,50 mes "High score!" color 255,255,255 pos 200,50 mes " Please save your score and name." pos 400,200 input myname,200,20 repeat redraw 1:redraw 0 color 45,45,45:boxf 0,300,1000,400 if (mousex>=350)and(mousex<=650)and(mousey>=300)and(mousey<=350){ font "@DotumChe",50,0 color 255,255,255 boxf 350,300,650,350 color 45,45,45 pos 465,300 mes "SAVE" pos 465,300 color 0,100,255 mes " !"} else{ font "@DotumChe",50,0 color 80,80,80 boxf 350,300,650,350 color 45,45,45 pos 465,300 mes "SAVE" pos 465,300 color 100,100,0 mes " ?"}} else{ pos 250,50 mes "High score is "+name+"'s "+hscore+" points." if (mousex>=350)and(mousex<=650)and(mousey>=300)and(mousey<=350){ font "@DotumChe",50,0 color 255,255,255 boxf 350,300,650,350 color 45,45,45 pos 465,300 mes "OK" pos 465,300 color 0,100,255 mes " !"} else{ font "@DotumChe",50,0 color 80,80,80 boxf 350,300,650,350 color 45,45,45 pos 465,300 mes "OK" pos 465,300 color 100,100,0 mes " ?"}} stick key if key=256{ if (mousex>=350)and(mousex<=650)and(mousey>=300)and(mousey<=350){ die=0 goto *hajime}} await 5 loop
保存して、同じディレクトリに「000100006kururi」という内容の
「hiscore.dat」というデータを作れば起動できます。
ゲームオーバーになると「スタック領域のオーバーフローです」と表示される
のですが、それって何なのでしょう?
どうすれば解決するでしょうか?
あと、初心者なのでアラ探しは勘弁してください。お願いします。



この記事に返信する


晩御飯

リンク

2010/3/23(Tue) 01:40:09|NO.31484

「スタック領域のオーバーフローです」で検索してみると。
http://quasiquote.org/hspwiki/HSP3%e3%81%aeFAQ%3a%e3%82%a8%e3%83%a9%e3%83%bc%e3%83%a1%e3%83%83%e3%82%bb%e3%83%bc%e3%82%b8%e3%81%ae%e6%84%8f%e5%91%b3%e3%81%a8%e5%af%be%e5%87%a6%e6%b3%95%e3%81%8c%e5%88%86%e3%81%8b%e3%82%89%e3%81%aa%e3%81%84#H-1lpqpum
これを見る限りサブルーチン辺りがおかしい事になってるらしい。
gosubとreturnの対応をきちんとやれ、だそうな。
正直エラーが再現出来なかったのでよく分からない。

あと初心者は免罪符にはならないしアラ探しが嫌なら掲示板に書き込まない方が良い。



ANTARES

リンク

2010/3/23(Tue) 02:09:42|NO.31485

 このスクリプトは以下と同じです。

*hajime gosub *gameover goto *hajime *gameover goto *hajime
 サブルーチンからサブルーチンを呼び出したり、
ループの中でまたループすることをネストと言いますが、
この場合のスタックはネストを管理するためのメモリ領域ということです。
ネストの深さには制限があり、無限に深くすることはできません。

#if 0 if die=1:gosub *gameover #else if die=1:gosub *gameover: if flg: goto *out #endif #if 0 if diec>200:goto *out #else if diec>200 { flg=1 } else { flg=0 } #endif



SYAM

リンク

2010/3/23(Tue) 10:18:52|NO.31490

むしろ初心者かどうかに関わらず、「アラ探し」はするもんじゃないと思うなー。
…とだけ書くのも勿体無いので ご質問の文から思ったチョイネタをひとつ。ご質問の内容とは関係ないですが。

bload 命令の前に exist 命令でファイルの有無を調べて、もし無ければデフォルトの内容でファイルを作る ようにしておくと後々便利かもしれないです。



しゅしゅ

リンク

2010/3/23(Tue) 11:13:45|NO.31491

>晩御飯さん
長ーいURLは
http://bit.ly/
ここで短縮するといいですよ。しないとレイアウトが崩れます。
短縮すれば
http://bit.ly/9ogBn9
これくらいになります。



くるり

リンク

2010/3/23(Tue) 11:16:46|NO.31492

なるほど、サブルーチンですね。
直してみます、ありがとうございました。



晩御飯

リンク

2010/3/23(Tue) 12:27:38|NO.31493

>しゅしゅさん
少々無神経でした。覚えておきます。



ONION software Copyright 1997-2023(c) All rights reserved.