TEST4
画面モジュールを作ってみました。
適当なフォルダに次のファイルを用意し、HSPでxana_test4.hspを実行してみて下さい。
- common.hsp (ここからゲット)
- xana_test4.hsp (↓からゲット)テストスクリプト
- xana_screen.hsp (↓からゲット)画面表示用モジュール
- Xana_tile070401-3.png (DENZI部屋さんのところからゲット) ※XANADU風タイル(ステータス)をbmp保存して下さい
テスト方法
- A〜Fキー でメッセージ欄に表示します。
- Gキー でバトル表示に変更します。
- Hキー で通常表示に変更します。
- ESCキー で終了します。
前回作ったスクリプトの画面を合成したら、それらしくなりましたw
次は、スクリプトを合成していきたいと思います。
スクリプトは、今後も改良していく予定です。
xana_test4.hsp
; ; プログラム :「ウソザナ」を作ってみる TEST4 ; ; 作成 :ふじぽん ; ; Copyright :http://d.hatena.ne.jp/fujiponXP ; ; 利用素材 : ; ; □ドット絵 :DENZI部屋(http://www3.wind.ne.jp/DENZI/diary/) ; タイトル :XANADU風タイル(ステータス) ; 更新日 :2007年04月01日 ; ファイル名:Xana_tile070401-3.png ※BMP形式で利用します。 ; ; 変更履歴 ; ver.1.0 2009/11/21 新規作成 ; ; ライセンスに関する表示 #include "common.hsp" about_lisence ; グローバル定数 #module ; ウィンドウID #const global sid_main 0 ; 描画用 #const global sid_scrload 4 ; 画面読み込み用 ; 定数 #const global cx 32 ; キャラクターサイズX #const global cy 32 ; キャラクターサイズY #const global wtime 50 ; 描画待ち時間(ms) #const global mapsizex 9 ; マップサイズX #const global mapsizey 9 ; マップサイズY #global ; モジュール読み込み #include "xana_screen.hsp" ; 画面生成 newmod a, m_screen, "Xana_tile070401-3.bmp" m_scName a, "Fujipon" m_scTitle a, "NoviceFighter" m_scHitPoints a, 1250 m_scGold a, 12500 m_scFood a, 7845 m_scExpAt a, 1000 m_scExpMg a, 0 m_scWepon a, "Dagger" m_scMagic a, "Needle" m_scWear a, "Cloth" m_scShield a, "Gloves" m_scItem a, "Spectacles" m_scDraw a, 0 *main getkey key, 65: if key : m_scMes a, "Killed+" + rnd(100) + "exp" ; A getkey key, 66: if key : m_scMes a, "Get " + rnd(100) + "gold" ; B getkey key, 67: if key : m_scMes a, "Get-Lamp" ; C getkey key, 68: if key : m_scMes a, "Open-Door" ; D getkey key, 69: if key : m_scMes a, "Use Key" ; E getkey key, 70: if key : m_scMes a, "You lost Key" ; F getkey key, 71 ; G if key { m_scMonName a, "Fire-Element" repeat rnd(9)+1 m_scMonHP a, cnt, rnd(100)*100 loop m_scDraw a, 1 } getkey key, 72: if key : m_scDraw a, 0 ; H await wtime goto *main
xana_screen.hsp
; ; モジュール定義:「ウソザナ」画面表示用 ; 作成 :ふじぽん ; ; モジュール名 :m_xana_screen ; ; モジュール変数:メッセージ表示Y位置mespos, 表示情報数値配列v_int, 表示情報文字列配列v_str ; ; Copyright :http://d.hatena.ne.jp/fujiponXP ; ; 変更履歴 ; ver.1.0 2009/11/21 新規作成 ; #module m_screen mespos, v_int, v_str ;マクロ定義 #define C_BLACK 0, 0, 0 #define C_GLAY 120,120,120 #define C_RED 255, 0, 0 #define C_BLUE 0, 0,255 #define C_WHITE 255,255,255 #define C_FONT_SIZE 11 ; 変数初期化 #modinit str chipfile dim v_int, 28, 4 ; 位置x, 色r,g,b sdim v_str, 28 ; 表示文字列 ; 変数設定 mespos = 0 ; 画面設定 screen sid_main, cx * (mapsizex + 7), cy * (mapsizey + 1): title "ウソザナ" buffer sid_scrload: picload chipfile ;マップ枠描画 gsel sid_main repeat ginfo_sy/16: y=cnt repeat ginfo_sx/16: x=cnt pos x*16,y*16: gcopy sid_scrload, 64, 0, 16, 16 loop loop color C_BLACK : boxf 16 - 2, 16 - 2, cx * mapsizex + 16 + 2, cy * mapsizey + 16 + 2 color C_BLUE : boxf 16 , 16 , cx * mapsizex + 16 , cy * mapsizey + 16 ; ステータス欄 color C_BLACK: boxf (mapsizex*2+2)*16-2, 2, (mapsizex*2+13)*16+13, 19*16+13 color C_GLAY : boxf (mapsizex*2+2)*16 , 4, (mapsizex*2+13)*16+11, 19*16+11 ; メッセージ欄 color 0, 0, 0: boxf (mapsizex*2+2)*16+4, 7*32+4, (mapsizex*2+13)*16+8, 19*16+8 color 255, 0, 0: boxf (mapsizex*2+2)*16+6, 7*32+6, (mapsizex*2+13)*16+6, 19*16+6 color 0, 0, 0: boxf (mapsizex*2+2)*16+8, 7*32+8, (mapsizex*2+13)*16+4, 19*16+4 ; フォント設定 font "Georgia", C_FONT_SIZE, font_bold m_ValueSet thismod, 2, 0, C_BLACK, "Hit Points" m_ValueSet thismod, 4, 0, C_BLACK, "Gold" m_ValueSet thismod, 6, 0, C_BLACK, "Food" m_ValueSet thismod, 8, 0, C_BLACK, "Experience" m_ValueSet thismod, 11, 0, C_BLACK, "Equipment" return ; 表示情報セット #modfunc m_ValueSet int py, int px, int pr, int pg, int pb, str pv v_int.py.0 = px ; 表示X位置 v_int.py.1 = pr ; 赤色 v_int.py.2 = pg ; 緑色 v_int.py.3 = pb ; 青色 v_str.py = pv ; 文字列 return ; 表示 flg(0:通常 1:戦闘) #modfunc m_scDraw int flg redraw 0 color C_GLAY boxf 20 * 16, 4, 30 * 16 + 27, 12 * 19 - 1 repeat 17 n = cnt + (cnt > 5) * 11 * flg m_scPrint v_int.n.1, v_int.n.2, v_int.n.3, v_int.n.0, cnt, v_str.n loop redraw 1 return ; メッセージ表示 #modfunc m_scMes str p1 if msgpos > 4 { x = (mapsizex + 1) * 32 + 10: y = 7 * 32 + 10 repeat 14 pos x, y gcopy sid_main, x, y + 1, 10 * 16 + 7, 5 * 16 -6 await 10 loop msgpos = 4 } redraw 0 m_scPrint C_WHITE, 1, 18 + msgpos, p1 redraw 1 msgpos += 1 await 10 return ; 文字列表示 #deffunc m_scPrint int pr, int pg, int pb, int px, int py, str ps x = px * C_FONT_SIZE + 10 * 32 + 4 y = py * (C_FONT_SIZE+2) + 4 ; 影表示 s = ps if (pr + pb + pg) > 0 { color C_BLACK repeat strlen(s) pos x + 2 + cnt * (C_FONT_SIZE+1), y + 1: mes strmid(s, cnt, 1) loop } ; 文字表示 color pr, pg, pb repeat strlen(s) c = strmid(s, cnt, 1) pos x + 0 + cnt * (C_FONT_SIZE+1), y: mes c pos x + 1 + cnt * (C_FONT_SIZE+1), y: mes c loop return ; 名前 #modfunc m_scName str ps m_ValueSet thismod, 0, 0, C_RED, ps return ; 称号 #modfunc m_scTitle str ps m_ValueSet thismod, 1, 0, C_WHITE, ps return ; 体力 #modfunc m_scHitPoints int p1 m_ValueSet thismod, 3, 5, C_WHITE, strf("%07d", p1) return ; 所持金 #modfunc m_scGold int p1 m_ValueSet thismod, 5, 5, C_WHITE, strf("%07d", p1) return ; 食料 #modfunc m_scFood int p1 m_ValueSet thismod, 7, 5, C_WHITE, strf("%07d", p1) return ; 攻撃経験値 #modfunc m_scExpAt int p1 m_ValueSet thismod, 9, 5, C_WHITE, strf("%07d", p1) return ; 魔法経験値 #modfunc m_scExpMg int p1 m_ValueSet thismod, 10, 5, C_WHITE, strf("%07d", p1) return ; 武器 #modfunc m_scWepon str ps m_ValueSet thismod, 12, 0, C_RED, ps return ; 魔法 #modfunc m_scMagic str ps m_ValueSet thismod, 13, 0, C_RED, ps return ; 装備 #modfunc m_scWear str ps m_ValueSet thismod, 14, 0, C_RED, ps return ; 盾 #modfunc m_scShield str ps m_ValueSet thismod, 15, 0, C_RED, ps return ; 道具 #modfunc m_scItem str ps m_ValueSet thismod, 16, 0, C_RED, ps return ; モンスター名 #modfunc m_scMonName str ps for i, 17, 28, 1 if i = 18 { m_ValueSet thismod, i, 0, C_BLACK, ps } else { m_ValueSet thismod, i, 0, C_BLACK, "" } next return ; モンスター体力 #modfunc m_scMonHP int p1, int p2 m_ValueSet thismod, 19 + p1, 5, C_WHITE, strf("%07d", p2) return #global