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

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

?? g11-01.cpp

?? 好書,關(guān)于游戲開發(fā)數(shù)據(jù)結(jié)構(gòu)的,還有一些實用例子
?? CPP
字號:
// ============================================================================
// G11-01.cpp
// Plotline demo
// ============================================================================
#include "SDL.h"
#include "SDLHelpers.h"
#include "Tree.h"
#include <stdlib.h>

// ============================================================================
//  Global Constants
// ============================================================================
const char PROGRAM_NAME[]   = "Game Demo 11-01: Plotline Demo";
const int WIDTH             = 640;
const int HEIGHT            = 480;


// ============================================================================
//  Classes
// ============================================================================
class Player
{
public:
    float x;
    float y;
};

// game can be in three states: Playing, selecting a new level, or won the game.
enum GameState
{
    PLAYING,
    SELECTING,
    WIN
};


// ============================================================================
//  Global Variables
// ============================================================================

// this is the main window for the framework
SDL_Surface* g_window = 0;

Player g_player;

SDL_Surface* g_hero;
SDL_Surface* g_text;
SDL_Surface* g_win;
SDL_Surface* g_tiles[9];

GameState g_state = PLAYING;

Tree<int>* g_tree;
TreeIterator<int> g_itr;

int g_dx = 0;
int g_dy = 0;
int g_timer;

// ============================================================================
//  Functions
// ============================================================================

// this draws the map
void DrawMap()
{
    int x;
    int y;
    
    // go through every x,y
    for( y = 0; y < 8; y++ )
    {
        for( x = 0; x < 10; x++ )
        {
            // blit the tile at the current level.
            SDLBlit( g_tiles[g_itr.Item()], g_window, x * 64, y * 64 );
        }
    }
}

// draw the level select screen
void DrawOptions()
{
    // blit the "select next level" text
    SDLBlit( g_text, g_window, 0, 0 );

    int x = 128;

    // loop through every level option available at the current level
    for( g_itr.ChildStart(); g_itr.ChildValid(); g_itr.ChildForth() )
    {
        // draw the tile of that level
        SDLLine( g_window, x-1, 127, x+64, 127, WHITE );
        SDLLine( g_window, x-1, 192, x+64, 192, WHITE );
        SDLLine( g_window, x-1, 127, x-1, 192, WHITE );
        SDLLine( g_window, x+64, 127, x+64, 192, WHITE );
        SDLBlit( g_tiles[g_itr.ChildItem()], g_window, x, 128 );
        x += 128;
    }
}


int main( int argc, char* argv[] )
{
    // declare coordinates.
    int x, y;
    int dt;

    // declare event holder
    SDL_Event event;

    // the iterator that keeps track of the current level
    TreeIterator<int> itr;

    // a temporary node structure, for creating new nodes
    Tree<int>* node;

    // start the player off at 0,0
    g_player.x = 0.0f;
    g_player.y = 0.0f;


    // create the root node
    g_tree = new Tree<int>;
    g_tree->m_data = 0;
    g_itr = g_tree;

    // create the iterator.
    itr = g_tree;

    // add the '2a' branch
    node = new Tree<int>;
    node->m_data = 1;
    itr.AppendChild( node );

    // add the '2b' branch
    node = new Tree<int>;
    node->m_data = 2;
    itr.AppendChild( node );

    // add the '2d' branch
    node = new Tree<int>;
    node->m_data = 3;
    itr.AppendChild( node );
    
    // add the '3a' branch
    itr.ChildStart();
    itr.Down();
    node = new Tree<int>;
    node->m_data = 4;
    itr.AppendChild( node );

    // add the '3b' branch
    itr.Up();
    itr.ChildStart();
    itr.ChildForth();
    itr.Down();
    node = new Tree<int>;
    node->m_data = 5;
    itr.AppendChild( node );

    // add the '3c' branch
    node = new Tree<int>;
    node->m_data = 6;
    itr.AppendChild( node );

    // add the '3d' branch
    itr.Up();
    itr.ChildStart();
    itr.ChildForth();
    itr.ChildForth();
    itr.Down();
    node = new Tree<int>;
    node->m_data = 7;
    itr.AppendChild( node );

    // add the '3e' branch
    node = new Tree<int>;
    node->m_data = 8;
    itr.AppendChild( node );



    // initialize the video system.
    SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER );
    SDL_WM_SetCaption( PROGRAM_NAME, 0); 

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

    // set the video mode.
    g_window = SDL_SetVideoMode( WIDTH, HEIGHT, 0, SDL_ANYFORMAT );


    // load the hero
    g_hero = SDL_LoadBMP( "hero1.bmp" );
    SDL_SetColorKey( g_hero, SDL_SRCCOLORKEY, 
                     SDL_MapRGB( g_hero->format, 255, 0, 255 ) );

    // load the text
    g_text = SDL_LoadBMP( "text.bmp" );
    g_win = SDL_LoadBMP( "win.bmp" );

    // load the tiles
    g_tiles[0] = SDL_LoadBMP( "smallcrust.bmp" );
    g_tiles[1] = SDL_LoadBMP( "smallfire.bmp" );
    g_tiles[2] = SDL_LoadBMP( "smallice.bmp" );
    g_tiles[3] = SDL_LoadBMP( "smallmarble.bmp" );
    g_tiles[4] = SDL_LoadBMP( "smallmetal.bmp" );
    g_tiles[5] = SDL_LoadBMP( "smallorangesky.bmp" );
    g_tiles[6] = SDL_LoadBMP( "smallstone.bmp" );
    g_tiles[7] = SDL_LoadBMP( "smallwater.bmp" );
    g_tiles[8] = SDL_LoadBMP( "smallwood.bmp" );



    // set the timer
    g_timer = SDL_GetTicks();


    while( 1 )
    {
        //look for an event
        if( SDL_PollEvent( &event ) )
        {
            //an event was found
            if( event.type == SDL_QUIT ) 
                break;
            if( event.type == SDL_MOUSEBUTTONDOWN ) 
            {
                // get the mouse state.
                SDL_GetMouseState( &x, &y );
                if( y >= 128 && y <= 192 && g_state == SELECTING )
                {
                    x = (x - 128) / 128;
                    if( x < g_itr.m_node->m_children.Size() )
                    {
                        g_itr.ChildStart();
                        while( x > 0 )
                        {
                            g_itr.ChildForth();
                            x--;
                        }
                        g_itr.Down();
                        g_state = PLAYING;
                    }
                }
            }
            if( event.type == SDL_MOUSEBUTTONUP ) 
            {
                // get the mouse state.
                SDL_GetMouseState( &x, &y );
            }
            if( event.type == SDL_KEYUP )
            {
                if( event.key.keysym.sym == SDLK_LEFT )
                {
                    g_dx += 1;
                }
                if( event.key.keysym.sym == SDLK_RIGHT )
                {
                    g_dx -= 1;
                }
                if( event.key.keysym.sym == SDLK_UP )
                {
                    g_dy += 1;
                }
                if( event.key.keysym.sym == SDLK_DOWN )
                {
                    g_dy -= 1;
                }
            }
            if( event.type == SDL_KEYDOWN )
            {
                // 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.sym == SDLK_LEFT )
                {
                    g_dx -= 1;
                }
                if( event.key.keysym.sym == SDLK_RIGHT )
                {
                    g_dx += 1;
                }
                if( event.key.keysym.sym == SDLK_UP )
                {
                    g_dy -= 1;
                }
                if( event.key.keysym.sym == SDLK_DOWN )
                {
                    g_dy += 1;
                }

            }

        }   // end event loop.



        if( g_state == PLAYING )
        {
            // calculate how much time has passed since the last timer update
            dt = SDL_GetTicks() - g_timer;
            g_timer = SDL_GetTicks();

            // move the player over by 128 pixels per second.
            g_player.x += ((float)(dt * 128) / 1000.0f) * g_dx;
            g_player.y += ((float)(dt * 128) / 1000.0f) * g_dy;

            // make sure the player doesn't go off the top, left, or
            // bottom sides of the screen.
            if( g_player.x < 0.0f )
                g_player.x = 0.0f;
            if( g_player.y < 0.0f )
                g_player.y = 0.0f;
            if( g_player.y > 416.0f )
                g_player.y = 416.0f;



            DrawMap();
            SDLBlit( g_hero, g_window, g_player.x, g_player.y );

            // if the player went past 640, he wins the level!
            if( g_player.x > 640.0f )
            {
                // reset the coordinates of the player
                g_player.x = 0.0f;
                g_player.y = 0.0f;

                // if the current level iterator has no children,
                // then that means the player won the game
                if( g_itr.m_node->m_children.Size() == 0 )
                {
                    g_state = WIN;
                }
                else
                {
                    // if not, then select the next level.
                    g_state = SELECTING;
                }
            }
        }
        else if( g_state == SELECTING )
        {
            // draw the option screen
            SDL_FillRect( g_window, NULL, SDL_MapRGB( g_window->format, 0, 0, 0 ) );
            DrawOptions(); 
        }
        else
        {
            // draw the "You win!" screen
            SDL_FillRect( g_window, NULL, SDL_MapRGB( g_window->format, 0, 0, 0 ) );
            SDLBlit( g_win, g_window, 0, 0 );
        }


        // update the entire window.
        SDL_UpdateRect( g_window, 0, 0, 0, 0 );
    }
  
    // done
    return 0;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲mv在线观看| 国产精品女人毛片| 国产日韩欧美精品一区| 国产精品69毛片高清亚洲| 国产高清无密码一区二区三区| 99热在这里有精品免费| 欧美精选午夜久久久乱码6080| 精品成人一区二区| 亚洲欧美另类在线| 美女视频网站黄色亚洲| av在线这里只有精品| 欧美日韩国产综合草草| 欧美激情中文字幕| 日韩中文字幕不卡| 不卡欧美aaaaa| 日韩欧美一区二区不卡| 亚洲女子a中天字幕| 久久不见久久见免费视频1| 色综合久久天天| 欧美精品一区二区三区一线天视频| 亚洲视频你懂的| 国产一区二区三区不卡在线观看 | 亚洲欧美一区二区三区国产精品| 日韩成人免费在线| 91欧美激情一区二区三区成人| 日韩欧美激情在线| 亚洲一区在线观看视频| 国产成人在线视频网址| 7777女厕盗摄久久久| 最新国产成人在线观看| 国内精品自线一区二区三区视频| 色婷婷激情一区二区三区| 欧美大片日本大片免费观看| 亚洲午夜精品在线| 成a人片国产精品| 久久色在线观看| 日韩精品久久久久久| 91视频在线观看免费| 久久精品欧美一区二区三区不卡| 五月开心婷婷久久| 色综合久久天天| 国产精品免费视频观看| 国产精品综合一区二区| 日韩三级伦理片妻子的秘密按摩| 亚洲综合一区二区三区| 91视视频在线直接观看在线看网页在线看| 久久女同精品一区二区| 久久电影国产免费久久电影| 欧美欧美午夜aⅴ在线观看| 亚洲精品老司机| 91在线视频播放地址| 国产日本亚洲高清| 国产一区二区三区电影在线观看| 日韩欧美在线观看一区二区三区| 亚洲成人午夜影院| 欧美视频一区二区三区四区| 亚洲日本在线天堂| 中文字幕的久久| 福利一区二区在线| 国产欧美va欧美不卡在线| 黑人巨大精品欧美一区| 日韩欧美在线影院| 久久精品av麻豆的观看方式| 91精品国产色综合久久不卡电影 | 精品视频一区二区不卡| 亚洲一级二级三级| 欧美性大战久久| 亚洲小少妇裸体bbw| 欧美日韩国产在线观看| 亚洲成人av中文| 欧美另类久久久品| 日本成人在线一区| 精品入口麻豆88视频| 精品一区二区三区免费毛片爱| 欧美va亚洲va香蕉在线| 韩国午夜理伦三级不卡影院| 精品成人一区二区三区四区| 国产麻豆精品theporn| 久久久国际精品| 成人avav在线| 亚洲最新视频在线观看| 欧美日韩免费不卡视频一区二区三区| 亚洲高清在线精品| 日韩欧美一级二级三级 | 久久久久久免费网| 成人福利视频在线| 亚洲激情在线激情| 欧美日韩国产精选| 久久99精品网久久| 中文字幕欧美国产| 色哟哟日韩精品| 五月激情综合网| 2023国产精品视频| 99精品久久99久久久久| 亚洲一二三四久久| 日韩欧美中文字幕制服| 国产激情一区二区三区四区| 成人欧美一区二区三区视频网页| 在线视频一区二区三| 蜜桃一区二区三区在线| 国产日韩精品一区二区三区在线| 91麻豆国产福利精品| 日韩成人一级片| 久久精品一区蜜桃臀影院| 91小视频在线免费看| 午夜精品一区二区三区免费视频| 亚洲精品一区二区三区影院| 菠萝蜜视频在线观看一区| 亚洲国产精品视频| 久久久久9999亚洲精品| 在线观看亚洲一区| 国内精品视频666| 亚洲视频一区二区在线| 日韩欧美自拍偷拍| 91在线精品秘密一区二区| 日本欧美一区二区三区乱码| 国产欧美一二三区| 亚洲一区免费观看| 欧美精品一区二区三| 91久久精品午夜一区二区| 麻豆精品国产91久久久久久| 亚洲欧美怡红院| 日韩天堂在线观看| 99精品国产99久久久久久白柏| 美国十次综合导航| 亚洲精品国产视频| 久久女同精品一区二区| 欧美日韩一区二区三区在线| 国产二区国产一区在线观看| 亚洲gay无套男同| 国产精品日产欧美久久久久| 欧美精品久久99久久在免费线 | 亚洲欧美日韩国产手机在线 | 国产精品自拍av| 亚洲国产欧美日韩另类综合| 国产欧美日韩视频一区二区 | 黄色小说综合网站| 午夜精品久久久久久久久| 国产精品国产三级国产普通话蜜臀 | 国产亚洲人成网站| 51久久夜色精品国产麻豆| 99精品国产91久久久久久 | 国产精品久久久久影院老司| 91精品国产色综合久久| 色欧美乱欧美15图片| 成人美女视频在线观看18| 九九精品视频在线看| 首页国产欧美久久| 亚洲精品水蜜桃| 专区另类欧美日韩| 国产欧美一二三区| 精品成人免费观看| 91精品国产一区二区三区| 欧美天堂亚洲电影院在线播放| www.欧美.com| 国产高清在线精品| 国产在线精品一区二区夜色 | 久久久一区二区三区捆绑**| 日韩一区二区三区电影在线观看| 欧美视频一区在线| 欧美中文字幕一区| 一本到不卡精品视频在线观看| 国产91精品久久久久久久网曝门| 精品一二三四区| 日本亚洲最大的色成网站www| 亚洲综合色自拍一区| 亚洲欧美一区二区三区国产精品| 国产精品久久久久国产精品日日| 久久美女高清视频| 久久精品欧美日韩| 久久先锋影音av| 国产亚洲精品资源在线26u| 精品91自产拍在线观看一区| 欧美一区二区三区视频免费播放 | 国内久久精品视频| 精品无人区卡一卡二卡三乱码免费卡 | 欧美成人性战久久| 欧美www视频| 久久网站热最新地址| 久久久亚洲综合| 中文字幕精品一区二区精品绿巨人| 久久亚洲捆绑美女| 欧美国产日产图区| 中文字幕亚洲一区二区av在线| 中文字幕中文字幕在线一区| 自拍偷拍亚洲综合| 亚洲激情六月丁香| 一区二区高清在线| 亚洲va韩国va欧美va精品| 婷婷亚洲久悠悠色悠在线播放 | 26uuu国产日韩综合| 久久蜜臀中文字幕| 国产精品视频麻豆| 亚洲女同ⅹxx女同tv| 亚洲国产精品久久一线不卡| 日韩中文字幕一区二区三区| 免费不卡在线视频| 国产成人免费视频| 91视视频在线直接观看在线看网页在线看| 一本色道久久综合亚洲aⅴ蜜桃 |