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

天行健 君子當自強而不息

Putting Together a Full Game(8)

 

Structuring the Application

The main application is relatively small (if you can call just under 1,500 lines of
code small). It has the job of initializing all the required components and tracking
the game state (that’s right, state-based processing is even used here).

First, you declare the application class. Although the class is incomplete at this
point, throughout the rest of this chapter, the pieces fall into place, and the application
class becomes complete. Now, check out the sections of the application class
that set up the class data and initialize the game system:

#include "core_common.h"
#include "core_manager.h"
#include "core_graphics.h"
#include "core_framework.h"
#include "core_input.h"
#include "core_sound.h"
#include "text_window.h"
#include "spell_controller.h"
#include "trigger.h"
#include "barrier.h"
#include "game_chars.h"
#include "game_script.h"

#define SOUND_CHAR_ATTACK       0
#define SOUND_MONSTER_ATTACK    1
#define SOUND_FIREBALL          2
#define SOUND_ICE               3
#define SOUND_HEAL              4
#define SOUND_TELEPORT          5
#define SOUND_GROUNDBALL        6
#define SOUND_CONCUSSION        7
#define SOUND_EVIL_FORCE        8
#define SOUND_ROAR              9
#define SOUND_CHAR_HURT         10
#define SOUND_MONSTER_HURT      11
#define SOUND_CHAR_DIE          12
#define SOUND_MONSTER_DIE       13
#define SOUND_BEEP              14

#define SPELL_FIREBALL          0
#define SPELL_ICE               1
#define SPELL_HEAL              2
#define SPELL_TELEPORT          3
#define SPELL_GROUNDBALL        4
#define SPELL_CONCUSSION        5
#define SPELL_EVIL_FORCE        6

#define ID_PLAYER               0

class cApp;

class cGameSpells : public cSpellController
{
private:
    cApp* m_app;

public:
    
void attach_app(cApp* app)  { m_app = app; }

    
virtual void play_spell_sound(long index);
};

/************************************************************************************************/

class cApp : public cFramework
{
    friend 
class cGameScript;
    friend 
class cGameChars;
    friend 
class cGameSpells;

    friend 
void menu_frame(void* data,   long purpose);
    friend 
void game_frame(void* data,   long purpose);
    friend 
void status_frame(void* data, long purpose);
    friend 
void barter_frame(void* data, long purpose);

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

private:
    ID3DXFont*          m_font;
    IDirect3DTexture9*  m_scene_backdrops[6];
    IDirect3DTexture9*  m_charge_bar;

    
long                m_scene_index;

    cCamera             m_camera;

    cInput              m_input;
    cInputDevice        m_keyboard;
    cInputDevice        m_mouse;

    cSound              m_sound;
    cSoundChannel       m_sound_channel;
    cMusicChannel       m_music_channel;
    cSoundData          m_sound_data;
    
    cMesh               m_scene_mesh;
    cObject             m_scene_object;

    cGameChars          m_game_chars;
    cGameSpells         m_game_spells;    

    cTextWindow         m_text_stats;
    cTextWindow         m_text_window;
    cTextWindow         m_text_header;

    cGameScript         m_game_script;

    
long                m_teleport_map;             // map to teleport on next frame (-1 = none)
    bool                m_is_monster_last_frame;    // flag if monsters during last frame

    
long                m_combat_exp;               // combat booty to reward at end of combat
    long                m_combat_money;         

    cTrigger            m_trigger;
    cBarrier            m_barrier;

    sItem               m_mil[1024];                
// the master item list

    cManager            m_state_manager;

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

public:
    cApp()
    {
        m_font                  = NULL;
        m_charge_bar            = NULL;
        m_scene_index           = 0;        
        m_combat_exp            = 0;
        m_combat_money          = 0;
        m_teleport_map          = -1;
        m_is_monster_last_frame = 
false;
        
        ZeroMemory(m_scene_backdrops, 
sizeof(m_scene_backdrops));
        ZeroMemory(m_mil,             
sizeof(m_mil));
    }

    
virtual bool init();
    
virtual void shutdown();
    
virtual bool frame();

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

private:
    
float get_height_below(float x_pos, float y_pos, float z_pos);

    
bool  check_intersect(float x_start, float y_start, float z_start,
                          
float x_end, float y_end, float z_end,
                          
float* dist);

    
void render_frame(long elapsed);

    
void free_level();
    
bool load_level(int scene_index);

    
void play_sound(long index);
    
void play_music(long index);
    
void stop_music();

    
void win_game();
    
void start_of_combat();
    
void end_of_combat();

    
void teleport_player(long map, float x_pos, float y_pos, float z_pos);
    
void setup_barter(const char* ics_file);

    sCharacter* get_char_at(
long mouse_x_pos, long mouse_y_pos);
    
bool last_point_reached(sCharacter* character);
};

The application class begins by setting three friend class references. Those three
classes, cGameSpells, cGameChars, and cGameScript, are the derived controllers for the spells,
characters, and scripts, respectively. Each of those classes need special access to
the application class, so you can make them friends.

The next portion of the cApp class declares a list of Game Core specific
objects, all of which are private to the cApp class.

From the Graphics Core, you can see the use of the graphics, font, and camera
objects. For input, there’s the input system object, plus a device for each the keyboard
and mouse. Rounding off the lot are objects for using the sound system, a
single sound and music channel, and a sound data object for loading sounds.

A small bitmap stores the graphics used to display the player’s charge bar (the
amount of charge built up for attacking). You store this bitmap using a texture
object. Following that, you include three text window objects to display various
dialogue and screen text.

At this point in the application class declaration, you define a couple of miscellaneous
private functions.

The win_game function is called whenever a script encounters the win-game action.
This action triggers the end of game, which returns play back to the main menu.
get_char_at is the function that determines which character a user clicks with the mouse.

Completing cApp are the class constructor and the overridden init, shutdown, and
frame functions, all of which you declare with public accessibility.


posted on 2007-12-29 20:45 lovedday 閱讀(239) 評論(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>
            精品成人一区二区三区| 亚洲一级片在线观看| 91久久精品一区二区三区| 国产欧美一区二区精品性| 国产精品亚洲产品| 国产精品推荐精品| 亚洲福利在线观看| 久久精品99无色码中文字幕 | 一本久道久久综合狠狠爱| 亚洲人成在线播放网站岛国| 99视频在线观看一区三区| 亚洲一级影院| 久久亚洲一区二区| 欧美日韩精品二区第二页| 国产精品夫妻自拍| 合欧美一区二区三区| 亚洲精品免费一二三区| 亚洲性图久久| 免费欧美日韩国产三级电影| 亚洲国产激情| 亚洲欧美国产毛片在线| 久久这里只有精品视频首页| 欧美视频在线视频| 午夜亚洲视频| 亚洲三级影院| 黑丝一区二区三区| 一区二区欧美在线观看| 欧美怡红院视频| 91久久国产综合久久| 欧美一区二区啪啪| 欧美系列精品| 亚洲国产综合91精品麻豆| 亚洲欧美中文另类| 亚洲欧洲日本在线| 一区二区三区四区国产| 久久精品国产综合精品| 欧美视频一二三区| 亚洲精品资源美女情侣酒店| 韩国福利一区| 亚洲欧美日韩成人| 91久久夜色精品国产网站| 久久精品官网| 国产伦精品一区| 亚洲手机成人高清视频| 国产精品久久久久aaaa| 欧美v亚洲v综合ⅴ国产v| 国产日韩精品在线观看| 亚洲免费一在线| 99综合精品| 欧美日本在线视频| 亚洲精品在线看| 亚洲第一二三四五区| 久久婷婷国产麻豆91天堂| 国产综合久久久久久鬼色| 欧美一区二区三区喷汁尤物| 亚洲图中文字幕| 国产精品久久久久久久app| 亚洲综合丁香| 亚洲午夜影视影院在线观看| 亚洲少妇诱惑| 亚洲国产精品va在线看黑人| 久久综合国产精品| 国产欧美精品日韩精品| 国产日韩在线视频| 久久久国产精品一区| 亚洲欧美日韩一区二区三区在线| 国产精品国产三级国产aⅴ入口| 一区二区福利| 亚洲视频狠狠| 国产一区二区三区久久| 久久一本综合频道| 噜噜噜91成人网| 99riav久久精品riav| 日韩一级精品| 国产精品永久免费| 开心色5月久久精品| 美女福利精品视频| 一区二区三区视频观看| 亚洲天堂av电影| 国产又爽又黄的激情精品视频| 久久久久久国产精品一区| 国产精品永久| 可以免费看不卡的av网站| 久久精品国产99| 亚洲人成网站在线播| 中文久久精品| 在线精品一区二区| 99香蕉国产精品偷在线观看| 国产精品日韩在线观看| 欧美一区二区视频在线| 一区二区三区欧美亚洲| 国产喷白浆一区二区三区| 欧美aa在线视频| 欧美性色综合| 蜜桃伊人久久| 国产精品美腿一区在线看| 免费日韩av| 国产精品国色综合久久| 毛片一区二区三区| 国产精品成人一区二区三区夜夜夜| 久久se精品一区二区| 欧美成人免费播放| 久久国产精品久久国产精品| 欧美国产精品久久| 久久频这里精品99香蕉| 欧美精品不卡| 久久久人人人| 国产精品久久久久久久久久久久久| 久久夜色精品国产| 国产精品福利av| 亚洲国产精品久久久久婷婷884| 欧美性猛交xxxx乱大交退制版 | 欧美日本在线视频| 久久伊人免费视频| 国产精品久久91| 亚洲三级电影全部在线观看高清| 国产情人综合久久777777| 99re视频这里只有精品| 免费亚洲视频| 亚洲欧美精品| 亚洲一二三区视频在线观看| 欧美电影免费观看| 久久青草福利网站| 国产日本欧美一区二区三区| 99这里只有精品| 9国产精品视频| 欧美成人高清| 女人天堂亚洲aⅴ在线观看| 国产视频亚洲精品| 亚洲欧美日韩在线高清直播| 亚洲欧美电影院| 国产精品高清网站| 一本色道88久久加勒比精品 | 老牛影视一区二区三区| 久久久久国色av免费观看性色| 国产精品久久国产精麻豆99网站| 亚洲精品自在久久| 99综合视频| 欧美四级在线观看| 欧美日韩免费一区| 亚洲精品激情| 国产一区二区三区四区hd| 亚洲一级片在线观看| 亚洲欧美日韩国产中文在线| 国产精品va在线播放| 亚洲伊人伊色伊影伊综合网| 亚洲欧美区自拍先锋| 午夜久久美女| 欧美日韩中字| 一区二区三区日韩精品| 伊人婷婷欧美激情| 国产精品久久二区二区| 欧美精品福利| 久久久91精品| 亚洲欧美一区二区视频| 亚洲巨乳在线| 亚洲福利免费| 美女成人午夜| 久久久久九九九| 欧美在线观看网站| 亚洲免费视频一区二区| 亚洲最新在线| 亚洲精品欧美| 亚洲缚视频在线观看| 国产综合婷婷| 国产亚洲精品成人av久久ww| 国产精品国产精品| 欧美色综合网| 欧美日韩中国免费专区在线看| 免费在线看一区| 久久精品国产亚洲一区二区三区 | 看欧美日韩国产| 久久久久国产一区二区| 西瓜成人精品人成网站| 亚洲在线视频观看| 亚洲一级在线| 亚洲一区3d动漫同人无遮挡| 亚洲无线视频| 亚洲欧美日韩成人| 欧美亚洲视频| 久久国产福利| 欧美久久综合| 久久人91精品久久久久久不卡| 久久精品99国产精品日本| 久久久国产精品一区| 久久天天综合| 亚洲成色www8888| 欧美好骚综合网| 亚洲精品在线观看免费| 在线亚洲免费视频| 亚洲欧美日韩国产成人精品影院| 亚洲你懂的在线视频| 欧美在线www| 久久免费视频一区| 欧美国内亚洲| 国产精品成av人在线视午夜片| 国产精品日韩在线| 在线观看的日韩av| 中文有码久久| 久久久精品国产免费观看同学|