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

天行健 君子當自強而不息

Putting Together a Full Game(9)

 

The Application init Function

As the starting point of the game, the init function initializes the system (including
the graphics, sound, and input systems), sets up the character and spell controllers,
loads the master item list, pushes the main menu state, and carries out a few miscellaneous
functions. Take a look at the Init function piece by piece to see what’s
going on:

bool cApp::init()
{
    create_display(g_hwnd, CLIENT_WIDTH, CLIENT_HEIGHT, 16, 
truetrue);
    set_perspective(0.6021124f, 1.3333f, 1.0f, 20000.0f);    

    ShowCursor(TRUE);

    create_font(&m_font, "Consolas", 16, 
falsefalse);

    m_input.create(g_hwnd, get_window_inst());
    m_keyboard.create_keyboard(&m_input);
    m_mouse.create_mouse(&m_input, 
true);

    m_sound.init(g_hwnd, 22050, 1, 16, DSSCL_PRIORITY);     
    m_sound_channel.create(&m_sound, 22050, 1, 16);
    m_music_channel.attach(&m_sound);

    
// load the master item list

    FILE* fp = fopen("..\\Data\\Game.mil", "rb");

    
if(fp == NULL)
        
return false;

    fread(m_mil, 1, 
sizeof(m_mil), fp);
    fclose(fp);

    
// initialize the character controller    

    m_game_chars.init(m_font, "..\\Data\\Game.mcl", m_mil, m_game_spells.get_spell_list(),
                      array_num(g_char_mesh_files), g_char_mesh_files,
                      "..\\Data\\", "..\\Data\\",
                      array_num(g_char_anims), g_char_anims);    
    
    m_game_chars.attach_app(
this);

    
// initialize the spell controller

    
if(! m_game_spells.init("..\\Data\\Game.msl", array_num(g_spell_mesh_files), g_spell_mesh_files, "..\\Data\\"))
        
return false;

    m_game_spells.attach_app(
this);

    m_game_chars.attach(&m_game_spells);
    m_game_spells.attach(&m_game_chars);

    m_game_script.attach_app(
this);

    
if(! load_texture_from_file(&m_charge_bar, "..\\Data\\ChargeBar.bmp", 0, D3DFMT_UNKNOWN))
        
return false;

    
// create the main, header, and stats text windows.
    m_text_window.create(m_font);
    m_text_header.create(m_font);
    m_text_stats.create(m_font);

    
// position all text windows
    m_text_window.move(2, 2, 636, 476, -1, -1, COLOR_DARK_BLUE, COLOR_ARGENTINE);
    m_text_header.move(2, 2, 128, 32,  -1, -1, COLOR_HALF_RED,  COLOR_ARGENTINE);
    m_text_stats.move(2,  2, 128, 48,  -1, -1, COLOR_DARK_BLUE, COLOR_ARGENTINE);

    
// push the main menu state, setting menu optios first.
    g_menu_options = MENU_LOAD;
    m_state_manager.push(menu_frame, 
this);

    
return true;
}

Graphics is the first order of business here—you initialize the graphics system and
set the video mode.  You then set the perspective to match that of the 3-D modeler
used to render the backdrops. Finally, you create a font to use throughout the
game and display the mouse cursor.

Next, you initialize the input system and create two device interfaces—one for the
keyboard and the other for the mouse.

Rounding out the Graphics Core initialization code, you initialize the sound system
and create the sound and music channels.

Now, you initialize the game-specific data and interfaces. You load the master item
list and initialize the character controller and spell controllers.

You're about halfway through the init function. At this point, you load a bitmap
that display the player's charge meter, and you create and position the text windows.

Rounding off the Init function, you make a call to the derived script class that tells
the script which application class interface to use. Following that, you push the first
of the game states, the main menu, onto the state stack.

 

The shutdown Function

What good is the Init function without a matching Shutdown function to shut down
and free used resources in the game? The cApp::shutdown function does just that.

void cApp::shutdown()
{
    m_state_manager.pop_all(
this);

    free_level();
}

 

Processing Frames with the frame Function

For every frame that the game is updated, the application class’s frame function is
called. To limit how often the game actually updates, however, a timer is maintained
that limits further frame processing to 30 frames a second. This process of limiting
the updates takes up the first half of the Frame function, as shown here:

bool cApp::frame()
{
    
static DWORD update_timer = timeGetTime();

    
// limit all frame updates to 30 fps
    if(timeGetTime() < update_timer + 33)
        
return true;

    update_timer = timeGetTime();

    m_keyboard.acquire();
    m_keyboard.read();
    m_mouse.acquire();
    m_mouse.read();

    
return m_state_manager.process_top(this);
}

As I mentioned, the game is updated 30 times a second. Each frame that the game
is updated, the keyboard and mouse’s states are read in, and the current state is
processed.

As states are inserted into the state stack, the uppermost
state executes when cManager::process_top is called, as shown in the frame function.

posted on 2007-12-29 21:04 lovedday 閱讀(276) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美大片免费观看| 日韩小视频在线观看专区| 一区二区av| 久久久久国产精品厨房| 亚洲摸下面视频| 一区二区三区视频在线观看| 亚洲国产欧美一区二区三区久久| 国产伦精品免费视频| 国产精品毛片在线| 国产麻豆综合| 一区视频在线看| 激情丁香综合| 亚洲精品视频在线播放| 亚洲精品国偷自产在线99热| 亚洲激情啪啪| 亚洲一区二区三区精品在线观看| 在线一区亚洲| 久久婷婷亚洲| 亚洲麻豆视频| 亚洲少妇在线| 免费日韩成人| 国产视频一区欧美| 亚洲国产精品高清久久久| 99re热这里只有精品视频| 亚洲欧美日韩综合一区| 国产精品99久久久久久久久| 欧美影片第一页| 午夜激情亚洲| 亚洲人成在线播放| 9色精品在线| 久久国产精品99久久久久久老狼 | 久久久久看片| 国产精品日本欧美一区二区三区| 国产欧美亚洲一区| 亚洲一区二区欧美| 亚洲欧洲日本在线| 欧美成人精品在线播放| 亚洲第一页中文字幕| 久久久久久91香蕉国产| 亚洲天天影视| 国产麻豆视频精品| 久久久国产91| 亚洲欧美国产精品专区久久| 欧美日韩在线观看一区二区三区| 亚洲精品资源美女情侣酒店| 欧美黄污视频| 欧美日韩性生活视频| 亚洲午夜免费视频| 亚洲一区区二区| 在线成人激情黄色| 亚洲免费久久| 国产又爽又黄的激情精品视频| 久久激情视频| 欧美国产乱视频| 性欧美办公室18xxxxhd| 久久精品一级爱片| 亚洲一级片在线看| 久久久噜噜噜久久人人看| 亚洲精品视频啊美女在线直播| 午夜精品久久久| 久久精品国产一区二区三| 国产日韩高清一区二区三区在线| 欧美在线日韩| 欧美日本不卡高清| 美日韩精品视频免费看| 亚洲激情网站免费观看| 亚洲综合日韩在线| 亚洲精品日韩欧美| 久久动漫亚洲| 久久精品三级| 国产日韩欧美在线看| 亚洲最快最全在线视频| 91久久午夜| 看片网站欧美日韩| 另类春色校园亚洲| 韩国欧美国产1区| 午夜激情亚洲| 久久久噜噜噜久久中文字幕色伊伊| 欧美日韩免费观看一区二区三区| 欧美大片在线影院| 亚洲缚视频在线观看| 久久精品免费电影| 欧美jizz19hd性欧美| 亚洲黄色在线| 欧美日韩国产另类不卡| 亚洲乱码视频| 久久成人资源| 亚洲日本欧美日韩高观看| 麻豆91精品91久久久的内涵| 牛牛影视久久网| 国产精品99久久99久久久二8| 欧美精品一区在线播放| 日韩午夜三级在线| 亚洲一二三区精品| 国产美女精品在线| 久热精品在线视频| 一区二区三区在线视频观看| 久久久久久网站| 亚洲国产日韩欧美综合久久| 亚洲欧美国产日韩天堂区| 国产亚洲午夜| 欧美视频免费在线| 久久久久久久高潮| 亚洲午夜精品一区二区三区他趣| 久久久久久久精| 午夜在线一区二区| 中文精品99久久国产香蕉| 激情综合网激情| 国产伦精品一区二区三区视频孕妇 | 亚洲欧美日韩国产综合| 久久av二区| 亚洲欧美日韩专区| 一区二区三区产品免费精品久久75| 国产日韩欧美91| 国产精品萝li| 欧美性色aⅴ视频一区日韩精品| 欧美亚洲视频| 欧美一区日韩一区| 午夜一区不卡| 久久精品国产欧美激情| 欧美中文在线观看国产| 亚洲免费影视第一页| 亚洲男人第一网站| 欧美资源在线| 久久人人爽人人爽| 免费成人网www| 欧美日韩一区二区三区视频| 欧美人与禽性xxxxx杂性| 欧美日韩系列| 国产在线精品二区| 99成人精品| 久久成人精品| 久久精品72免费观看| 蜜臀av在线播放一区二区三区| 免费成人高清视频| 一本久道久久综合婷婷鲸鱼| 亚洲亚洲精品三区日韩精品在线视频 | 国产日韩视频| 日韩午夜高潮| 久久久亚洲成人| 日韩视频在线免费| 久久久久久久久伊人| 国产精品高潮呻吟久久| 91久久精品国产91性色tv| 先锋影院在线亚洲| 亚洲精品中文字幕女同| 另类图片综合电影| 国产日韩欧美精品一区| 一区二区三区四区五区在线| 亚洲国产精品va在线观看黑人 | 麻豆av福利av久久av| 亚洲美洲欧洲综合国产一区| 欧美在线亚洲综合一区| 国产精品久久久久影院色老大| 亚洲激情网址| 欧美激情欧美激情在线五月| 欧美影院在线播放| 国产美女精品在线| 久久人人超碰| 久久久久久亚洲精品杨幂换脸 | 亚洲免费网址| 国产精品乱码一区二三区小蝌蚪 | 国产亚洲一本大道中文在线| 亚洲一区二区三区激情| 99精品久久久| 亚洲激情亚洲| 欧美日韩综合网| 亚洲在线视频观看| 亚洲午夜精品视频| 黄色国产精品| 亚洲精品欧洲| 国模吧视频一区| 亚洲大胆美女视频| 欧美午夜电影在线| 久久久久久九九九九| 欧美大片18| 蜜臀av国产精品久久久久| 欧美激情第8页| 久久久久青草大香线综合精品| 久久九九热免费视频| 99精品99久久久久久宅男| 午夜在线观看免费一区| 中日韩美女免费视频网址在线观看| 亚洲一区二区三区四区视频| 亚洲激情国产精品| 欧美与欧洲交xxxx免费观看 | 国产伦精品一区二区三区视频黑人 | 久久国产精品免费一区| 欧美国产日韩亚洲一区| 日韩午夜激情| 99精品免费| 在线视频精品一| 美日韩精品视频免费看| 欧美a级理论片| 亚洲激情女人| 欧美日韩国产免费观看| 亚洲精品国产精品久久清纯直播 | 欧美一级大片在线观看| 亚洲香蕉网站| 国产精品伦一区|