青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Working with Maps and Levels(1)

Placing Characters on the Map

While going through the examples, I placed characters on the map in
a direct, hard-coded manner. However, remember that hard-coding game data is a
no-no. You need to have as much flexibility as possible when designing your maps,
and this includes placement of characters in a level.

Two methods for placing characters in maps that provide the flexibility you want
involve character map lists and scripts.

 

Character Map Lists

In numerous chapters, “Implementing Scripts,” I use external
data files that store a list of numbers and text. Those data files are loaded and
parsed into some useful information to the engine loading the data. Action templates,
for example, contain the action text plus the entry data for each action, all
in one easy-to-read-and-edit file.

To adhere to the simple nature of using text data files, you can create lists of characters
to place within a map when the map is loaded. Because players are placed in
a map using only a set of coordinates and a direction to face, this data file might
look something like the following:

0 100.0 0.0 450.0 0.0
21 0.0 0.0 -82.0 1.57
18 640.0 10.0 0.0 3.14

At first appearance, the preceding three lines of numbers are just that—a list of
numbers—but the trained eye sees that each number represents something. Starting
with the first number on each line, you have the following:

■ The character’s type (for example: 0=Main Character, 21=Ogre, 18=Child)
■ The X-coordinate, Y-coordinate, and Z-coordinate
■ The angle that the character is facing (in radians)

Now knowing what each number means, you can see that I defined three characters
and placed them through the map at their respective locations and pointed
them in a certain direction. This data is compact, easy to edit, and can be loaded
and processed quickly.

 

Loading Character Map Lists

To process the data files as just described, you need only two functions.
These functions are as follows:

long get_next_long_2(FILE* fp)
{
    
char buf[1024];
    
long pos = 0;    
    
    
for(;;)
    {
        
int c = fgetc(fp);

        
if(c == EOF || c == '\n' || (c == ' ' && pos) || pos == sizeof(buf)-1)
            
break;

        
if((c >= '0' && c <= '9') || c == '.' || c == '-')
            buf[pos++] = (
char)c;
    }

    
if(pos == 0)  // if there is no long value in file
        return -1;

    buf[pos] = 0;

    
return atol(buf);
}

/////////////////////////////////////////////////////////////////////////////////////////////

float get_next_float_2(FILE* fp)
{
    
char buf[1024];
    
long pos = 0;    

    
for(;;) 
    {
        
int c = fgetc(fp);

        
if(c == EOF || c == '\n' || (c == ' ' && pos) || pos == sizeof(buf)-1)
            
break;

        
if((c >= '0' && c <= '9') || c == '.' || c == '-')
            buf[pos++] = (
char)c;
    }

    buf[pos] = 0;

    
return (float)atof(buf);
}

Both functions take a file pointer (fp) as an argument and return the next long type
number or float type number found in the specified file. You arrange the character
map list data file so that the first number (the character type) is a long, although
the remaining numbers are float.

Using get_next_long_2 and get_next_float_2, you can parse an entire character map list as follows:

// fp = file pointer to open character map data file
long Type; // Character type to load
float XPos, YPos, ZPos, Direction;
long NumCharactersLoaded = 0; // # characters loaded

while(1)
{
  // Break if no more characters to process
  if((Type = get_next_long_2 (fp)) == -1)
    break;

  // Get coordinates and angle
  XPos = get_next_float_2(fp);
  YPos = get_next_float_2(fp);
  ZPos = get_next_float_2(fp);
  Direction = get_next_float_2(fp);

  // Do something with data - insert a character
  NumCharactersLoaded++; // Increase # characters loaded
}

// Done loading NumCharactersLoaded # of characters

 

posted on 2007-12-09 13:42 lovedday 閱讀(202) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美在线免费| 久久久九九九九| 久久日韩粉嫩一区二区三区| 亚洲在线一区二区| 欧美高清影院| 欧美激情视频在线免费观看 欧美视频免费一 | 欧美日韩不卡一区| 欧美顶级艳妇交换群宴| 国产一区二区福利| 午夜精品一区二区三区在线播放 | 亚洲一区二区3| 中国亚洲黄色| 欧美三级网址| 亚洲美女中文字幕| 一区二区欧美精品| 欧美日本精品| 夜夜嗨av一区二区三区免费区| 亚洲精品国产精品国自产观看浪潮 | 久久精品中文字幕一区二区三区| 欧美亚洲成人精品| 亚洲精品小视频| 亚洲精品国精品久久99热一| 免费国产自线拍一欧美视频| 美女任你摸久久| 一区二区视频免费在线观看 | 亚洲第一福利视频| 久久精品国产视频| 欧美.www| 日韩视频一区二区三区在线播放免费观看 | 亚洲精品美女91| 欧美成人免费在线观看| 亚洲国产精品va在线看黑人| 亚洲福利免费| 农村妇女精品| 亚洲乱码日产精品bd| 亚洲毛片网站| 欧美日韩中文在线观看| 亚洲美女视频在线观看| 亚洲午夜三级在线| 国产欧美一区二区白浆黑人| 欧美一区二区日韩一区二区| 久久亚洲精品一区二区| 亚洲高清不卡一区| 欧美日韩高清在线播放| 一本一本久久a久久精品综合妖精| 欧美一级成年大片在线观看| 国产一区二区三区的电影 | 久久久精品五月天| 91久久久久久久久| 欧美一区二区视频在线观看2020 | 欧美激情中文字幕乱码免费| 日韩一级裸体免费视频| 午夜国产精品视频免费体验区| 国产偷自视频区视频一区二区| 久久久天天操| 99国产精品久久久久久久成人热| 久久福利电影| 亚洲乱码国产乱码精品精| 国产美女精品一区二区三区| 美日韩在线观看| 亚洲欧美一区二区激情| 欧美国产在线视频| 欧美在线三级| 中日韩高清电影网| 在线观看日韩| 国产伦精品一区二区三区在线观看| 鲁大师影院一区二区三区| 一本久道久久综合狠狠爱| 久久综合国产精品| 亚洲欧美色一区| 亚洲激情视频在线播放| 国产精品外国| 欧美日韩小视频| 开心色5月久久精品| 亚洲一区二区三区久久| 亚洲国产精品久久久久婷婷884| 校园春色综合网| 日韩一区二区电影网| 在线观看日韩专区| 国产精品美女在线| 欧美日本国产精品| 欧美在线三区| 国产欧美一区二区三区视频| 一本色道久久综合亚洲精品高清 | 久久亚洲午夜电影| 国产精品露脸自拍| 欧美理论在线播放| 欧美亚洲三区| 欧美大尺度在线| 久久久久久九九九九| 亚洲午夜伦理| 99视频在线观看一区三区| 在线看国产一区| 狠狠操狠狠色综合网| 国产美女精品一区二区三区| 国产精品久久久对白| 欧美日韩mp4| 欧美日韩大陆在线| 欧美人与性动交cc0o| 欧美成人免费va影院高清| 欧美xx69| 欧美精品v日韩精品v国产精品| 蜜桃av一区二区| 美女露胸一区二区三区| 老妇喷水一区二区三区| 久久这里只精品最新地址| 久久综合九色综合欧美狠狠| 久久不射中文字幕| 久久久久www| 久久永久免费| 美女露胸一区二区三区| 蜜臀a∨国产成人精品| 男女激情久久| 欧美日韩123| 欧美色欧美亚洲另类七区| 亚洲欧美视频在线观看视频| 先锋影音久久久| 亚洲一区二区免费在线| 欧美二区在线播放| 欧美国产视频在线| 国产精品试看| 亚洲视频每日更新| 中国av一区| 亚洲一区精彩视频| 久久精品国产在热久久| 欧美日韩少妇| 亚洲日本乱码在线观看| 在线激情影院一区| 久久亚洲精选| 美女国产一区| 在线免费观看成人网| 欧美成人a视频| 亚洲国产精品一区二区三区| 亚洲欧美一区二区激情| 国产一区二区高清视频| 欧美中文在线观看国产| 一区二区三区国产精华| 欧美成人午夜激情视频| 亚洲美女福利视频网站| 亚洲第一在线综合在线| 国产日韩欧美精品| 欧美精品18videos性欧美| 亚洲国产欧美一区二区三区久久| 欧美风情在线观看| 亚洲伦理在线免费看| 午夜精彩国产免费不卡不顿大片| 久久er精品视频| 午夜欧美精品久久久久久久| 久久综合999| 欧美日韩一区二区视频在线| 国产人成一区二区三区影院| 亚洲高清不卡av| 欧美亚日韩国产aⅴ精品中极品| 宅男精品视频| 久久精品人人| 亚洲精品国产精品乱码不99| 欧美成人精品不卡视频在线观看| 美女成人午夜| 国产欧美在线视频| 免费影视亚洲| 夜夜嗨av一区二区三区免费区 | 亚洲国产高清aⅴ视频| 欧美视频不卡中文| 一区二区亚洲欧洲国产日韩| 在线成人av网站| 99国产精品久久| 久久久久久成人| 亚洲精品小视频在线观看| 久久这里有精品15一区二区三区| 国产精品v一区二区三区| 亚洲高清视频的网址| 国产精品xxxav免费视频| 91久久精品国产91久久性色tv| 亚洲盗摄视频| 欧美伊人影院| 欧美日韩网址| 91久久精品国产91久久性色tv| 性色av一区二区怡红| 亚洲专区欧美专区| 久久综合激情| 国产精品白丝黑袜喷水久久久| 亚洲精品免费在线| 久久亚洲欧美国产精品乐播| 亚洲午夜视频在线观看| 男女激情视频一区| 亚洲精品一区二区三区樱花 | 国产精品福利网站| 一区二区av| 亚洲黄色成人网| 久久这里有精品视频| 国内精品视频一区| 99视频精品全国免费| 亚洲免费大片| 欧美激情综合在线| 在线精品福利| 欧美ab在线视频| 欧美激情在线| 最新亚洲激情| 亚洲国产欧美国产综合一区| 女女同性女同一区二区三区91|