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

天行健 君子當(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) 評(píng)論(0)  編輯 收藏 引用


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


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

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

搜索

最新評(píng)論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            一个人看的www久久| 亚洲在线黄色| 欧美成人精品激情在线观看| 亚洲欧美日韩国产综合| 亚洲精品乱码久久久久久黑人| 美女脱光内衣内裤视频久久影院| 伊人精品成人久久综合软件| 蜜桃av久久久亚洲精品| 欧美成年人视频网站欧美| 国产精品热久久久久夜色精品三区| 亚洲午夜视频| 午夜精品短视频| 伊人狠狠色丁香综合尤物| 亚洲第一福利在线观看| 欧美视频专区一二在线观看| 午夜视频一区二区| 久久久久网站| 一区二区三区四区五区视频| 亚洲欧美国产不卡| 亚洲欧洲精品一区| 在线视频欧美日韩| 在线看片欧美| 亚洲一二三区视频在线观看| 国内精品国产成人| 99人久久精品视频最新地址| 国产亚洲第一区| 91久久夜色精品国产九色| 国产精品久久久久9999| 欧美aⅴ一区二区三区视频| 欧美日韩免费观看一区三区| 久久国产精品99国产| 欧美国产亚洲视频| 久久漫画官网| 国产精品jizz在线观看美国| 你懂的国产精品| 国产精品羞羞答答| 亚洲精品久久久蜜桃 | 免费不卡在线观看av| 欧美日韩精品欧美日韩精品一| 久久精品99久久香蕉国产色戒| 久久午夜羞羞影院免费观看| 亚洲欧美视频在线观看| 欧美成人精品在线观看| 久久久久成人精品| 欧美午夜在线视频| 亚洲欧洲中文日韩久久av乱码| 国产综合久久| 亚洲免费小视频| 亚洲一区日韩在线| 欧美人成在线视频| 欧美激情精品久久久久久免费印度 | 欧美在线精品免播放器视频| 欧美电影专区| 欧美国产综合| 1204国产成人精品视频| 久久超碰97中文字幕| 午夜精品国产更新| 国产精品成人在线观看| 一本色道久久88亚洲综合88| 亚洲伦理在线| 欧美日韩高清一区| 亚洲美女91| 99精品国产在热久久| 欧美成人精品在线视频| 欧美顶级大胆免费视频| 亚洲第一福利在线观看| 久久精品国语| 欧美成人有码| 亚洲人在线视频| 欧美好骚综合网| 亚洲精品一二区| 亚洲午夜免费视频| 国产精品欧美日韩一区二区| 亚洲一区二区三区成人在线视频精品| 亚洲桃色在线一区| 国产精品美女主播在线观看纯欲| 亚洲视频欧美在线| 欧美一区二区视频在线| 久久久99爱| 欧美大片在线看免费观看| 亚洲国产精品一区二区尤物区 | 一区二区三区国产| 亚洲在线国产日韩欧美| 国产精品揄拍500视频| 欧美成人a视频| 亚洲毛片一区二区| 国产精品久久久久久久久久久久久 | 久久狠狠婷婷| 亚洲电影免费在线观看| 欧美大片一区二区| 亚洲午夜在线视频| 久久久久久色| 亚洲美女网站| 国产精品久久一卡二卡| 久久国产精品毛片| 亚洲精品日韩欧美| 久久成年人视频| 91久久精品国产| 欧美亚一区二区| 久久噜噜亚洲综合| 一区二区三区www| 免费中文日韩| 亚洲欧美日韩高清| 亚洲黄色视屏| 国产伦理精品不卡| 欧美激情综合在线| 欧美一区午夜视频在线观看| 亚洲国产影院| 久久日韩精品| 亚洲综合不卡| 91久久精品网| 国内精品嫩模av私拍在线观看| 欧美日韩xxxxx| 久久九九国产| 亚洲女人天堂av| 亚洲日本成人网| 免费不卡视频| 久久精品视频免费| 亚洲免费伊人电影在线观看av| 禁久久精品乱码| 国产麻豆精品在线观看| 欧美日韩性生活视频| 免费观看日韩| 欧美一区视频在线| 亚洲一区二区在线观看视频| 亚洲高清视频一区二区| 久久夜色精品国产噜噜av| 亚洲欧美中文另类| 亚洲天堂av图片| 日韩一级视频免费观看在线| 亚洲电影中文字幕| 黑人巨大精品欧美黑白配亚洲| 香蕉免费一区二区三区在线观看 | 中国女人久久久| 亚洲美女中文字幕| 亚洲人午夜精品| 亚洲激情国产精品| 亚洲成色www久久网站| 麻豆国产精品一区二区三区 | 亚洲理论电影网| 一区二区在线视频播放| 国产夜色精品一区二区av| 国产精品入口尤物| 国产欧美一区二区精品仙草咪| 国产精品a久久久久| 国产精品久久激情| 国产精品免费在线| 国产精品视频久久久| 国产精品视频yy9299一区| 国产精品一二一区| 国产日韩欧美不卡| 一区二区三区在线视频观看| 韩国一区二区三区在线观看| 狠狠网亚洲精品| 亚洲第一色在线| 亚洲日本欧美| 亚洲天堂偷拍| 欧美在线一级视频| 久久综合亚州| 亚洲国产第一页| 一区二区久久久久| 午夜欧美不卡精品aaaaa| 久久精品91| 欧美黄色精品| 国产精品网站在线观看| 狠狠色综合色区| 亚洲精品乱码久久久久久| 亚洲图片欧洲图片日韩av| 久久aⅴ国产紧身牛仔裤| 久久综合激情| 亚洲精品日本| 欧美一区二区三区在线播放| 久久深夜福利免费观看| 欧美日韩另类丝袜其他| 国产精品网站一区| 亚洲国产一区二区精品专区| 亚洲一区二区三区在线| 久久午夜电影网| 亚洲美女视频在线观看| 性高湖久久久久久久久| 欧美精品在线观看播放| 国产精品午夜在线| 最新亚洲视频| 久久精品国产亚洲5555| 亚洲国产精品一区制服丝袜 | 麻豆精品网站| 中文有码久久| 免播放器亚洲| 国产精品一区一区| 日韩亚洲欧美成人| 久久久免费精品视频| 日韩小视频在线观看| 久久久久久久网站| 国产精品毛片a∨一区二区三区|国| 亚洲成色999久久网站| 欧美在线播放一区| 亚洲精品久久久久| 久久综合网络一区二区| 国产女主播一区二区| 一区二区三区免费网站|