• <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>

            天行健 君子當自強而不息

            Working with Maps and Levels(8)

            cTrigger::get_enable_state, cTrigger::set_enable_state, cTrigger::enable, cTrigger::disable

            The get_enable_state  function checks the current status of a trigger; by passing the
            trigger identification number, you get in return the state of the trigger. If a trigger
            is disabled, a call to get_enable_state  returns a value of false. If enabled, the return
            value is true. To enable or disable a trigger, call on the enable function, using the
            trigger's identification number as the only argument.

            Each of the two functions scans the linked list of sTrigger structures. For get_enable_state,
            the enabled flag value of the first structure found in the list that has a matching identification
            number as the number provided in the ID argument is returned.

            For the set_enable_state function, the linked list is scanned, and every instance of a structure
            with a matching identification number as passed in the ID argument has its enabled
            flag set to the value as provided in the Enable argument. Take a look at each function’s
            code:

            bool cTrigger::get_enable_state(long id)
            {
                
            for(sTrigger* trig = m_root_trigger; trig != NULL; trig = trig->next)
                {
                    
            if(trig->id == id)
                        
            return trig->enabled;
                }

                
            return false;
            }

            void cTrigger::set_enable_state(long id, bool state)
            {
                
            for(sTrigger* trigger = m_root_trigger; trigger != NULL; trigger = trigger->next)
                {
                    
            if(trigger->id == id)
                        trigger->enabled = state;
                }
            }

            cTrigger::get_num_triggers and cTrigger::get_root_trigger

            As I like to do with all my classes, I have included two functions that you can use to
            retrieve the number of sTrigger structures in the linked list as well as the pointer to
            the first structure (the root, or parent, structure) contained with the list.

             

            Using Triggers

            As I promised in the section, “Using Map Triggers,” you now revisit using files to store triggers
            on a map, this time using the cTrigger class created in the section “Creating a Trigger Class.”
            In this section, you find out how to define and load a trigger file effectively.

             

            Defining a Trigger File

            You start with a sample trigger data file (called test.trg):

            1 0 1 -900 0 900 620
            2 1 0 0 0 0 100 100 100
            3 2 1 100 10 200 20 100
            4 3 0 10 10 10 -100 -50 0 0 100

            The first trigger (ID# 1) is a sphere located at -900,0,900 with a radius of 620. The
            second trigger (ID# 2) is a box that covers the area from 0,0,0 to 100,100,100. The
            third trigger (ID# 3) is a cylinder; its lower-middle point is at 100,10,200, it has a
            radius of 20, and it extends up 100 units. The fourth trigger (ID# 4) is a triangle
            that encloses the area from 10,10 to 10,-100 to -50,0; it has a Y-coordinate (the bottom
            of the triangle) of 0 and extends 100 units upward. Notice that all other triggers
            are disabled by default.

             

            Loading a Trigger File

            To load the trigger file, instance the cTrigger file and call Load:

            cTrigger Trigger;
            Trigger.load(“test.trg”);

             

            Touching a Trigger

            Finally, to see whether a trigger is touched by a character, call GetTrigger with the
            character’s coordinates:

            long TriggerID;
            TriggerID = Trigger.get_trigger(CharXPos, CharYPos, CharZPos);
             

            if(TriggerID)
              MessageBox(NULL, “Trigger touched!”, “Message”, MB_OK);

            With this admittedly simplified example of loading and using the cTrigger class
            under your belt, you might want to work through the Mapping example program
            to get more experience with creating, loading, and checking for character-to-trigger
            collisions using the cTrigger class.


            posted on 2007-12-10 11:34 lovedday 閱讀(158) 評論(0)  編輯 收藏 引用

            公告

            導航

            統計

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關鏈接

            搜索

            最新評論

            国产亚洲精品自在久久| 久久久久久综合一区中文字幕| 国产国产成人久久精品| 久久成人国产精品一区二区| 国产高潮国产高潮久久久91| 久久久久亚洲爆乳少妇无| 77777亚洲午夜久久多喷| 精品久久久久久久无码 | 伊人久久大香线蕉综合5g| 久久久亚洲欧洲日产国码二区| 91精品国产高清久久久久久国产嫩草 | 国产99久久久国产精品小说| 国产人久久人人人人爽| 色99久久久久高潮综合影院| 国产精品一久久香蕉国产线看观看| 国产精品免费久久久久电影网| 婷婷综合久久中文字幕蜜桃三电影| 久久国产成人精品国产成人亚洲| 婷婷伊人久久大香线蕉AV| 无夜精品久久久久久| 久久精品国产久精国产| 久久精品无码一区二区无码| 亚洲精品99久久久久中文字幕| 秋霞久久国产精品电影院| 久久久久亚洲AV无码专区体验| 亚洲欧美日韩久久精品| 久久久亚洲精品蜜桃臀| 亚洲一区二区三区日本久久九| 欧洲成人午夜精品无码区久久 | 色综合久久天天综线观看| 久久精品免费观看| 久久噜噜电影你懂的| 久久福利青草精品资源站免费| 精品免费久久久久久久| 97精品久久天干天天天按摩| 韩国免费A级毛片久久| 9久久9久久精品| 91久久精品国产成人久久| 久久国产热这里只有精品| 久久精品无码一区二区三区日韩| 中文字幕亚洲综合久久2|