亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? demo12_7_16b.cpp

?? 一本外國(guó)人寫的關(guān)于3D游戲編程的書的源碼
?? CPP
?? 第 1 頁(yè) / 共 5 頁(yè)
字號(hào):
// load the ant bitmaps
Load_Bitmap_File(&bitmap16bit, "ANTIMG24.BMP");

// create master ant
Create_BOB(&ants[0],320,200, 24,24, 9, BOB_ATTR_MULTI_ANIM | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY,0,16);

// load the ants in 
for (index=0; index < 9; index++)
    Load_Frame_BOB16(&ants[0], &bitmap16bit, index, index, 0, BITMAP_EXTRACT_MODE_CELL);


// set the animations
int ant_anim_up[3]    = {0,1,-1};
int ant_anim_right[3] = {2,3,-1};
int ant_anim_down[3]  = {4,5,-1};
int ant_anim_left[3]  = {6,7,-1};
int ant_anim_dead[2]  = {8,-1};

Load_Animation_BOB(&ants[0],0,2, ant_anim_up);
Load_Animation_BOB(&ants[0],1,2, ant_anim_right);
Load_Animation_BOB(&ants[0],2,2, ant_anim_down);
Load_Animation_BOB(&ants[0],3,2, ant_anim_left);
Load_Animation_BOB(&ants[0],4,2, ant_anim_dead);

Set_Anim_Speed_BOB(&ants[0],3);
Set_Animation_BOB(&ants[0], ANT_ANIM_UP);

// clone the ants
for (index=1; index < NUM_ANTS; index++)
    Clone_BOB(&ants[0], &ants[index]);

// initialize the ants
Init_Ants();

// create the mnm
Create_BOB(&mnm,0,0, 8,8, 1, BOB_ATTR_SINGLE_FRAME | BOB_ATTR_VISIBLE, DDSCAPS_SYSTEMMEMORY,0,16);

// load the mnm 
Load_Frame_BOB16(&mnm, &bitmap16bit, 0, 1, 141, BITMAP_EXTRACT_MODE_ABS);


// position all the mnms
int num_piles = 3+rand()%3;
int curr_mnm = 0;

for (int piles=0; piles < num_piles; num_piles++)
    {
    // plop down some mnms at the pile position
    int pile_x = 32 + rand()%400;
    int pile_y = rand()%480;

    // compute number of mnms for pile
    int num_mnms_pile = 5 + rand()%15;

    // now find a position for each
    for (index = 0; index < num_mnms_pile; index++)
        {
        // select random position and energy level for mnm
        food[curr_mnm].x = pile_x + rand()%20;
        food[curr_mnm].y = pile_y + rand()%20;
        food[curr_mnm].energy = 600 + rand()%1000;

        // increment total number of mnms thus far
        if (++curr_mnm >= NUM_MNMS)
           break;

        } // end for index

        if (++curr_mnm >= NUM_MNMS)
           break;

      } // end for pile 

// unload ant imagery
Unload_Bitmap_File(&bitmap16bit);

// initialize directinput
DInput_Init();

// acquire the keyboard only
DInput_Init_Keyboard();
DInput_Init_Mouse();

// initilize DirectSound
DSound_Init();

// load background sounds
niceday_sound_id = DSound_Load_WAV("NICEDAY.WAV");

// start the sounds
DSound_Play(niceday_sound_id, DSBPLAY_LOOPING);

// hide the mouse
if (!WINDOWED_APP)
   ShowCursor(FALSE);

// return success
return(1);

} // end Game_Init

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

int Game_Shutdown(void *parms)
{
// this function is where you shutdown your game and
// release all resources that you allocated

int index; // looping var

// shut everything down

// kill all the bobs
for (index = 0; index<NUM_ANTS; index++)
    Destroy_BOB(&ants[index]);

// shutdown directdraw last
DDraw_Shutdown();

// now directsound
DSound_Stop_All_Sounds();
DSound_Shutdown();

// shut down directinput
DInput_Shutdown();

// return success
return(1);
} // end Game_Shutdown

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

#if 0

// defines for ants
#define NUM_ANTS        16
#define ANT_ANIM_UP      0
#define ANT_ANIM_RIGHT   1
#define ANT_ANIM_DOWN    2
#define ANT_ANIM_LEFT    3

// states of ant
#define ANT_WANDERING             0   // moving around randomly
#define ANT_EATING                1   // at a mnm eating it
#define ANT_RESTING               2   // sleeping :)
#define ANT_SEARCH_FOOD           3   // hungry and searching for food
        #define ANT_SEARCH_FOOD_S1        31  // substate 1
        #define ANT_SEARCH_FOOD_S2        32  // substate 2
#define ANT_COMMUNICATING         4   // talking to another ant  
#define ANT_DEAD                  5   // this guy is dead, got too hungry

#define ANT_INDEX_HUNGER_LEVEL     0
#define ANT_INDEX_HUNGER_TOLERANCE 1 
#define ANT_INDEX_AI_STATE         2
#define ANT_INDEX_AI_SUBSTATE      3
#define ANT_INDEX_DIRECTION        4

#endif


void Init_Ants(void)
{
// this function initializes all the ant positions, states, etc.

int index;

for (index=0; index < NUM_ANTS; index++)
    {
    // set the position of ant
    ants[index].x = rand()%472;
    ants[index].y = rand()%screen_height;

    // set the hunger level and tolerance of this guy
    ants[index].varsI[ANT_INDEX_HUNGER_LEVEL]     = 0;

    // ant will die if hunger level reaches this
    ants[index].varsI[ANT_INDEX_HUNGER_TOLERANCE] = 2000+rand()%2000;  

    // set the ai state of ant
    ants[index].varsI[ANT_INDEX_AI_STATE] = ANT_WANDERING;

    // set last ant talked to as self
    ants[index].varsI[ANT_INDEX_LAST_TALKED_WITH] = index;

    // set how long to wander
    ants[index].counter_1 = RAND_RANGE(150, 300);

    // set direction
    ants[index].varsI[ANT_INDEX_DIRECTION] = RAND_RANGE(ANT_ANIM_UP, ANT_ANIM_LEFT);
    
    // time in that direction
    ants[index].counter_2 = RAND_RANGE(10, 100);

    // start animation
    Set_Animation_BOB(&ants[index], ants[index].varsI[ANT_INDEX_DIRECTION]);

    // init ant memory 
    memset(&ants_mem[index], 0, sizeof(ANT_MEMORY));

    } // end for index

} // end Init_Ants

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

void Draw_Ants(void)
{
// this function draws all the ants

int index;

for (index=0; index < NUM_ANTS; index++)
    {
    // draw the image
    ants[index].x-=8; ants[index].y-=8; // center ant
    Draw_BOB16(&ants[index], lpddsback);
    ants[index].x+=8; ants[index].y+=8; // fix center

    // draw a little number above ant
    sprintf(buffer,"%d", index);
    Draw_Text_GDI(buffer,ants[index].x,ants[index].y-16,RGB(0,255,0),lpddsback);

    // animate the ant
    if (ants[index].varsI[ANT_INDEX_AI_STATE] == ANT_WANDERING ||
        ants[index].varsI[ANT_INDEX_AI_STATE] == ANT_SEARCH_FOOD ||
        ants[index].varsI[ANT_INDEX_AI_STATE] == ANT_DEAD)
    Animate_BOB(&ants[index]);

 

    } // end for index

} // end Draw_Ants

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

float Food_Near_Ant(int cell_x, int cell_y)
{
// this functions scan all the food in the universe and tests if any is
// close to ant in this cell, if so the energy level of the food is scaled 
// and summed to the "memory" strength of that particular geographical location
// in the ants memory
// this algorithm is totally inefficient, in real life this was be called only
// once and all the cell based positions would be pre-computed since the mnms never
// move, but this is just to show you how you would do it if they could move...

int index; // looping var

float food_sum = 0; // used to tally up food in cell sector

// is this mnm in the current cell?
for (index = 0; index < NUM_MNMS; index++)
    {
    // is this mnm still there
    if (food[index].energy > 0)
       {
       // compute cell position, this is dumb, but needed if mnms can move, which
       // they could if you give the ants the ability to pick them up :)
       int mnm_x = food[index].x / 30;
       int mnm_y = food[index].y / 30;

       // is this within the same cell
       if (mnm_x == cell_x && mnm_y == cell_y)
          food_sum+=(food[index].energy/5);

       } // end if

    } // end for index

// now send it back 
return(food_sum);

} // end Food_Near_Ant

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

int Max_Food_In_Cell(int cell_x, int cell_y, int *food_x, int *food_y)
{
// this function finds the exact location of the mnm with the highest energy in a cell

float max_food = 0;   // used to tally up food in cell sector
int max_food_id = 0; // used to track winner

// is this mnm in the current cell?
for (int index = 0; index < NUM_MNMS; index++)
    {
    // is this mnm still there
    if (food[index].energy > 0)
       {
       // compute cell position, this is dumb, but needed if mnms can move, which
       // they could if you give the ants the ability to pick them up :)
       int mnm_x = food[index].x / 30;
       int mnm_y = food[index].y / 30;

       // is this within the same cell
       if (mnm_x == cell_x && mnm_y == cell_y)
          { 
          // is this higher energy
          if (food[index].energy > max_food)
             {
             // set this as new food
             max_food_id = index;
             max_food = food[index].energy;
             *food_x = food[index].x;
             *food_y = food[index].y;
             } // end if

          } // end if

       } // end if

    } // end for index

// now send it back 
return(max_food_id);

} // end Max_Food_In_Cell

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

int Select_State_Rand(int state1, int prob1,            
                      int state2, int prob2,    
                      int state3, int prob3,    
                      int state4, int prob4,    
                      int state5, int prob5,
                      int state6, int prob6)
{
// this function simply selects one of state1...state6 based on the probability
// of each state, if probi is 0 then the state is not considered

int index     = 0,   // looping variable
    curr_elem = 0,   // tracks next entry to place in table
    state_prob[100]; // used to hold generated probability look up

// build probability table
for (index = 0; index < prob1; index++)
    state_prob[curr_elem++] = state1;

for (index = 0; index < prob2; index++)
    state_prob[curr_elem++] = state2;

for (index = 0; index < prob3; index++)
    state_prob[curr_elem++] = state3;

for (index = 0; index < prob4; index++)

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃av噜噜一区二区三区小说| 国内成人免费视频| 欧美一区二区国产| 99久久精品国产导航| 欧美aⅴ一区二区三区视频| 国产精品日日摸夜夜摸av| 精品视频一区二区三区免费| 风间由美性色一区二区三区| 日本网站在线观看一区二区三区| 中文一区一区三区高中清不卡| 欧美一区二区三区小说| 91麻豆精品秘密| 国产精品影视在线| 日本不卡一二三| 亚洲综合免费观看高清完整版在线| 国产日韩欧美a| 精品国产制服丝袜高跟| 欧美日本韩国一区| 色狠狠色狠狠综合| 成人黄动漫网站免费app| 秋霞午夜av一区二区三区| 亚洲一级二级在线| 亚洲激情综合网| 综合中文字幕亚洲| 中文字幕不卡在线观看| 欧美精品一区二区三区四区| 91精品国产麻豆国产自产在线 | 亚洲动漫第一页| 中文字幕永久在线不卡| 国产午夜精品久久久久久久| 精品国产伦一区二区三区观看体验 | 一区二区三区视频在线看| 中文字幕av一区二区三区高| 国产亚洲成av人在线观看导航| 日韩欧美国产三级| 51午夜精品国产| 欧美日本国产一区| 欧美日韩高清一区| 欧美丰满美乳xxx高潮www| 欧美日韩日日骚| 欧美日韩久久一区| 欧美日韩在线三级| 欧美片在线播放| 欧美日本在线视频| 91麻豆精品久久久久蜜臀| 欧美日韩成人一区| 欧美日韩精品高清| 制服丝袜激情欧洲亚洲| 538prom精品视频线放| 91精品国产91久久久久久最新毛片| 欧美视频在线一区二区三区| 欧美人妖巨大在线| 日韩欧美在线一区二区三区| 日韩一区二区不卡| 久久伊99综合婷婷久久伊| 久久精品欧美一区二区三区不卡| 国产无人区一区二区三区| 国产清纯白嫩初高生在线观看91 | 91九色最新地址| 色8久久人人97超碰香蕉987| 欧美丝袜丝交足nylons图片| 欧美日韩一区二区三区在线看| 欧美精品aⅴ在线视频| 精品免费视频.| 国产精品女人毛片| 亚洲人成网站色在线观看| 亚洲成人免费影院| 激情文学综合插| 91在线视频播放地址| 在线日韩av片| 日韩一区二区在线看| 国产三级一区二区| 综合自拍亚洲综合图不卡区| 五月综合激情日本mⅴ| 九九在线精品视频| 成人综合在线观看| 欧美在线制服丝袜| 欧美精品一区二区三区蜜桃视频 | 99精品偷自拍| 欧美人牲a欧美精品| 精品毛片乱码1区2区3区| 国产精品蜜臀av| 亚洲成人精品一区| 国产一区二区主播在线| 在线中文字幕一区| 久久久久久久综合色一本| 亚洲女性喷水在线观看一区| 日韩成人av影视| av一区二区三区| 欧美电视剧在线看免费| 亚洲欧美日韩国产手机在线| 精品一区在线看| 色嗨嗨av一区二区三区| 久久一区二区三区四区| 亚洲一级二级三级| 国产成人无遮挡在线视频| 欧美色区777第一页| 中文字幕第一区综合| 欧美aaaaaa午夜精品| 色婷婷精品大在线视频| ww亚洲ww在线观看国产| 亚洲国产成人高清精品| 成人精品鲁一区一区二区| 欧美精品久久99| 国产精品电影一区二区| 激情五月播播久久久精品| 欧美日韩国产精品自在自线| 1024精品合集| 国产精品1区二区.| 欧美精品一二三四| 亚洲欧美自拍偷拍色图| 国产专区欧美精品| 在线综合+亚洲+欧美中文字幕| 亚洲人成影院在线观看| 国产精品888| 欧美一区二区三区爱爱| 亚洲3atv精品一区二区三区| 99在线精品视频| 亚洲国产成人在线| 国内精品国产三级国产a久久| 欧美日本韩国一区二区三区视频| 亚洲图片欧美激情| 国产精品一区在线| 精品欧美乱码久久久久久 | 7777精品伊人久久久大香线蕉| 欧美国产激情二区三区| 国产一区二区h| 亚洲精品一区二区三区福利| 免费观看一级欧美片| 欧美另类videos死尸| 亚洲黄色av一区| 色婷婷综合久久久中文字幕| 日韩毛片一二三区| 97精品视频在线观看自产线路二| 国产精品女主播av| 成人丝袜18视频在线观看| 亚洲不卡一区二区三区| 色欧美88888久久久久久影院| 国产精品国产三级国产aⅴ无密码| 国产99精品国产| 欧美激情自拍偷拍| 成人午夜在线视频| 中文字幕色av一区二区三区| a4yy欧美一区二区三区| 亚洲日本va午夜在线影院| 99re视频精品| 亚洲精品高清视频在线观看| 色狠狠桃花综合| 亚洲一区二区三区爽爽爽爽爽| 在线亚洲欧美专区二区| 亚洲成av人片| 日韩三级视频中文字幕| 久久超碰97中文字幕| 欧美精品一区二区三区蜜桃视频 | 国产综合一区二区| 久久久久久麻豆| 成人动漫视频在线| 亚洲蜜臀av乱码久久精品| 欧美日韩在线播放三区| 奇米一区二区三区av| 欧美精品一区二区久久婷婷| 国产成人午夜高潮毛片| 亚洲天堂a在线| 欧美日韩国产一区| 久草在线在线精品观看| 国产天堂亚洲国产碰碰| 91在线视频网址| 亚洲777理论| 久久久久久亚洲综合| 色综合色综合色综合| 日韩二区三区四区| 欧美国产精品一区二区| 色吧成人激情小说| 免费看精品久久片| 中文字幕乱码亚洲精品一区| 91成人在线免费观看| 久久精品国产99国产精品| 欧美—级在线免费片| 精品视频一区二区三区免费| 狠狠狠色丁香婷婷综合激情| 成人免费小视频| 3atv一区二区三区| 成人毛片视频在线观看| 亚洲午夜精品17c| 国产婷婷色一区二区三区 | 久久亚洲一区二区三区明星换脸 | 韩国v欧美v日本v亚洲v| 亚洲美女屁股眼交| 精品国产青草久久久久福利| 91免费观看在线| 久久av老司机精品网站导航| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 另类欧美日韩国产在线| 中文字幕一区二区三区四区不卡| 91精品国产综合久久久久久久| 成人精品小蝌蚪| 极品销魂美女一区二区三区| 亚洲小说欧美激情另类| 国产欧美一区二区精品性色| 91精品中文字幕一区二区三区|