超基本的な機能だけのサムプルです。
ループ構造のマップの実装をしてます。(´ω`)
; 初期化
randomize
screen 0, 400, 400, 0, (ginfo(20)-400)/2, (ginfo(21)-400)/2
gosub *create_chip
gosub *create_map
px = 50 : py = 50
gsel 0 : gosub *draw_map
pos 0, 0 : font "MS Pゴシック", 16, 1 : color 255,255,255
mes "マウスクリックでマップスクロール開始\nマウスを動かせばその方向へスクロールします"
onclick goto *startscroll
stop
*startscroll
onclick 0
mcx = mousex : mcy = mousey
*main
; このwait値を減らせば高速になる
wait 2
; クリック時からのマウスの位置で移動方向を決める
; 遊びは±20dot
nx = mousex : ny = mousey
if (mcx-20)<nx { px -= 1 }
if (mcx+20)>nx { px += 1 }
if (mcy-20)<ny { py -= 1 }
if (mcy+20)>ny { py += 1 }
if px<0 { px = 99 }
if px>99 { px = 0 }
if py<0 { py = 99 }
if py>99 { py = 0 }
gosub *draw_map
goto *main
*draw_map
; px, py を中心座標として25x25のマップを描く
dim dmap, 25, 25
dx = px - 12 : dy = py - 12
; 仮マップの生成(マップ端の折り返しを処理する)
repeat 25
y = cnt : repeat 25
xx = dx + cnt
if xx < 0 { xx += 100 }
if xx > 99 { xx -= 100 }
yy = dy + y
if yy < 0 { yy += 100 }
if yy > 99 { yy -= 100 }
dmap(cnt,y) = map(xx,yy)
loop
loop
; マップを描画
redraw 0
repeat 25
y = cnt : repeat 25
; マップのチップ番号から、拾ってくるバッファの位置を決定
cx = dmap(cnt,y) \ 4 : cy = (dmap(cnt,y) - cx) / 4
; バッファからチップ画像をピーコ
pos cnt*16, y*16
gcopy 10, cx*16, cy*16, 16, 16
loop
loop
title "(x,y)="+str(px)+","+str(py)
redraw 1
return
*create_map
; 100x100のマップをテケトーに作る
; 0〜15の16種類のチップ番号で構成
dim map, 100, 100
repeat 100
y=cnt : repeat 100
map(cnt,y) = rnd(16)
loop
loop
return
*create_chip
; バッファ10番に16x16サイズのチップを16コ(4x4)テケトーに作る
; 0 1 2 3
; 4 5 6 7
; 8 9 10 11
; 12 13 14 15
; 64x64サイズのグラフィックを読み込むように変更するのもよろし
bgscr 10, 16*4, 16*4
repeat 4
_y=cnt : repeat 4
color rnd(255), rnd(255), rnd(255)
boxf cnt*16, _y*16, (cnt+1)*16, (_y+1)*16
loop
loop
return