“RUN” それは魔法の言葉

私とコンピュータの思い出を、だらだらと綴ります。

58.ゲーム&ウォッチのマンホールを作ろう その5

問題は通行人の出現パターンだった。
ゲーム&ウォッチなので、何らかのロジックでパターンを発生させていると想像はできるのだが、いかんせん、法則がわからない。
ここで、できる人は、ロジックで何とかするんだろうけど、作っているのは凡人の私。じゃあ、力業だ!と通行人の出現パターンをデータで持つことにしたww

パターンといっても単純ではない。なんせミスターマンホールは1か所しか支えられない。
だから、同時に穴に落ちるような通行人の出現パターンが存在してはならないということ。
画面いっぱいに通行人が埋まっても、ちゃんとさばけるようにならないとだめ。それが脳汁がでるこのゲームの醍醐味♪

Excelにパターンを作って、その登場するタイミングと上下のどちらかを表す文字列を関数で生成した。
上下段はUかDで表した。タイミングはタイマーイベントごとにカウントアップするカウンタを用意して、その値を後ろにくっつけた。
なので、U11,D16のような文字列で出現パターンを表した。

f:id:CORO3:20210104225954p:plain

!通行人出現パターン
ARRAY.LOAD pa_ptn$[],"D11","U21","D31","U41","D48","D56",~
"D63","D67","U76","D83","D90","U96",~
"D100","U104","U110","D117","U121","U125","U129","U133",~
"U137","D142","U148","D153","U157","U159","D165","D169",~
"D171","U175","U177","D183","U187","U189","U194","U196",~
"D200","U204","U211","D212","D220","U221","U227","D228",~
"D234","U235","U241","D242","D247","D253","U257","U259",~
"U261","D265","D267","U271","D275","D277","D279","U283",~
"D293","D295","U301","U306","U308","U313","D318","D320",~
"U326","D331","D336","D338","U343","U345","U349","U351",~
"D355","D357","U361","D365","D367","D369","U373","U377",~
"U379","D383","U387","U391","D395","D397","U401","U403",~
"U405","D409","D411","U415","U417","U419","U421","U423",~
"D427","D429","U433","U435","U437","D441","D443","D447",~
"U455","D461","D468","D475","U480","D484","D488","D492",~
"U496","U502","D503","D509","U513","U515","D519","U523",~
"U525","D529","U533","D537","D539","D543","D545","U549",~
"D553","U557","D561","D563","U567","U569","U571","D575",~
"D579","D581","U585","U587","U589","D593","D595","D600",~
"U604","U606","U608","D612","D614","U618","U620","U622",~
"D626","D628","D630","D632","D634","U642","U646","D647",~
"D654","D656","U660","D661","D665","D667","D669","D673",~
"U677","U679","U681","U683","D687","D689","U691","D698",~
"U700","U702","D706","D708","U710","U715","D717","D719",~
"D721","D723","U725","U727","U729","U731","U733","D737",~
"D739","U741","U743","U745","D747","D751","U753","U755",~
"U757","U759","D761","D765","U767","U769","U771","D778",~
"D780","D786","U792","D796","U800","U804","U806","U808",~
"D814","D822","U823","D828","U830","U832","U834","U836",~
"D838","D843","U845","U847","U849","U851","D853","D855",~
"D857","U859","U864","D866","D868","D870","D872","U874",~
"U876","U878","U880","D882","D887","U889","U891","U893",~
"D895","D897","D899","D901","D903","U907","U909","D911",~
"D913","U924","U929","U931"
ARRAY.LENGTH pa_size,pa_ptn$[]

前回のエントリーで書いたように、タイマーで処理を繰り返すようにしたので、そのたびにカウンタを+1するようにして、文字の後ろの数字とカウンタの数値が一緒になったら、通行人を追加するようにした。

!通行人を追加
IF count=VAL(MID$(pa_ptn$[pa_count],2)) THEN
 IF LEFT$(pa_ptn$[pa_count],1)="U" THEN
  upa += 512
 ELSE
  dpa += 512
 ENDIF
 pa_count+=1
 IF pa_count>=pa_size THEN pa_count=1:count=0
ENDIF

これを組み込んで、パターンに矛盾がないかをチェックしつつ、気持ちよく遊べるように調整した。