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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? gd23-04.cpp

?? 游戲開發數據結構-Data.Structures.for.Game.Programmers
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
                    ay >= 0 && ay < p_map.Height() &&
                    p_map.Get( ax, ay ).m_passable == true &&
                    p_map.Get( ax, ay ).m_marked == false )
                {
                    // calculate the distance to get into this cell.
                    // this is calulated as:
                    // distance of the current cell plus
                    // the weight of the adjacent cell times the distance
                    // of the cell.
                    // diagonal cell's cost is around 1.4 times the cost of
                    // a horizontal or vertical cell.
                    distance = p_map.Get( x, y ).m_distance + 
                               p_map.Get( ax, ay ).m_weight * DISTTABLE[dir]; 

                    // check if the node has already been calculated before
                    if( p_map.Get( ax, ay ).m_lastx != -1 )
                    {
                        // the node has already been calculated, see if the
                        // new distance is shorter. If so, update the links.
                        if( distance < p_map.Get( ax, ay ).m_distance )
                        {
                            // the new distance is shorter, update the links
                            p_map.Get( ax, ay ).m_lastx = x;
                            p_map.Get( ax, ay ).m_lasty = y;
                            p_map.Get( ax, ay ).m_distance = distance;

                            // add the cell to the queue.
                            c.x = ax;
                            c.y = ay;
                            c.heuristic = distance + 
                                          AStarHeuristic( x, y, 
                                                          p_gx, p_gy, 
                                                          dir );
                            queue.Enqueue( c );

                            com.c = CHANGEPOINTER;
                            com.x = ax;
                            com.y = ay;
                            com.newx = x;
                            com.newy = y;
                            g_queue.Enqueue( com );

                        }
                    }
                    else
                    {
                        // set the links and the distance
                        p_map.Get( ax, ay ).m_lastx = x;
                        p_map.Get( ax, ay ).m_lasty = y;
                        p_map.Get( ax, ay ).m_distance = distance;

                        // add the cell to the queue.
                        c.x = ax;
                        c.y = ay;
                        c.heuristic = distance + 
                                      AStarHeuristic( x, y, 
                                                      p_gx, p_gy,
                                                      dir );
                        queue.Enqueue( c );

                        com.c = ENQUEUE;
                        com.x = ax;
                        com.y = ay;
                        g_queue.Enqueue( com );

                        com.c = CHANGEPOINTER;
                        com.newx = x;
                        com.newy = y;
                        g_queue.Enqueue( com );

                    }
                }
            }
        }
    }
}




// ============================================================================
//  Button Callbacks
// ============================================================================

void Go()
{
    if( g_startx == -1 || g_starty == -1 || g_goalx == -1 || g_goaly == -1 )
        return;

    PathAStar( g_map, g_startx, g_starty, g_goalx, g_goaly );
    ClearMarks();
    g_done = false;
    g_processing = true;
    g_timer = SDL_GetTicks();
    
}


void ClearMap()
{
    if( g_processing == true )
        return;
    ClearCells( g_map );
    g_done = false;
}


void Slower()
{
    if( g_timeLength < 0 )
        g_timeLength++;
    else
        g_timeLength += 50;
}


void Faster()
{
    if( g_timeLength > 0 )
        g_timeLength -= 50;
    else
        g_timeLength--;
}

// ============================================================================
//  Main
// ============================================================================
int main( int argc, char* argv[] )
{
    int x;
    int y;
    Command c;

    //initialize systems
    SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER );
    SDL_EnableUNICODE( true );
    SDL_WM_SetCaption( PROGRAM_NAME, 0); 
    TTF_Init();
    g_gui = new SDLGUI( WIDTH, HEIGHT, ITEMS, WHITE );
    g_gui->SetFont( "arial.ttf", ARIAL, 18, TTF_STYLE_NORMAL );

    g_gui->AddButton( 0, HEIGHT - 64, "gbup.bmp", "gbdown.bmp", "Go!",
                      ARIAL, BLACK, WHITE, Go );
    g_gui->AddButton( 128, HEIGHT - 64, "gbup.bmp", "gbdown.bmp", "Slower",
                      ARIAL, BLACK, WHITE, Slower );
    g_gui->AddButton( 256, HEIGHT - 64, "gbup.bmp", "gbdown.bmp", "Faster",
                      ARIAL, BLACK, WHITE, Faster );
    g_gui->AddButton( 384, HEIGHT - 64, "gbup.bmp", "gbdown.bmp", "Clear",
                      ARIAL, BLACK, WHITE, ClearMap );

    // load the bmps
    g_blackbox = SDL_LoadBMP( "boxblack.bmp" );
    g_redbox = SDL_LoadBMP( "boxred.bmp" );
    g_greenbox = SDL_LoadBMP( "boxgreen.bmp" );
    g_bluebox = SDL_LoadBMP( "boxblue.bmp" );
    g_wallbox = SDL_LoadBMP( "boxwall.bmp" );
    g_start = SDL_LoadBMP( "start.bmp" );
    g_goal = SDL_LoadBMP( "goal.bmp" );


    // set the color keys of the BMPs
    SDL_SetColorKey( g_blackbox, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_blackbox->format, 255, 255, 255 ));
    SDL_SetColorKey( g_redbox, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_redbox->format, 255, 255, 255 ));
    SDL_SetColorKey( g_greenbox, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_greenbox->format, 255, 255, 255 ));
    SDL_SetColorKey( g_bluebox, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_bluebox->format, 255, 255, 255 ));
    SDL_SetColorKey( g_wallbox, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_wallbox->format, 255, 255, 255 ));
    SDL_SetColorKey( g_start, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_start->format, 255, 255, 255 ));
    SDL_SetColorKey( g_goal, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_goal->format, 255, 255, 255 ));
    

    Clear();
    ClearCells( g_map );
    //RandomizeWeights();

    // set our at exit function
    atexit( SDL_Quit ) ;

    // declare event variable
    SDL_Event event;

    g_gui->Draw();
    g_gui->Update();

    // loop until we get a quit message.
    while( 1 )
    {
        //look for an event
        if( SDL_PollEvent( &event ) )
        {
            //an event was found
            if( event.type == SDL_QUIT ) 
                break;

            // mouse button was pressed
            if( event.type == SDL_MOUSEBUTTONDOWN ) 
            {
                // get the mouse g_state.
                SDL_GetMouseState( &x, &y );

                // tell the GUI that a button has been pressed
                g_gui->MouseDown( x, y );

                g_mousedown = true;
                // see if the user clicked on a square
                x = x / 24;
                y = y / 24;
                if( x < MAPX && y < MAPY )
                {
                    if( g_weight == 10 )
                        g_walldraw = true;
                    else
                        g_walldraw = false;
                }
            }

            // mouse button was released
            if( event.type == SDL_MOUSEBUTTONUP ) 
            {
                // get the mouse state.
                SDL_GetMouseState( &x, &y );

                // tell the GUI that a button has been released
                g_gui->MouseUp( x, y );

                g_mousedown = false;
                // see if the user clicked on a square
                x = x / 24;
                y = y / 24;
                if( x < MAPX && y < MAPY && g_processing == false )
                {
                    // flip the drawing state
                    g_map.Get( x, y ).m_passable = !g_walldraw;
                    g_map.Get( x, y ).m_weight = (float)g_weight;
                }
            }

            if( event.type == SDL_MOUSEMOTION )
            {
                // get the mouse state.
                SDL_GetMouseState( &x, &y );

                // see if the user is over a square
                x = x / 24;
                y = y / 24;
                if( x < MAPX && y < MAPY && g_mousedown == true && g_processing == false )
                {
                    // draw the current wall state
                    g_map.Get( x, y ).m_passable = !g_walldraw;
                    g_map.Get( x, y ).m_weight = (float)g_weight;
                }
            }

            if( event.type == SDL_KEYDOWN )
            {
                // get the mouse state.
                SDL_GetMouseState( &x, &y );

                // a key was pressed.
                if( event.key.keysym.sym == SDLK_ESCAPE )
                {
                    // if ESC was pressed, quit the program.
                    SDL_Event quit;
                    quit.type = SDL_QUIT;
                    SDL_PushEvent( &quit );
                }

                if( event.key.keysym.unicode >= '0' &&
                    event.key.keysym.unicode <= '9' )
                {
                    g_weight = (float)(event.key.keysym.unicode - '0') + 1.0f;
                }

                if( event.key.keysym.sym == SDLK_g )
                {
                    x = x / 24;
                    y = y / 24;
                    if( x < MAPX && y < MAPY )
                    {
                        // if the program isn't processing, set the goal
                        if( g_processing == false && g_done == false )
                        {
                            if( g_map.Get( x, y ).m_passable != false )
                            {
                                g_goalx = x;
                                g_goaly = y;
                            }
                        }
                    }
                }

                if( event.key.keysym.sym == SDLK_s )
                {
                    x = x / 24;
                    y = y / 24;
                    if( x < MAPX && y < MAPY )
                    {
                        // if the program isn't processing, set the goal
                        if( g_processing == false && g_done == false )
                        {
                            if( g_map.Get( x, y ).m_passable != false )
                            {
                                g_startx = x;
                                g_starty = y;
                            }
                        }
                    }
                }

                // tell the GUI that a key was pressed.
                g_gui->KeyDown( event.key.keysym.sym, 
                                event.key.keysym.mod,
                                event.key.keysym.unicode );
            }
        }

        // figure out the number of repetitions to make
        x = 0;
        if( g_timeLength < 0 )
        {
            x = -g_timeLength;
        }
        else if( SDL_GetTicks() - g_timer >= g_timeLength )
        {
            g_timer = SDL_GetTicks();
            x = 1;
        }

        if( g_processing == true )
        {

            for( y = 0; y < x; y++ )
            {
                if( g_queue.Count() == 0 )
                {
                    g_processing = false;
                    g_done = true;
                }
                else
                {
                    c = g_queue.Front();
                    g_queue.Dequeue();
                    if( c.c == ENQUEUE )
                    {
                        g_map.Get( c.x, c.y ).m_inQueue = true;
                    }
                    else if( c.c == DEQUEUE )
                    {
                        g_map.Get( c.x, c.y ).m_inQueue = false;
                        g_map.Get( c.x, c.y ).m_marked = true;
                    }
                    else
                    {
                        g_map.Get( c.x, c.y ).m_lastx = c.newx;
                        g_map.Get( c.x, c.y ).m_lasty = c.newy;
                    }    
                }
            }
        }

        // draw the g_gui at the end of each loop.
        g_gui->Draw();

        DrawMap();

        g_gui->Update();
    }

    return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久色.com| 欧美日韩一级大片网址| 亚洲在线视频网站| 1024成人网色www| 国产精品嫩草99a| 欧美经典三级视频一区二区三区| 久久久久久97三级| 国产亚洲一区二区三区四区| 国产日韩欧美在线一区| 中文字幕精品在线不卡| 国产片一区二区三区| 国产午夜一区二区三区| 亚洲国产精华液网站w| 中文字幕不卡三区| 亚洲激情成人在线| 三级欧美韩日大片在线看| 五月天亚洲精品| 奇米色777欧美一区二区| 久久国产成人午夜av影院| 精品一区二区三区蜜桃| 国产精品自在在线| 99国产精品99久久久久久| 欧美日韩在线不卡| 欧美大片在线观看一区| 国产精品少妇自拍| 午夜a成v人精品| 国产精选一区二区三区| 色噜噜偷拍精品综合在线| 欧美精品123区| 国产午夜精品一区二区三区视频| 国产精品久久久久四虎| 亚洲香蕉伊在人在线观| 久久国产生活片100| 成人ar影院免费观看视频| 在线看国产一区| 久久综合色一综合色88| 亚洲精品国产无套在线观| 蜜臀精品一区二区三区在线观看 | 在线观看91精品国产麻豆| 日韩欧美中文一区| 国产精品高潮久久久久无| 亚洲成人免费视| 成人免费视频视频| 欧美一级夜夜爽| 欧美日韩和欧美的一区二区| 日韩欧美一区电影| 99re成人在线| 亚洲精品一区二区三区福利| 毛片av一区二区三区| 日韩美女一区二区三区四区| 国产在线精品免费| 国产清纯白嫩初高生在线观看91| 懂色中文一区二区在线播放| 成人免费一区二区三区在线观看| 色婷婷国产精品久久包臀| 五月综合激情日本mⅴ| 日韩一级视频免费观看在线| 国产一区二区看久久| 国产精品午夜春色av| 91福利社在线观看| 麻豆精品视频在线观看视频| 国产日韩欧美精品在线| 日本乱人伦aⅴ精品| 日韩精品午夜视频| 中文字幕高清一区| 欧美日韩久久久| 国产成人精品免费在线| 亚洲欧洲中文日韩久久av乱码| 欧美日本一区二区三区四区| 国产精品一区二区久久精品爱涩 | 日韩不卡手机在线v区| 久久蜜桃av一区二区天堂| 一道本成人在线| 久久精品av麻豆的观看方式| 最新热久久免费视频| 7777精品伊人久久久大香线蕉超级流畅| 国产一区二区0| 亚洲成人福利片| 国产精品网站在线观看| 欧美欧美欧美欧美| 波多野结衣中文一区| 免费观看久久久4p| 亚洲精品福利视频网站| 国产欧美日韩在线看| 欧美日韩在线亚洲一区蜜芽| 成人av资源在线观看| 极品少妇xxxx精品少妇| 亚洲国产一区在线观看| 中文字幕在线播放不卡一区| 欧美成人a在线| 欧美欧美午夜aⅴ在线观看| 成人h精品动漫一区二区三区| 蜜臀久久99精品久久久久宅男| 一区二区免费视频| 国产精品久久久久久久久免费樱桃| 欧美一级黄色录像| 欧美日韩在线三级| 色中色一区二区| 不卡的av中国片| 国产成人久久精品77777最新版本| 婷婷六月综合网| 一区二区三区**美女毛片| 亚洲国产精品v| 国产欧美久久久精品影院| 久久综合久色欧美综合狠狠| 欧美一区二区三区白人| 欧美男男青年gay1069videost| 色哟哟国产精品| 91免费看`日韩一区二区| 成人晚上爱看视频| 国产成人av电影在线播放| 激情亚洲综合在线| 韩国精品主播一区二区在线观看| 欧美aaaaaa午夜精品| 天天色综合天天| 午夜精品福利一区二区三区蜜桃| 夜夜夜精品看看| 亚洲成av人**亚洲成av**| 亚洲一区二区黄色| 日韩主播视频在线| 日本一道高清亚洲日美韩| 日韩av一区二区在线影视| 日产欧产美韩系列久久99| 免费在线观看视频一区| 国内精品久久久久影院一蜜桃| 国产一区二区三区精品欧美日韩一区二区三区 | 91免费国产在线观看| 97精品国产97久久久久久久久久久久| 成人一区二区三区| 色哟哟日韩精品| 欧美日韩午夜影院| 欧美成人video| 欧美国产乱子伦 | 亚洲成人动漫在线观看| 日韩激情av在线| 久久99精品久久久| 国产东北露脸精品视频| www.亚洲精品| 欧美亚洲一区二区在线观看| 欧美一区二区三区免费观看视频| 精品久久久久久久一区二区蜜臀| 国产亚洲成年网址在线观看| 亚洲欧美色一区| 午夜不卡在线视频| 国产精品1区2区3区在线观看| 成人精品高清在线| 欧美午夜精品久久久久久超碰 | 免费观看在线综合| 大胆亚洲人体视频| 欧美日韩免费高清一区色橹橹| 欧美大片在线观看一区| 中文字幕一区二区三区四区| 午夜视频一区二区三区| 国产精品羞羞答答xxdd| 色婷婷一区二区| 精品免费一区二区三区| 亚洲美女淫视频| 极品美女销魂一区二区三区 | 一区二区三区中文字幕电影| 蜜臀久久99精品久久久久久9| 成人免费高清在线| 91精品国产91久久久久久一区二区 | 亚洲午夜影视影院在线观看| 免费成人美女在线观看| 99re热这里只有精品免费视频| 欧美色图免费看| 国产性天天综合网| 日本怡春院一区二区| 成人av先锋影音| 欧美xxxxxxxx| 亚洲国产一二三| 成人激情文学综合网| 日韩视频中午一区| 亚洲第一主播视频| 91性感美女视频| wwwwxxxxx欧美| 日韩av电影一区| 91国在线观看| 亚洲欧洲成人自拍| 国产福利电影一区二区三区| 日韩小视频在线观看专区| 亚洲一区二区三区中文字幕| 成人午夜短视频| 久久亚洲综合av| 日本特黄久久久高潮| 精品视频在线免费观看| 亚洲免费三区一区二区| 国产不卡视频在线观看| 2020国产成人综合网| 久久成人精品无人区| 69久久夜色精品国产69蝌蚪网 | 久久久久久久久蜜桃| 久久精品国产一区二区三| 欧美视频精品在线| 亚洲成人一二三| 欧美日韩精品高清| 亚洲 欧美综合在线网络| 欧美日韩另类一区| 天堂一区二区在线免费观看| 欧美三级电影精品|