マップエディタ
Wikiで新しい記事を書こうと思って、それ用のプログラムを書いていた。
簡易マップエディタ。
マップチップの絵がダサいのは俺が描けないからであって、DXRubyの機能がしょぼいせいではない。
ついでにソースも。
# 簡易マップエディタ require 'dxruby' # マップデータ map = Array.new(32) { [1] * 32 } # 絵のデータを作る mapimage = [] for i in 0..3 mapimage.push(Image.new(32, 32)) end mapimage[0].box(0, 0, 31, 31, [255, 100, 100, 200]) # 海 mapimage[1].box(0, 0, 31, 31, [255, 50, 200, 50]) # 平地 mapimage[2].box(0, 0, 31, 31, [255, 50, 200, 50]) # 木 mapimage[2].box(13, 16, 18, 28, [255, 200, 50, 50]) mapimage[2].circleFill(16, 10, 8, [255, 0, 255, 0]) mapimage[3].box(0, 0, 31, 31, [255, 50, 200, 50]) # 山 for i in 1..30 do mapimage[3].line(15 - i/2, i, 16 + i/2, i, [255, 200, 100, 100]) end wakuimage = Image.new(36, 36).box(0, 0, 35, 35, [255, 255, 255, 255]) # 選択枠 select = 0 # メインループ Window.loop do # マウス左クリック if Input.mouseDown?(M_LBUTTON) then x, y = Input.mousePosX, Input.mousePosY if x >= 512 then # 右のほうなら for i in 0..3 if x >= 560 and x < 592 and y >= i * 64 + 64 and y < i * 64 + 96 then select = i break end end else # 左のほうなら if x > 0 and y > 0 and y < 480 then map[y/16][x/16] = select end end end # 選択枠描画 Window.draw(558, select * 64 + 62, wakuimage) # マップチップ描画 for i in 0..3 Window.draw(560, i * 64 + 64, mapimage[i]) end # 全体図描画 for i in 0..31 for j in 0..31 Window.drawEx(j * 16, i * 16, mapimage[map[i][j]], :centerx => 0, :centery => 0, :scalex => 0.5, :scaley => 0.5) end end if Input.keyPush?(K_ESCAPE) then p map break end end
こーいうものを作っていると、簡単なものが簡単に作れるのはDXRubyの最大の利点なのだろうと思う。
もちろん、ちょっとした追加機能ぐらいならすぐできるが、むちゃくちゃ本格的なものになると辛いのかもしれない。
マップエディタがどのレベルまで行けば本格的なのかはよくわからないが。