• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天行健 君子當(dāng)自強(qiáng)而不息

            游戲中物件的定義與使用(3)

             

            本篇是游戲中物件的定義與使用(2)的續(xù)篇。

             

            MIL編輯器的使用

            快速且容易地創(chuàng)建物件的需求誕生了MIL編輯器,MIL編輯器不過(guò)是一個(gè)windows應(yīng)用程序,它允許玩家操控物件列表,編輯每個(gè)想要的物件的屬性特征。可以保存和加載MIL,但是物件屬性的列表將保持固定不變(直到根據(jù)自己的意圖重編它們)。

            如下圖所示,該對(duì)話框由一個(gè)包含所有物件的列表框,以及編輯物件信息,保存和加載物件列表的按鈕組成。列表提供了1024個(gè)物件的空間,這意味著可以使用一個(gè)16位的變量去存儲(chǔ)物件的編號(hào)(范圍從0 - 1023)。

            To begin using the Master Item List Editor, locate and execute the MILEdit.exe file.

             At the Master Item List Editor dialog box, you can perform the following steps to add
            or edit items, and then save them to disk:


            1. Select an item from the Item List by double-clicking the item (or selecting
            the item and clicking the Edit button), or add an item by clicking the Add
            button. The Modify Item dialog box appears.


            2. Edit the appropriate fields in the Modify Item dialog box.


            3. When you finish editing, click OK to apply the changes and return to the
            Master Item List Editor dialog.


            4. To make the changes permanent, click Save on the Master Item List Editor
            dialog box, and in the Save MIL File dialog box, enter a filename and save
            the MIL to disk.

            The MIL Editor uses the same version of the sItem structure shown earlier, but I added
            some extra item categories. Those extra categories are Shield, Healing, and Container (a container object
            such as a backpack). Here these extra categories are added to the ItemCategories enum list, shown previously
            in the section “Items Categories and Values”:

            enum ItemCategories
            {
                 MONEY = 0, WEAPON, ARMOR,
                 SHIELD, ACCESSORY, EDIBLE,
                 HEALING, COLLECTION, TRANSPORTATION,
                 CONTAINER, OTHER
            };

            If you decide to modify the MIL Editor to use different item attributes or categories,
            modify the sItem structure as well. When you’re ready, you can start using
            the item data you created in your game project.

             

            Accessing Items from the MIL


            Once you have a MIL, you can load the entire list into an array of sItem structures
            using the following code:

            sItem Items[1024]; // Array of sItem structures

            // Open the Default.mil file
            FILE *fp = fopen(“Default.mil”, “rb”);

            // Read in all items
            for(short i=0;i<1024;i++)
                fread(&Items[i], 1, sizeof(sItem), fp);

            // Close file
            fclose(fp);

            At this point, I’m assuming that your item structure is relatively small and that you
            are using no more than 1,024 items in your MIL. What happens if you extend each
            item’s sItem structure or you begin storing more items in the MIL? We’re talking
            about some serious memory usage.


            To avoid loading each and every single item in memory from the MIL at once, you
            can access individual items directly from the MIL. Because the size of each item
            structure is fixed, you can access each item’s data by moving the file pointer to the
            appropriate position and reading in the structure, as in the following code bit:

            // ItemNum = reference # of item to load
            sItem Item;

            // Open the MIL file titled items.mil
            FILE *fp=fopen(“items.mil”, “rb”);

            // Seek to the appropriate position in file
            // based on the size of the sItem structure and
            // the number of the item to load.
            fseek(fp, sizeof(sItem) * ItemNum, SEEK_SET);

            // Read in the item structure
            fread(&Item, 1, sizeof(sItem), fp);

            // Close the file
            fclose(fp);


            And there you go—quick and easy access to every item in the MIL! Now, it’s time
            to do something with those items.


            posted on 2007-11-06 01:03 lovedday 閱讀(250) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            公告

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關(guān)鏈接

            搜索

            最新評(píng)論

            波多野结衣久久精品| 久久99国产亚洲高清观看首页| 久久精品国产一区二区三区| 国产精品无码久久四虎| 97香蕉久久夜色精品国产 | 亚洲国产精品无码久久SM| 蜜臀av性久久久久蜜臀aⅴ | 99久久国语露脸精品国产| 欧美777精品久久久久网| 久久se精品一区精品二区国产| 婷婷久久综合九色综合绿巨人| 亚洲午夜久久久久久噜噜噜| 亚洲国产精品人久久| 无码国产69精品久久久久网站| 久久精品无码一区二区三区日韩| 囯产极品美女高潮无套久久久 | 狠狠色丁香久久婷婷综合| 久久精品嫩草影院| 久久精品a亚洲国产v高清不卡| 久久久91人妻无码精品蜜桃HD | 久久久久成人精品无码 | 久久久久久久久久免免费精品| 日韩av无码久久精品免费| 久久综合九色欧美综合狠狠 | 9久久9久久精品| 久久精品国产亚洲av麻豆色欲 | 久久精品这里热有精品| 亚洲色婷婷综合久久| 看全色黄大色大片免费久久久| 91精品国产综合久久久久久| 国内精品伊人久久久久777| 亚洲国产成人久久笫一页| 国产精品99久久不卡| 久久免费高清视频| 欧美亚洲另类久久综合| 久久精品视频网| 九九久久精品无码专区| 香蕉久久夜色精品国产小说| 91久久精品国产成人久久| 亚洲中文精品久久久久久不卡| 亚洲天堂久久久|