「ウソザナ」 TEST11
モンスターとのバトル後に出るお宝ゲット処理を作ってみました。
アイテム用モジュールスクリプトが追加になります。
適当なフォルダに次のファイルを用意し、HSPでxana_test11.hspを実行してみて下さい。
- common.hsp (ここからゲット)
- xana_test11.hsp (↓からゲット)テストスクリプト
- xana_my.hsp (ここからゲット)自キャラ用モジュール
- Xana_tile060227-4.PNG (DENZI部屋さんのところからゲット) ※XANADU風タイル(自キャラ)をbmp保存して下さい
- Xana_tile081213-1.PNG (DENZI部屋さんのところからゲット) ※XANADU風タイル(マップ)をbmp保存して下さい
- Xana_tile070401-5.PNG (DENZI部屋さんのところからゲット) ※XANADU風タイル(アイテム)をbmp保存して下さい
うまく起動するとこんな画面でアイテムをゲットすることができます。
テスト方法
- 矢印キー で上下左右に移動します。
- ESCキー で終了します。
ITEMBOXにぶつかると箱を開けます。
完全に開くとアイテムが出てきます。
アイテムを拾うと消えます。
音は鳴りません(早く実装したいヨォ)^^;
拾ったアイテムは使用できません。
次回は、前回作ったTEST10と組み合わせてみようと思います。
ウソザナ完成は、まだまだ、まだまだ先です。^^;
xana_test11.hsp
; ; プログラム :「ウソザナ」を作ってみる TEST11 ; ; 作成 :ふじぽん ; ; Copyright :http://d.hatena.ne.jp/fujiponXP ; ; 利用素材 : ; ; □ドット絵 :DENZI部屋(http://www3.wind.ne.jp/DENZI/diary/) ; ; タイトル :XANADU風タイル(自キャラ) ; 更新日 :2006年02月28日 ; ファイル名:Xana_tile060227-4.png ※BMP形式で利用します。 ; ; タイトル :XANADU風タイル(敵キャラ) ; 更新日 :2008年12月22日 ; ファイル名:Xana_tile081213-2.png ※BMP形式で利用します。 ; ; タイトル :XANADU風タイル(ステータス) ; 更新日 :2007年04月01日 ; ファイル名:Xana_tile070401-3.png ※BMP形式で利用します。 ; ; タイトル :XANADU風タイル(マップ) ; 更新日 :2008年12月22日 ; ファイル名:Xana_tile081213-1.png ※BMP形式で利用します。 ; ; タイトル :XANADU風タイル(アイテム) ; 更新日 :2007年04月02日 ; ファイル名:Xana_tile070401-5.png ※BMP形式で利用します。 ; ; 変更履歴 ; ver.1.0 2009/11/21 新規作成 ; ver.1.1 2009/11/22 TEST3(自・敵移動)+TEST4(ステータス表示) ; ver.1.2 2009/12/09 TEST6 ニセマップスクロール ; ver.1.3 2009/12/13 TEST6(マップスクロール)+TEST1(自移動) ; ver.1.4 2009/12/20 これまでのモジュール(自キャラ、モンスタ、画面、メニュー、共通)を組み合わせてみる ; ver.1.5 2009/12/26 バトル処理を作ってみる ; ver.1.6 2009/12/27 アイテム処理を作ってみる ; ; ライセンスに関する表示 #include "common.hsp" about_lisence ; 乱数発生の初期化 randomize ; 定数 #const global cx 32 ; キャラクターサイズX #const global cy 32 ; キャラクターサイズY #const global wtime 50 ; 描画待ち時間(ms) #const global HO_LEFT 0 ; 方向 左 #const global HO_RIGHT 1 ; 方向 右 #const global HO_UP 2 ; 方向 上 #const global HO_DOWN 3 ; 方向 下 #const global sid_main 0 ; 描画用 #const global sid_monload 11 ; モンスター読み込み用 #const global sid_moncopy 12 ; モンスターgcopy用 ; モジュール読込 #include "xana_my.hsp" #include "xana_item.hsp" screen sid_main,9*cx,9*cy: title "ウソザナ" celload "Xana_tile081213-1.bmp",1: celdiv 1,cx,cy ; マップチップ ; マップ変数定義 dim MapData,9,9 dim MapAction,9,9 MapData(0,0)= 1, 1, 1, 1, 1, 1, 1, 1, 1 MapData(0,1)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,2)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,3)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,4)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,5)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,6)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,7)= 0, 0, 0, 0, 0, 0, 0, 0, 1 MapData(0,8)= 0, 0, 0, 0, 0, 0, 0, 0, 1 ; 0=自由移動 1:移動不可 5:落下 MapAction(0,0)=1,1,1,1,1,1,1,1,1 MapAction(0,1)=1,0,0,0,0,0,0,0,1 MapAction(0,2)=1,0,0,0,0,0,0,0,1 MapAction(0,3)=1,0,0,0,0,0,0,0,1 MapAction(0,4)=1,0,0,0,0,0,0,0,1 MapAction(0,5)=1,0,0,0,0,0,0,0,1 MapAction(0,6)=1,0,0,0,0,0,0,0,1 MapAction(0,7)=1,0,0,0,0,0,0,0,1 MapAction(0,8)=1,1,1,1,1,1,1,1,1 ; 装備 ; 服 0:ノーマル赤 1:ノーマル白 2:レーザーアーマー 3:ハーフプレート 4:フルプレート ; 頭 0:なし 1:フルヘルム 2:プレートヘルム 3:赤髪 4:白髪 5:茶髪 ; 盾 0:なし 1:赤小 2:赤大 3:黒小 4:黒大 ; 武器 0:なし 1:剣 2:槍 3:杖 4:斧 5:弓 6:鈍器 dim eq , 4: eq.0 = 2, 3, 1, 1 dim eqmax, 4: eqmax.0 = 5, 6, 5, 7 ; 変数設定 eqpos = 0 ; 装備種類 ; 自キャラ生成 newmod my, charactor, "Xana_tile060227-4.bmp", sid_main, 0, 0 m_myEquip my, eq.0, eq.1, eq.2, eq.3 ; 装備 m_myPos my, cx, cy*3, HO_RIGHT m_myHpset my.cnt, 1250 ; アイテム生成 m_itmSetup "Xana_tile070401-5.bmp", sid_main, 0, 0 ; マップ描画 gsel sid_main for i,0,9 for j,0,9 pos j*cx,i*cy celput 1,MapData(j,i) next next newmod a, item, ITM_GOLD , ITM_NORMAL_BOX , 3*cx, 3*cy, ITM_STATUS_CLOSE newmod a, item, ITM_GOLD , ITM_NORMAL_BOX , 2*cx, 4*cy, ITM_STATUS_CLOSE newmod a, item, ITM_GOLD , ITM_NORMAL_BOX , 4*cx, 7*cy, ITM_STATUS_CLOSE newmod a, item, ITM_GOLD , ITM_NORMAL_BOX , 3*cx, 1*cy, ITM_STATUS_CLOSE newmod a, item, ITM_GOLD , ITM_NORMAL_BOX , 7*cx, 6*cy, ITM_STATUS_CLOSE newmod a, item, ITM_GOLD , ITM_NORMAL_BOX , 1*cx, 5*cy, ITM_STATUS_CLOSE newmod a, item, ITM_RED_POTION , ITM_SPECIAL_BOX, 6*cx, 2*cy, ITM_STATUS_CLOSE foreach a m_itmDisp a.cnt loop *start ; スクリーン表示 gsel sid_main ; 描画 redraw 1 m_mydisp my await wtime redraw 0 ; キー入力 stick key,255 if key&128 : end ; 終了 my_turn ; 自キャラ goto *start ; 自キャラ #deffunc my_turn ret = m_myWalk(my.0, key, MapAction) ; 移動処理 if ret { check_x = m_myNX(my.0) check_y = m_myNY(my.0) ; アイテムとの衝突チェック foreach a if m_itmHitcheck(a.cnt, check_x, check_y) { ; 衝突判定 ret = 0 if m_itmStatus(a.cnt) { if rnd(3)=0 : m_itmDisp a.cnt } else { wait 10 m_itmErase a.cnt delmod a.cnt } break } loop } if ret : m_myWalkcommit my.0 ; 移動確定 return
xana_item.hsp
; ; モジュール定義:「ウソザナ」アイテム用 ; 作成 :ふじぽん ; ; モジュール名 :item ; ; モジュール変数: ; indx, no, sp, x , y アイテム情報(インデックス,種類,特別,位置) ; sid_load, sid_copy, sid_draw SID(画像読込用,gcopy用,描画用) ; basex, basey 描画基本座標(左上) ; ; Copyright :http://d.hatena.ne.jp/fujiponXP ; ; 変更履歴 ; ver.1.0 2009/12/27 新規作成 ; #module item index, no, sp, x, y #const MAX 255 ; セットアイテム最大数 #const global ITM_STATUS_CLOSE 0 ; ステータス(クローズ) #const global ITM_STATUS_OPEN 3 ; ステータス(オープン) #const global ITM_NORMAL_BOX 0 ; アイテムボックス(通常) #const global ITM_SPECIAL_BOX 1 ; アイテムボックス(特別) #const global ITM_MATCK 0 ; マトック #const global ITM_FOOD 1 ; 食料 #const global ITM_BELL 2 ; 鈴 #const global ITM_STAFF 3 ; 杖 #const global ITM_SCROLL 4 ; 呪文書 #const global ITM_RING 5 ; 指輪 #const global ITM_NECKLACE 6 ; ネックレス #const global ITM_GOLD 7 ; ゴールド #const global ITM_NORMAL_BOX1 8 ; アイテムボックス(通常)1 #const global ITM_NORMAL_BOX2 9 ; アイテムボックス(通常)2 #const global ITM_NORMAL_BOX3 10 ; アイテムボックス(通常)3 #const global ITM_SPECIAL_BOX1 11 ; アイテムボックス(特別)1 #const global ITM_SPECIAL_BOX2 12 ; アイテムボックス(特別)2 #const global ITM_SPECIAL_BOX3 13 ; アイテムボックス(特別)3 #const global ITM_HOURGLASS 16 ; 砂時計 #const global ITM_SPECTACLES 17 ; 眼鏡 #const global ITM_CANDLE 18 ; 蝋燭 #const global ITM_CRYSTAL 19 ; 水晶 #const global ITM_HUMMER 20 ; ハンマー #const global ITM_BOOTS 21 ; ブーツ #const global ITM_SKULL 22 ; 頭蓋骨 #const global ITM_KNIFE 24 ; 武器:ナイフ #const global ITM_SPEAR 25 ; 武器:スピア #const global ITM_SHORT_SWORD 26 ; 武器:ショートソード #const global ITM_BROAD_SWORD 27 ; 武器:ブロードソード #const global ITM_BOW 28 ; 武器:弓 #const global ITM_NORMAL_ARROR 29 ; 武器:矢 #const global ITM_TWISTED_ARROR 30 ; 武器:ねじれた矢 #const global ITM_SHURIKEN 31 ; 武器:手裏剣 #const global ITM_MIRROR 32 ; 鏡 #const global ITM_LAMP 33 ; ランプ #const global ITM_CROWN 34 ; 王冠 #const global ITM_MANTLE 35 ; マント #const global ITM_NORMAL_JEWL 36 ; 宝石(通常) #const global ITM_SPECIAL_JEWEL 37 ; 宝石(特別) #const global ITM_BLACKONYX 38 ; ブラックオニキス #const global ITM_RUBY 39 ; ルビー #const global ITM_MACE 41 ; 武器:メイス #const global ITM_MURASAME_SWORD 42 ; 武器:ムラサメソード #const global ITM_AXE 45 ; 武器:斧 #const global ITM_LONG_SPEAR 46 ; 武器:ロングスピア #const global ITM_BUTTLE_AXE 47 ; 武器:戦闘用斧 #const global ITM_NORMAL_CLOTH 56 ; 装備:布の服(通常) #const global ITM_SPECIAL_CLOTH 57 ; 装備:布の服(特別) #const global ITM_CHAIN_MAIL 58 ; 装備:鎖帷子(胸) #const global ITM_FULL_MAIL 59 ; 装備:鎖帷子(頭+胸) #const global ITM_HALF_PLATE 60 ; 装備:鋼製鎧(半身) #const global ITM_HALF_LEATHER 61 ; 装備:レザーアーマー(半身) #const global ITM_FULL_LEATHER 62 ; 装備:レザーアーマー(全身) #const global ITM_FULL_PLATE 63 ; 装備:鋼製鎧(全身) #const global ITM_WHITE_ROBE 72 ; 装備:白ローブ #const global ITM_RED_ROBE 73 ; 装備:赤ローブ #const global ITM_MIX_ROBE 74 ; 装備:赤白ローブ #const global ITM_BATTLE_SUITS 75 ; 装備:バトルスーツ #const global ITM_BARBUTA 88 ; 兜:バルブータ #const global ITM_KNIGHT_HELM 89 ; 兜:ナイトヘルム #const global ITM_DEAMON_HELM 90 ; 兜:デーモンヘルム #const global ITM_FULL_HELM 91 ; 兜:フルヘルム #const global ITM_NOMAL_KEY 96 ; 鍵(通常) #const global ITM_SPECIAL_KEY 97 ; 鍵(特別) #const global ITM_NOMAL_GLOVE 98 ; 手袋(通常) #const global ITM_SPECIAL_GLOVE 99 ; 手袋(特別) #const global ITM_SPECIAL_BOOK 100 ; 本(特別) #const global ITM_NOMAL_BOOK 101 ; 本(通常) #const global ITM_RED_MUSHROOM 102 ; 赤キノコ #const global ITM_BLACK_MUSHROOM 103 ; 黒キノコ #const global ITM_NORMAL_SHIELD 104 ; 盾:ノーマルシールド #const global ITM_ROUND_SHIELD 105 ; 盾:ラウンドシールド #const global ITM_STEEL_SHIELD 106 ; 盾:鋼のシールド #const global ITM_SCUTUM 107 ; 盾:スクトゥム #const global ITM_DRAGON_SCUTUM 108 ; 盾:竜のスクトゥム #const global ITM_PINK_POTION 112 ; 薬(ピンク) #const global ITM_WHITE_POTION 113 ; 薬(白) #const global ITM_RED_POTION 114 ; 薬(赤) #const global ITM_BLOODY_POTION 115 ; 薬(赤黒) #const global ITM_SYLVER_POTION 116 ; 薬(銀) #const global ITM_BLACK_POTION 117 ; 薬(黒) #const global ITM_EMPTY_BOTTLE 118 ; 空瓶 ; セットアップ #deffunc m_itmSetup str fname, int p_draw, int p_basex, int p_basey ; 変数定義 dim status, MAX ; SID設定 sid_draw = p_draw ; 描画用SID sid_copy = ginfo_newid: buffer sid_copy, cx, cy*MAX ; 画像退避用SID sid_load = ginfo_newid: celload fname, sid_load: celdiv sid_load, cx, cy; オリジナル画像用 SID ; パラメータ設定 basex = p_basex: basey = p_basey ; 描画基本位置 ; アイテムリストを初期化 repeat MAX status(cnt) = -1 loop return ; 初期設定 #modinit int p_no, int p_sp, int p_x, int p_y, int p_status ; パラメータセット index = -1 repeat MAX if status(cnt) < 0: index = cnt: break loop if index < 0: dialog "アイテムリストがいっぱいです。中止します。": stop no = p_no: sp = p_sp: x = p_x: y = p_y: status(index) = p_status ; 描画前画像退避 gsel sid_copy: gmode 1, cx, cy pos 0, index*cy: gcopy sid_draw, x+basex, y+basey return ; 描画 #modfunc m_itmDisp ; 退避画像復元 m_itmErase thismod ; 描画 gsel sid_draw: pos x+basex, y+basey color 0, 133, 111: gmode 4, cx, cy, 255 if status(index) < ITM_STATUS_OPEN { celput sid_load, 8+sp*3+status(index) ; BOX } else { celput sid_load, no ; ITEM } status(index)++ return ; 退避画像復元 #modfunc m_itmErase gsel sid_main: gmode 0, cx, cy pos x+basex, y+basey: gcopy sid_copy, 0, index*cy return ; 当たり判定 #modcfunc m_itmHitcheck int px, int py return (abs(x - px) < cx) & (abs(y - py) < cy) ; 状態(0=オープン 1=クローズ) #modcfunc m_itmStatus ret = status(index)<ITM_STATUS_OPEN+1 return ret #global