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

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

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 閱讀(209) 評論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

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

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            久久免费视频观看| 欧美激情网友自拍| 国产精品一区二区三区成人| 亚洲午夜久久久久久久久电影院 | 免费不卡在线观看| 久久久久久97三级| 亚洲黄色成人网| 亚洲黄色在线观看| 欧美日韩免费一区二区三区视频| 亚洲一区二区在线播放| 亚洲永久免费av| 好看的日韩视频| 亚洲国产综合91精品麻豆| 欧美精品色一区二区三区| 亚洲一区制服诱惑| 欧美亚洲免费在线| 亚洲激情欧美| 亚洲一区二区高清| 国产主播一区二区三区四区| 欧美福利影院| 国产精品乱码| 美女精品网站| 国产精品xxx在线观看www| 久久久综合香蕉尹人综合网| 欧美肥婆bbw| 欧美影院午夜播放| 欧美www视频在线观看| 亚洲欧美日韩精品久久| 久久婷婷成人综合色| 亚洲视频一区| 狂野欧美性猛交xxxx巴西| 在线视频欧美精品| 久久精品国产精品亚洲| 亚洲视频免费在线观看| 久久精品在线免费观看| 亚洲视频福利| 你懂的一区二区| 久久久精品动漫| 欧美日韩在线不卡| 欧美电影在线观看完整版| 国产美女精品| 日韩视频在线一区| 亚洲欧洲在线免费| 久久精品最新地址| 欧美在线观看天堂一区二区三区| 欧美www视频在线观看| 久久久久在线观看| 国产九九精品| 夜夜嗨av一区二区三区免费区| 在线精品国产成人综合| 欧美一级在线播放| 销魂美女一区二区三区视频在线| 欧美国产一区二区三区激情无套| 久久免费视频在线| 国产日韩成人精品| 亚洲欧美日韩国产成人精品影院| 一本久久a久久精品亚洲| 久久中文精品| 免费日韩精品中文字幕视频在线| 国产一区二区三区奇米久涩| 亚洲一区二区在| 亚洲欧美日韩视频二区| 国产精品福利网| 一二三四社区欧美黄| 一区二区欧美日韩| 欧美久久在线| 亚洲毛片av在线| 亚洲午夜未删减在线观看| 欧美精品亚洲精品| 亚洲精品一区二区三区福利| 9人人澡人人爽人人精品| 欧美激情综合五月色丁香| 亚洲人成久久| 国产精品99久久不卡二区| 欧美视频日韩视频在线观看| 一级成人国产| 久久黄色网页| 黄色小说综合网站| 农村妇女精品| 一本大道久久a久久综合婷婷| 在线亚洲自拍| 国产欧美一区二区精品秋霞影院 | 91久久国产综合久久| 99国内精品久久| 欧美日本一道本在线视频| 一区二区三区日韩欧美精品| 欧美一区影院| **欧美日韩vr在线| 欧美精品一区二区在线播放| av成人免费在线观看| 久久国产精品99国产精| 亚洲第一在线综合网站| 欧美日本国产| 午夜精品剧场| 欧美国产大片| 亚洲性感美女99在线| 国产一区二区黄| 欧美成人精品福利| 国产精品99久久久久久人 | 一区二区三区国产在线| 国产欧美一区二区三区国产幕精品| 欧美一级在线视频| 亚洲黄色影院| 久久精品国产综合| 亚洲美女视频在线免费观看| 国产欧美日本在线| 欧美成年人视频网站| 亚洲专区一区| 亚洲国产欧美另类丝袜| 先锋影音国产一区| 91久久在线| 国产三区二区一区久久| 欧美人妖另类| 久久久五月天| 亚洲欧美成人在线| 亚洲日本精品国产第一区| 久久久综合网站| 亚洲综合首页| 日韩视频在线永久播放| 激情综合中文娱乐网| 国产精品视频免费在线观看| 欧美激情国产精品| 久久精品人人| 亚洲伊人网站| 一本综合精品| 亚洲免费高清| 亚洲二区在线观看| 蜜臀a∨国产成人精品| 欧美在线精品一区| 午夜精品短视频| 亚洲视频第一页| 一本久久a久久精品亚洲| 亚洲高清三级视频| 一区二区三区在线不卡| 国产日韩欧美二区| 国产精品手机视频| 国产精品久久久久一区二区| 欧美日韩高清在线观看| 欧美华人在线视频| 欧美成人一区二区| 免费久久99精品国产| 久久久久久夜| 久久天天躁夜夜躁狠狠躁2022 | 一区二区三区高清视频在线观看 | 欧美一级黄色录像| 亚洲专区一二三| 正在播放欧美视频| 亚洲图片欧美一区| 亚洲一区二区3| 亚洲欧美欧美一区二区三区| 亚洲欧美日韩综合aⅴ视频| 这里只有精品视频在线| 亚洲在线观看视频网站| 亚洲综合精品自拍| 亚洲宅男天堂在线观看无病毒| 亚洲伊人网站| 欧美在线关看| 裸体女人亚洲精品一区| 亚洲国产毛片完整版| 亚洲精品影院在线观看| 亚洲网址在线| 久久国产精彩视频| 免费成人黄色| 欧美日韩一区二区在线播放| 国产精品久久久久av免费| 国产欧美一区二区三区沐欲 | 欧美暴力喷水在线| 欧美日韩国产片| 国产精品专区第二| 在线观看免费视频综合| 亚洲欧洲精品一区二区精品久久久| 日韩一二三在线视频播| 欧美一级专区免费大片| 欧美成人乱码一区二区三区| 亚洲欧洲日韩综合二区| 亚洲一区中文字幕在线观看| 久久久欧美一区二区| 欧美精品videossex性护士| 国产精品欧美日韩| 亚洲福利国产| 性久久久久久久久久久久| 欧美成人综合| 亚洲一区二区在线免费观看视频| 久久久噜噜噜久久中文字幕色伊伊| 欧美片网站免费| 红桃视频成人| 亚洲综合色噜噜狠狠| 蜜桃av一区二区在线观看| 日韩一级不卡| 久久亚洲图片| 国产精品一页| 一区二区动漫| 欧美aⅴ99久久黑人专区| 亚洲一区二区动漫| 欧美精品九九| 亚洲国产精品www| 欧美在线观看日本一区| 亚洲作爱视频| 欧美激情综合| 亚洲高清三级视频|