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

天行健 君子當自強而不息

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>
            久久久噜噜噜久久| 国产精品视频一区二区高潮| 亚洲欧洲免费视频| 久久www免费人成看片高清| 欧美专区日韩视频| 国产精品永久| 久久久久久电影| 免费观看在线综合色| 伊甸园精品99久久久久久| 香蕉久久国产| 久久综合狠狠综合久久激情| 在线成人www免费观看视频| 欧美日韩免费| 亚洲欧美国产精品va在线观看| 99re热精品| 欧美日韩三级在线| 亚洲另类视频| 亚洲一区中文字幕在线观看| 狠狠色2019综合网| 久久综合狠狠综合久久综青草| 免费观看国产成人| 亚洲日本久久| 国产精品成人观看视频国产奇米| 中国av一区| 久久久久久久久久久一区| 黄色日韩网站视频| 欧美电影免费观看| 亚洲视频1区| 免费久久99精品国产自| 亚洲最新视频在线播放| 国产婷婷成人久久av免费高清 | 亚洲国产高清aⅴ视频| 欧美不卡一卡二卡免费版| 亚洲综合久久久久| 欧美激情精品久久久久久大尺度 | 亚洲另类春色国产| 国产精品久久二区二区| 久久爱www.| 一区二区三区欧美亚洲| 蜜桃av噜噜一区| 亚洲午夜在线观看| 在线激情影院一区| 国产麻豆9l精品三级站| 美乳少妇欧美精品| 亚洲伊人网站| 亚洲国产精品高清久久久| 亚洲一区日本| 亚洲精品一区二区三区福利| 国产综合色在线| 欧美亚一区二区| 久热精品在线| 久久成年人视频| 亚洲一区二区三区777| 久久中文精品| 久久精品观看| 亚洲一区在线免费| 国产欧美1区2区3区| 欧美性片在线观看| 欧美岛国激情| 欧美精品偷拍| 91久久久精品| 亚洲人体偷拍| 最新日韩中文字幕| 亚洲国产专区校园欧美| 国产欧美精品国产国产专区| 国产精品福利网| 欧美日韩亚洲高清| 国产精品国产三级国产a| 欧美日韩情趣电影| 国产精品h在线观看| 欧美日韩精品在线| 欧美三日本三级少妇三99| 欧美日韩在线视频首页| 国产精品久久久999| 国产日韩欧美在线看| 怡红院精品视频| 最新国产成人av网站网址麻豆| 亚洲精品一区中文| 亚洲一区在线视频| 久久av资源网站| 亚洲精品一品区二品区三品区| 亚洲毛片视频| 久久最新视频| 国产精品美女久久福利网站| 狠狠久久婷婷| 久久激情网站| 亚洲一线二线三线久久久| 欧美第一黄色网| 狠狠干综合网| 久久国产精品高清| 9国产精品视频| 另类酷文…触手系列精品集v1小说| 亚洲日本aⅴ片在线观看香蕉| 欧美h视频在线| 一区二区三区欧美在线| 一本大道久久a久久精品综合| 欧美片第1页综合| 性色一区二区三区| 久久激情中文| 99国产成+人+综合+亚洲欧美| 亚洲精品资源| 欧美精品一区二区久久婷婷| 一区二区三区免费网站| 亚洲天堂久久| 狠狠色综合日日| 亚洲国产欧美一区二区三区同亚洲| 性欧美大战久久久久久久免费观看| 欧美激情自拍| 99精品黄色片免费大全| 亚洲国产影院| 国产精品wwwwww| 午夜久久影院| 亚洲一区日韩| 狠狠色狠狠色综合人人| 久久久国产精品亚洲一区 | 欧美日韩亚洲一区二区| 亚洲日本免费电影| 亚洲第一色中文字幕| 久久人人97超碰精品888 | 午夜影视日本亚洲欧洲精品| 欧美一区二区啪啪| 永久久久久久| 精品成人久久| 亚洲国产一区二区三区在线播| 欧美日韩影院| 久久精品欧美日韩| 欧美激情精品久久久久久| 亚洲尤物在线视频观看| 午夜精品久久久久久久男人的天堂| 国产亚洲一二三区| 亚洲国产精品精华液网站| 欧美精品免费视频| 久久人人精品| 欧美一级在线视频| 欧美成人免费va影院高清| 亚洲精品少妇30p| 欧美电影在线| 久久国产乱子精品免费女| 国产精品视频网址| 免费成人你懂的| 亚洲一区二区三区中文字幕在线 | 蜜桃久久av| 欧美日韩久久精品| 亚洲激情av在线| 亚洲第一福利社区| 久久久国产视频91| 免费在线播放第一区高清av| 欧美精品网站| 亚洲五月婷婷| 久久精品一区二区三区不卡| 亚洲一区二区在线播放| 亚洲人成毛片在线播放| 欧美激情黄色片| 亚洲视频在线一区观看| 亚洲欧美在线视频观看| 欧美激情一二三区| 亚洲视频一二| 欧美国产欧美综合 | 欧美99久久| 国一区二区在线观看| 欧美久久久久久久久久| 久久综合九色综合网站| 亚洲免费福利视频| 国产亚洲欧美在线| 欧美日韩免费观看一区三区 | 在线精品一区二区| 欧美三级欧美一级| 欧美成人a∨高清免费观看| 亚洲一区二区三区精品动漫| 久久综合中文字幕| 欧美在线视频观看免费网站| 国产一区二区三区观看| 国产精品男人爽免费视频1| 麻豆精品视频在线观看| 欧美亚洲午夜视频在线观看| 亚洲男女自偷自拍| 亚洲国产日韩在线| 久久男人资源视频| 亚洲少妇中出一区| 一区二区三区日韩精品视频| 亚洲精品三级| 香蕉久久一区二区不卡无毒影院| 亚洲午夜国产一区99re久久| 夜夜嗨网站十八久久 | 亚洲欧洲在线视频| 一区二区三区www| 欧美激情视频一区二区三区不卡| 国产精品乱码久久久久久| 亚洲国产一区二区三区在线播| 亚洲一区二区在线| 欧美激情国产日韩精品一区18| 亚洲精品国产精品久久清纯直播 | 一区二区成人精品| 亚洲你懂的在线视频| 欧美一区二区视频免费观看| 久久亚洲国产精品日日av夜夜| 欧美成人精品在线播放| 一区二区91| 欧美猛交免费看| 伊人久久大香线蕉av超碰演员|