本文整理汇总了C++中GameError函数的典型用法代码示例。如果您正苦于以下问题:C++ GameError函数的具体用法?C++ GameError怎么用?C++ GameError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GameError函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Ammo
void Menu::initialize(Graphics *g, Input *i)
{
mainMenu.push_back("Main Menu");
mainMenu.push_back("Recovery - 200"); mainMenu.push_back("Projectile Ammo (Not in yet) - 100"); mainMenu.push_back("Done");
titleMenu.push_back("Play"); titleMenu.push_back("Controls");
retryMenu.push_back("Retry"); retryMenu.push_back("Exit");
scoreScreen.push_back("Scores");
highlightColor = graphicsNS::RED;
normalColor = graphicsNS::WHITE;
menuAnchor = D3DXVECTOR2(50,50);
input = i;
verticalOffset = 45;
horizontalOffset = 160;
linePtr = 0;
selectedItem = -1;
graphics = g;
menuItemFont = new TextDX();
menuHeadingFont = new TextDX();
menuItemFontHighlight = new TextDX();
if(menuItemFont->initialize(graphics, 20, true, false, "Calibri") == false)
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing menuItem font"));
if(menuItemFontHighlight->initialize(graphics, 25, true, false, "Calibri") == false)
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing menuItem font"));
if(menuHeadingFont->initialize(graphics, 35, true, false, "Calibri") == false)
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing menuHeading font"));
menuHeadingFont->setFontColor(normalColor);
menuItemFont->setFontColor(normalColor);
menuItemFontHighlight->setFontColor(highlightColor);
upDepressedLastFrame = false;
downDepressedLastFrame = false;
mainDepressedLastFrame = false;
titleMenuDepressedLastFrame = false;
done = false;
}
开发者ID:Sariander,项目名称:Games-Project-2,代码行数:34,代码来源:menu+(Young).cpp
示例2: throw
bool NPC::initialize(Game* gamePtr, int width, int height, int ncols, TextureManager* textureM, Image* gameDialogBox)
{
gameConfig = gamePtr->getGameConfig();
// image must be initialized first in order to use sprite size data
bool result = Entity::initialize(gamePtr, width, height, ncols, textureM);
// active and set collision box area
active = true;
edge.left = -spriteData.width/2;
edge.right = spriteData.width/2;
edge.top = -spriteData.height/2;
edge.bottom = spriteData.height/2;
dialogBox = gameDialogBox;
if(!dialogText.initialize(gamePtr->getGraphics(), SPRITE_TEXT_FILE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing NPC dialogText"));
dialogText.setFontHeight(14);
if(!responseText.initialize(gamePtr->getGraphics(), SPRITE_TEXT_FILE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing NPC response Text"));
responseText.setFontHeight(14);
// dialogText.setProportional(true);
if(!selectorTexture.initialize(gamePtr->getGraphics(), "pictures/text/selector.png"))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing NPC selector texture"));
if(!selector.initialize(gamePtr->getGraphics(), 0, 0, 0, &selectorTexture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing NPC selector image"));
return result;
}
开发者ID:cknolla,项目名称:WichitaGame,代码行数:30,代码来源:npc.cpp
示例3: TextureManager
ItemController::ItemController(Graphics *graphics, TextureManager* iTxt) {
itemTexture = new TextureManager();
if (!itemTexture->initialize(graphics, TEXTURE_ITEM))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing item texture"));
crateList = new std::list<Crate*>();
itemList = std::vector<Item*>();
//init crate location first
levelCrateLoc[0] = new std::list<VECTOR2>();
levelCrateLoc[0]->push_back(VECTOR2(321, 568)); // crate 1.1
levelCrateLoc[0]->push_back(VECTOR2(1152, 250)); // crate 2.1
levelCrateLoc[0]->push_back(VECTOR2(2447, 250)); //crate 2.5.1
levelCrateLoc[0]->push_back(VECTOR2(2688, 668)); // crate 3.1
levelCrateLoc[0]->push_back(VECTOR2(2815, 602)); // crate 3.2
//init crate item second
levelCrateItemType[0] = new std::list<int>();
levelCrateItemType[0]->push_back(itemControllerNS::ItemType::machineGun); // crate 1.1
levelCrateItemType[0]->push_back(itemControllerNS::ItemType::shotGun); // crate 2.1
levelCrateItemType[0]->push_back(itemControllerNS::ItemType::machineGun); // crate 2.5.1
levelCrateItemType[0]->push_back(itemControllerNS::ItemType::machineGun); // crate 3.1
levelCrateItemType[0]->push_back(itemControllerNS::ItemType::shotGun); // crate 3.2
itemIconTexture = iTxt;
gunTexture = new TextureManager();
if (!gunTexture->initialize(graphics, TEXTURE_GUNS))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing gun texture"));
gunImage = new Image();
gunImage->initialize(graphics, itemControllerNS::GUN_TEXTURE_WIDTH, itemControllerNS::GUN_TEXTURE_HEIGHT, 1, gunTexture);
itemIconTexture = new TextureManager();
if (!itemIconTexture->initialize(graphics, ITEM_ICON_TEXTURE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing item icon texture"));
}
开发者ID:Capeguy,项目名称:GPAssignment2,代码行数:31,代码来源:itemController.cpp
示例4: Graphics
//=============================================================================
// Initializes the game
// throws GameError on error
//=============================================================================
void Game::initialize(HWND hw)
{
hwnd = hw; // save window handle
// initialize graphics
graphics = new Graphics();
// throws GameError
graphics->initialize(hwnd, GAME_WIDTH, GAME_HEIGHT, FULLSCREEN);
// initialize input, do not capture mouse
input->initialize(hwnd, false); // throws GameError
// init sound system
audio = new Audio();
if (*WAVE_BANK != '\0' && *SOUND_BANK != '\0') // if sound files defined
{
if( FAILED( hr = audio->initialize() ) )
{
if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) )
throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system because media file not found."));
else
throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system."));
}
}
// attempt to set up high resolution timer
if(QueryPerformanceFrequency(&timerFreq) == false)
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing high resolution timer"));
QueryPerformanceCounter(&timeStart); // get starting time
initialized = true;
}
开发者ID:Cusimonster,项目名称:Asteroids,代码行数:38,代码来源:game.cpp
示例5: Direct3DCreate9
void Graphics::initialize(HWND hw, int w, int h, bool full)
{
hwnd = hw;
width = w;
height = h;
fullscreen = full;
direct3d = Direct3DCreate9(D3D_SDK_VERSION);
if (direct3d == NULL)
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing Direct3D"));
initD3Dpp();
if(fullscreen)
{
if(isAdapterCompatible())
d3dpp.FullScreen_RefreshRateInHz = pMode.RefreshRate;
else
throw(GameError(gameErrorNS::FATAL_ERROR,
"The graphics device does not support the specified resolution and/or format."));
}
D3DCAPS9 caps;
DWORD behavior;
result = direct3d->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &caps);
if( (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
caps.VertexShaderVersion < D3DVS_VERSION(1,1) )
behavior = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
else
behavior = D3DCREATE_HARDWARE_VERTEXPROCESSING;
result = direct3d->CreateDevice(
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
hwnd,
behavior,
&d3dpp,
&device3d);
if (FAILED(result))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error creating Direct3D device"));
result = D3DXCreateSprite(device3d, &sprite);
if (FAILED(result))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error creating Direct3D sprite"));
device3d->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
device3d->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device3d->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
if( FAILED( direct3d->CheckDeviceFormat(caps.AdapterOrdinal,
caps.DeviceType,
d3dpp.BackBufferFormat,
D3DUSAGE_DEPTHSTENCIL,
D3DRTYPE_SURFACE,
D3DFMT_D24S8 ) ) )
stencilSupport = false;
else
stencilSupport = true;
device3d->CreateQuery(D3DQUERYTYPE_OCCLUSION, &pOcclusionQuery);
}
开发者ID:KWJYP,项目名称:M.J_Physical_GameStudio_Engine,代码行数:59,代码来源:graphics.cpp
示例6: GameConfig
//=============================================================================
// Initializes the game
// throws GameError on error
//=============================================================================
void Game::initialize(HWND hw)
{
hwnd = hw; // save window handle
//AllocConsole();
// initialize gameConfig
gameConfig = new GameConfig();
gameConfig->initialize(hwnd);
// initialize graphics
graphics = new Graphics();
// throws GameError
graphics->initialize(hwnd, gameConfig->getGameWidth(), gameConfig->getGameHeight(), FULLSCREEN);
// initialize input, do not capture mouse
input->initialize(hwnd, false); // throws GameError
// initialize console
console = new Console();
console->initialize(graphics, input); // prepare console
console->print("---Console---");
// initialize messageDialog
messageDialog = new MessageDialog();
messageDialog->initialize(graphics, input, hwnd);
// initialize inputDialog
inputDialog = new InputDialog();
inputDialog->initialize(graphics, input, hwnd);
// initialize DirectX font
if(dxFont.initialize(graphics, gameNS::POINT_SIZE, false, false, gameNS::FONT) == false)
throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize DirectX font."));
dxFont.setFontColor(gameNS::FONT_COLOR);
// init sound system
audio = new Audio();
if (*WAVE_BANK != '\0' && *SOUND_BANK != '\0') // if sound files defined
{
if( FAILED( hr = audio->initialize() ) )
{
if( hr == HRESULT_FROM_WIN32( ERROR_FILE_NOT_FOUND ) )
throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system because media file not found."));
else
throw(GameError(gameErrorNS::FATAL_ERROR, "Failed to initialize sound system."));
}
}
// attempt to set up high resolution timer
if(QueryPerformanceFrequency(&timerFreq) == false)
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing high resolution timer"));
QueryPerformanceCounter(&timeStart); // get starting time
initialized = true;
}
开发者ID:cknolla,项目名称:WichitaGame,代码行数:61,代码来源:game.cpp
示例7: TextureManager
HUD::HUD(Graphics*& g) {
graphics = g;
itemTexture = new TextureManager();
gunHUDTexture = new TextureManager();
hpHUDTexture = new TextureManager();
hpTexture = new TextureManager();
//Load and set up hp HUD texture
if (!hpHUDTexture->initialize(graphics, TEXTURE_HUD_HP))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing hp hud texture"));
hpHUD = new Image();
hpHUD->initialize(graphics, hudNS::HP_HUD_WIDTH, hudNS::HP_HUD_HEIGHT, 1, hpHUDTexture);
hpHUD->setCurrentFrame(0);
hpHUD->setX(50);
hpHUD->setY(60);
if (!hpTexture->initialize(graphics, TEXTURE_HUD_HP_RED))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing hp texture"));
hp = new Image();
hp->initialize(graphics, hudNS::HP_WIDTH, hudNS::HP_HEIGHT, 1, hpTexture);
hp->setCurrentFrame(0);
hp->setX(hpHUD->getX() + 30);
hp->setY(hpHUD->getY());
//Load and set up gun HUD texture
if (!gunHUDTexture->initialize(graphics, TEXTURE_HUD_GUN))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing gun hud texture"));
gunHud = new Image();
gunHud->initialize(graphics, hudNS::GUN_HUD_WIDTH, hudNS::GUN_HUD_HEIGHT, 1, gunHUDTexture);
gunHud->setCurrentFrame(0);
gunHud->setX(hpHUD->getX() + hpHUD->getWidth() + 50);
gunHud->setY(50);
//Load and set up item HUD texture
if (!itemTexture->initialize(graphics, TEXTURE_GUNS))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing gun texture"));
currentItemImage = new Image();
currentItemImage->initialize(graphics, gunNS::TEXTURE_WIDTH, gunNS::TEXTURE_HEIGHT, gunNS::TEXTURE_COLS, itemTexture);
currentItemImage->setX(gunHud->getX());
currentItemImage->setY(gunHud->getY() + 10);
currentItemImage->setScale(0.8);
//Load and set up Points HUD texture
pointHud = new Image();
pointHud->initialize(graphics, hudNS::GUN_HUD_WIDTH, hudNS::GUN_HUD_HEIGHT, 1, gunHUDTexture);
pointHud->setCurrentFrame(0);
pointHud->setX(gunHud->getX() + gunHud->getWidth() + 50);
pointHud->setY(50);
//set up font
ammoFont = new TextDX();
ammoFont->initialize(graphics, 20, false, false, "Courier New");
ammoFont->setFontColor(SETCOLOR_ARGB(192, 0, 0, 0));
currentItem = nullptr;
currentPlayer = nullptr;
}
开发者ID:Capeguy,项目名称:GPAssignment2,代码行数:55,代码来源:hud.cpp
示例8: throw
bool Bowser::initialize(Game *gamePtr, int width, int height, int ncols,
TextureManager *textureM)
{
attackTimer = 1.0f;
// Bowser sprite initialize
bowserSpriteCoordinates.populateVector("sprite_data\\bowser.xml");
if (!initializeCoords(bowserSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bowser"));
//Idle
bowserIdle.initialize(gamePtr->getGraphics(), bowserNS::WIDTH,
bowserNS::HEIGHT, 0, textureM);
if (!bowserIdle.initialize(bowserSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bowser"));
bowserIdle.setFrames(bowserNS::IDLE_START_FRAME, bowserNS::IDLE_END_FRAME);
bowserIdle.setCurrentFrame(bowserNS::IDLE_START_FRAME);
bowserIdle.setFrameDelay(bowserNS::IDLE_ANIMATION_DELAY);
//Spin Attack
bowserSpin.initialize(gamePtr->getGraphics(), bowserNS::WIDTH,
bowserNS::HEIGHT, 0, textureM);
if (!bowserSpin.initialize(bowserSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bowser"));
bowserSpin.setFrames(bowserNS::SPIN_START_FRAME, bowserNS::SPIN_END_FRAME);
bowserSpin.setCurrentFrame(bowserNS::SPIN_START_FRAME);
bowserSpin.setFrameDelay(bowserNS::SPIN_ANIMATION_DELAY);
// Fire Ball Attack
bowserFireBreath.initialize(gamePtr->getGraphics(), bowserNS::WIDTH,
bowserNS::HEIGHT, 0, textureM);
if (!bowserFireBreath.initialize(bowserSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bowser"));
bowserFireBreath.setFrames(bowserNS::FIRE_BREATH_START_FRAME, bowserNS::FIRE_BREATH_END_FRAME);
bowserFireBreath.setCurrentFrame(bowserNS::FIRE_BREATH_START_FRAME);
bowserFireBreath.setFrameDelay(bowserNS::FIRE_BREATH_ANIMATION_DELAY);
//Dying
bowserDying.initialize(gamePtr->getGraphics(), bowserNS::WIDTH,
bowserNS::HEIGHT, 0, textureM);
if (!bowserDying.initialize(bowserSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing bowser"));
bowserDying.setFrames(bowserNS::DYING_START_FRAME, bowserNS::DYING_END_FRAME);
bowserDying.setCurrentFrame(bowserNS::DYING_START_FRAME);
bowserDying.setFrameDelay(bowserNS::DYING_ANIMATION_DELAY);
bowserDying.setLoop(false);
return(Entity::initialize(gamePtr, width, height, ncols, textureM));
}
开发者ID:SyndicateX,项目名称:Mega-Man-X,代码行数:49,代码来源:Bowser.cpp
示例9: throw
//=============================================================================
// Initializes the game
// Throws GameError on error
//=============================================================================
void Spacewar::initialize(HWND hwnd)
{
Game::initialize(hwnd); // throws GameError
// nebula texture
if (!nebulaTexture.initialize(graphics,NEBULA_IMAGE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula texture"));
// main game textures
if (!gameTextures.initialize(graphics,TEXTURES_IMAGE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing game textures"));
// nebula image
if (!nebula.initialize(graphics,0,0,0,&nebulaTexture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing nebula"));
// planet
if (!planet.initialize(this, planetNS::WIDTH, planetNS::HEIGHT, 2, &gameTextures))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing planet"));
// ship
if (!ship1.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, true))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship1"));
ship1.setFrames(shipNS::SHIP1_START_FRAME, shipNS::SHIP1_END_FRAME);
ship1.setCurrentFrame(shipNS::SHIP1_START_FRAME);
ship1.setX(GAME_WIDTH/4);
ship1.setY(GAME_HEIGHT/4);
ship1.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
// ship2
if (!ship2.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, true))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship2"));
ship2.setFrames(shipNS::SHIP2_START_FRAME, shipNS::SHIP2_END_FRAME);
ship2.setCurrentFrame(shipNS::SHIP2_START_FRAME);
ship2.setX(GAME_WIDTH - GAME_WIDTH/4);
ship2.setY(GAME_HEIGHT/4);
ship2.setVelocity(VECTOR2(-shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
//ship3 initalization. Do not rotate, start pointing north. This ship is controlled by the arrow keys.
//ship3 ignores direction and will move in the direction of the key
if (!ship3.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, false))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship3"));
ship3.setFrames(shipNS::SHIP1_START_FRAME, shipNS::SHIP1_END_FRAME);
ship3.setCurrentFrame(shipNS::SHIP1_START_FRAME);
ship3.setX(GAME_WIDTH - GAME_WIDTH/4);
ship3.setY(GAME_HEIGHT - GAME_HEIGHT/4);
ship3.setDegrees(270);
//ship3.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
//ship4 initalization. Do not rotate, start pointing north. This ship is controlled by WASD
//ship4 will rotate with A and D, and will move forward based on direction on W, and move backward based on direction on S.
if (!ship4.initialize(this, shipNS::WIDTH, shipNS::HEIGHT, shipNS::TEXTURE_COLS, &gameTextures, false))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing ship4"));
ship4.setFrames(shipNS::SHIP2_START_FRAME, shipNS::SHIP2_END_FRAME);
ship4.setCurrentFrame(shipNS::SHIP2_START_FRAME);
ship4.setX(GAME_WIDTH/4);
ship4.setY(GAME_HEIGHT - GAME_HEIGHT/4);
ship4.setDegrees(270);
//ship4.setVelocity(VECTOR2(shipNS::SPEED,-shipNS::SPEED)); // VECTOR2(X, Y)
return;
}
开发者ID:Capeguy,项目名称:GPAssignment2,代码行数:63,代码来源:spacewar.cpp
示例10: throw
bool ParticleManager::initialize(Graphics *g)
{
if (!tm.initialize(g, FLAMES_IMAGE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing dust texture"));
for (int i = 0; i < MAX_NUMBER_PARTICLES; i++)
{
if (!particles[i].initialize(g,0,0,0,&tm))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing dust"));
particles[i].setActive(false);
particles[i].setVisible(false);
particles[i].setScale(0.125f);
//particles[i].setRotationValue(0.05f);
}
return true;
}
开发者ID:tylermulley,项目名称:Goblins-and-Castle,代码行数:15,代码来源:particleManager.cpp
示例11: ZeroMemory
//=============================================================================
// Initialize D3D presentation parameters
//=============================================================================
void Graphics::initD3Dpp()
{
try{
ZeroMemory(&d3dpp, sizeof(d3dpp)); // fill the structure with 0
// fill in the parameters we need
d3dpp.BackBufferWidth = width;
d3dpp.BackBufferHeight = height;
if(fullscreen) // if fullscreen
d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; // 24 bit color
else
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; // use desktop setting
d3dpp.BackBufferCount = 1;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.hDeviceWindow = hwnd;
d3dpp.Windowed = (!fullscreen);
if(VSYNC) // if vertical sync is enabled
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
else
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
d3dpp.EnableAutoDepthStencil = true;
d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // Depth 24, Stencil 8
} catch(...)
{
throw(GameError(gameErrorNS::FATAL_ERROR,
"Error initializing D3D presentation parameters"));
}
}
开发者ID:RodionChachura,项目名称:Bomberman,代码行数:30,代码来源:graphics.cpp
示例12: RegisterRawInputDevices
// ==================================================================
// マウスとコントローラの入力を初期化
// マウスをキャプチャする場合、capture = trueを設定
// GameErrorをスロー
// ==================================================================
void Input::initialize(HWND hwnd, bool capture)
{
try
{
mouseCaptured = capture;
// 高精細マウスを登録
Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
Rid[0].dwFlags = RIDEV_INPUTSINK;
Rid[0].hwndTarget = hwnd;
RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));
if(mouseCaptured)
SetCapture(hwnd); // マウスをキャプチャ
// コントローラの状態をクリア
ZeroMemory(controllers, sizeof(ControllerState) * MAX_CONTROLLERS);
checkControllers(); // 接続されているコントローラをチェック
}
catch(...)
{
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing input system"));
}
}
开发者ID:poiulkjhmnbv,项目名称:SpaceGo,代码行数:30,代码来源:input.cpp
示例13: Bullet
void CyraxWComponent::activate(bool facingRight, float x, float y, Game *cipher)
{
Bullet *newBullet = new Bullet();
newBullet->setBulletSprite(CyraxWComponentNS::WIDTH, CyraxWComponentNS::HEIGHT, CyraxWComponentNS::WBULLET_START_FRAME, CyraxWComponentNS::WBULLET_END_FRAME, 100);
newBullet->setCurrentFrame(CyraxWComponentNS::WBULLET_START_FRAME);
if (!newBullet->initialize(cipher, CyraxWComponentNS::WIDTH, CyraxWComponentNS::HEIGHT, CyraxWComponentNS::TEXTURE_COLS, &WbulletTexture))
{
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing cyrax W"));
}
newBullet->setX(x);
newBullet->setY(y);
newBullet->setActive(true);
VECTOR2 direction;
if (facingRight) //shoot right
{
direction.x = CyraxWComponentNS::WBULLET_MIN_SPEED;
direction.y = CyraxWComponentNS::WBULLET_MIN_SPEED;
newBullet->flipHorizontal(true);
newBullet->setDirection(direction);
}
else if (!facingRight) //shoot left
{
direction.x = -CyraxWComponentNS::WBULLET_MIN_SPEED;
direction.y = CyraxWComponentNS::WBULLET_MIN_SPEED;
newBullet->setDirection(direction);
}
bulletList.push_back(newBullet);
}
开发者ID:fire2fox433,项目名称:GPP-Final,代码行数:28,代码来源:CyraxWComponent.cpp
示例14: RegisterRawInputDevices
//=============================================================================
// Initialize mouse and controller input
// Set capture=true to capture mouse
// Throws GameError
//=============================================================================
void Input::initialize(HWND hwnd, bool capture)
{
try {
mouseCaptured = capture;
// register high-definition mouse
Rid[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
Rid[0].usUsage = HID_USAGE_GENERIC_MOUSE;
Rid[0].dwFlags = RIDEV_INPUTSINK;
Rid[0].hwndTarget = hwnd;
RegisterRawInputDevices(Rid, 1, sizeof(Rid[0]));
if(mouseCaptured)
SetCapture(hwnd); // capture mouse
// Clear controllers state
ZeroMemory( controllers, sizeof(ControllerState) * MAX_CONTROLLERS );
checkControllers(); // check for connected controllers
}
catch(...)
{
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing input system"));
}
}
开发者ID:oracle991,项目名称:ThreesClone,代码行数:30,代码来源:input.cpp
示例15: throw
//=============================================================================
// Initializes the game
// Throws GameError on error
//=============================================================================
void GroveMon::initialize(HWND hwnd) {
Game::initialize(hwnd);
for (int i = 0; i < nTextures; i++) {
if (!textures[i].initialize(graphics, images[i].c_str()))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing texture"));
}
text.initialize(graphics, 24, false, false, "Cambria");
background.initialize(graphics, 0, 0, 0, &textures[3]);
background.setX(0);
background.setY(0);
textBoxBack.initialize(graphics, 0, 0, 0, &textures[4]);
textBoxBack.setX(0);
textBoxBack.setY(290);
textBoxBack.setScale(GAME_WIDTH / textBoxBack.getWidth());
liz.initialize(graphics, 0, 0, 0, &textures[2]);
liz.setScale(0.5);
lizard->image = &liz;
tur.initialize(graphics, 0, 0, 0, &textures[0]);
tur.setScale(0.5);
turtle->image = &tur;
din.initialize(graphics, 0, 0, 0, &textures[1]);
din.setScale(0.5);
dino->image = &din;
}
开发者ID:Danice123,项目名称:GroveMon,代码行数:33,代码来源:GroveMon.cpp
示例16: NecridQComponent
Necrid::Necrid(Game *cipher)
{
Qcomponent = new NecridQComponent(cipher);
Wcomponent = new NecridWComponent(cipher);
Ecomponent = new NecridEComponent(cipher);
//Rcomponent = new NecridRComponent();
Q_CoolDown = NecridNS::QSkillCD;
W_CoolDown = NecridNS::WSkillCD;
E_CoolDown = NecridNS::ESkillCD;
if (!characterTexture.initialize(cipher->getGraphics(), NECRID_IMAGE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing Player texture"));
if (!this->initialize(cipher, charactersNS::WIDTH, charactersNS::HEIGHT, NecridNS::TEXTURE_COLS, &characterTexture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing player"));
currentFrame = startFrame;
startFrame = NecridNS::NECRID_START_FRAME; // first frame of ship animation
endFrame = NecridNS::NECRID_END_FRAME; // last frame of ship animation
}
开发者ID:fire2fox433,项目名称:GPP-Final,代码行数:17,代码来源:Necrid.cpp
示例17: Agent47QComponent
Agent47::Agent47(Game *cipher)
{
Qcomponent = new Agent47QComponent(cipher);
Wcomponent = new Agent47WComponent(cipher);
Ecomponent = new Agent47EComponent(cipher);
//Rcomponent = new Agent47RComponent();
Q_CoolDown = Agent47NS::QSkillCD;
W_CoolDown = Agent47NS::WSkillCD;
E_CoolDown = Agent47NS::ESkillCD;
if (!characterTexture.initialize(cipher->getGraphics(), AGENT47_IMAGE))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing Player texture"));
if (!this->initialize(cipher, charactersNS::WIDTH, charactersNS::HEIGHT, Agent47NS::TEXTURE_COLS, &characterTexture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing player"));
currentFrame = startFrame;
startFrame = Agent47NS::AGENT_START_FRAME; // first frame of ship animation
endFrame = Agent47NS::AGENT_END_FRAME; // last frame of ship animation
}
开发者ID:fire2fox433,项目名称:GPP-Final,代码行数:17,代码来源:Agent47.cpp
示例18: throw
void Character_Menu::initialize(HWND hwnd, Graphics*& graphics, bool right)
{
if (right)//PLAYER 2
{
goku_ = GOKU_2;
piccolo_ = PICCOLO_2;
naruto_ = NARUTO_2;
luffy_ = LUFFY_2;
}
else//player 1
{
goku_ = GOKU_1;
piccolo_ = PICCOLO_1;
naruto_ = NARUTO_1;
luffy_ = LUFFY_1;
}
//initializing goku menu
if (!goku_image.initialize(graphics,GAME_WIDTH,GAME_HEIGHT,0,&goku_texture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing GOKU menu"));
if (!goku_texture.initialize(graphics,goku_,TRANSCOLORR))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing GOKU menu texture"));
//initializing piccolo menu
if (!piccolo_image.initialize(graphics, GAME_WIDTH, GAME_HEIGHT, 0, &piccolo_texture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing PICCOLO menu"));
if (!piccolo_texture.initialize(graphics, piccolo_, TRANSCOLORR))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing start PICCOLO texture"));
//initilaizing naruto menu
if (!naruto_image.initialize(graphics, GAME_WIDTH, GAME_HEIGHT, 0, &naruto_texture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing naruto menu"));
if (!naruto_texture.initialize(graphics, naruto_, TRANSCOLORR))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing start naruto texture"));
//initialize luffy menu
if (!luffy_image.initialize(graphics, GAME_WIDTH, GAME_HEIGHT, 0, &luffy_texture))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing luffy menu"));
if (!luffy_texture.initialize(graphics, luffy_, TRANSCOLORR))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing start luffy texture"));
//place player 2 on the other side of screem
if (right)
{
goku_image.setX(GAME_WIDTH / 2);
piccolo_image.setX(GAME_WIDTH / 2);
naruto_image.setX(GAME_WIDTH / 2);
luffy_image.setX(GAME_WIDTH / 2);
}
}
开发者ID:claudiahnandez,项目名称:Math-273-Project,代码行数:55,代码来源:Character_Menu.cpp
示例19: GameError
GameManager::GameManager()
{
if( m_pGameManager )
throw GameError( "[GameManager::GameManager]: Attempt to instantiate multiple instances of singleton class GameManager." );
m_pGameManager = this;
/* Setup default game settings. */
PlayerConfiguration playerConfig;
// Player defaults: 1 user controlled and 3 AI players.
m_gameConfig.NumPlayers = 4;
playerConfig.IsAIPlayer = false;
m_gameConfig.PlayerConfigs.push_back( playerConfig );
playerConfig.IsAIPlayer = true;
m_gameConfig.PlayerConfigs.push_back( playerConfig );
m_gameConfig.PlayerConfigs.push_back( playerConfig );
m_gameConfig.PlayerConfigs.push_back( playerConfig );
// Dealer defaults.
m_gameConfig.DealerConfig.HitOnSoftSeventeen = false;
// Misc defaults.
m_gameConfig.AllowSplit = true;
m_gameConfig.AllowSurrender = false;
// Add some AI players.
m_players.push_back( new UserPlayer( 1 ) );
m_players.push_back( new AIPlayer( 2 ) );
m_players.push_back( new AIPlayer( 3 ) );
m_players.push_back( new AIPlayer( 4 ) );
/* Create game visualizer and input singletons */
GameInput::Create();
GameVisualizer::Create();
// Visualize game board
GameVisuals()->Visualize( GameVisualizer::GameBoard );
// Initialize visualizations for player names & starting chips
sPlayerXNameChanged nameData;
sPlayerXSetChipsToY chipsData;
for( uint index = 0; index < m_players.size(); ++index )
{
nameData.playerIndex = index;
nameData.name = std::string("Player ") + NumToStr( index + 1 );
chipsData.playerIndex = index;
chipsData.chips = m_players[ index ]->GetChips();
GameVisuals()->Visualize( GameVisualizer::PlayerXNameChanged, (void*)&nameData );
GameVisuals()->Visualize( GameVisualizer::PlayerXSetChipsToY, (void*)&chipsData );
}
}
开发者ID:Jerorfigan,项目名称:BlackJack,代码行数:57,代码来源:GameManager.cpp
示例20: throw
//=============================================================================
// Initialize Mega Man.
// Post: returns true if successful, false if failed
//=============================================================================
bool chargingSprites::initialize(Game *gamePtr, int width, int height, int ncols,
TextureManager *textureM)
{
// chargingSprites shooting sprite initialize
megamanShootingSpriteCoordinates.populateVector("sprite_data\\xshootcoords.txt");
if (!initializeCoords(megamanShootingSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing chargingSprites"));
megamanCharge1.initialize(gamePtr->getGraphics(), chargingSpritesNS::WIDTH,
chargingSpritesNS::HEIGHT, 0, textureM);
if (!megamanCharge1.initialize(megamanShootingSpriteCoordinates))
throw(GameError(gameErrorNS::FATAL_ERROR, "Error initializing chargingSprites"));
megamanCharge1.setFrames(chargingSpritesNS::CHARGE1_MEGAMAN_START_FRAME, chargingSpritesNS::CHARGE1_MEGAMAN_END_FRAME);
megamanCharge1.setCurrentFrame(chargingSpritesNS::CHARGE1_MEGAMAN_START_FRAME);
megamanCharge1.setFrameDelay(chargingSpritesNS::CHARGE1_MEGAMAN_ANIMATION_DELAY);
return(Entity::initialize(gamePtr, width, height, ncols, textureM));
}
开发者ID:SyndicateX,项目名称:Mega-Man-X,代码行数:22,代码来源:chargingSprites.cpp
注:本文中的GameError函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论