本文整理汇总了C++中MenuManager::ReadKeyboardModifiers方法的典型用法代码示例。如果您正苦于以下问题:C++ MenuManager::ReadKeyboardModifiers方法的具体用法?C++ MenuManager::ReadKeyboardModifiers怎么用?C++ MenuManager::ReadKeyboardModifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MenuManager
的用法示例。
在下文中一共展示了MenuManager::ReadKeyboardModifiers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RunGame
//=============================================================================
// Function: RunGame
// gets control from the main program and runs the main zzt++ loop.
// Parameters:
// none.
// Returns:
// nothing
//=============================================================================
void GameEngine::RunGame(void)
{
char xit=0; // exit game, false by default.
char shift='\0'; // shift pressed, false by default.
char x,y; // temporary storage for player coordinates
char currentboard;// current boad number during play
int c; // used to store character read from keyboard.
int mod; // used to store keyboard modifier status.
// We're playing a new game, so we go to the first board.
BM.SetCurrentBoard(1);
currentboard=BM.GetCurrentBoard();
// Draw the current board. The player gets drawn automatically.
BM.DrawBoard(BM.GetCurrentBoard());
// Get the modifiers from the keyboard
mod=MM.ReadKeyboardModifiers();
// check whether left or right shift was pressed
shift=((mod & KMOD_LFT) || (mod & KMOD_RGT));
// Set initial game speed.
SetSpeed(5);
// Draw game menu
MM.DrawMenu(GAMEMENU);
// start the main loop
while (!xit)
{
// Set counter at 0 at beginning of loop.
// this is declared in timerisr.hpp as global.
CycleCount=0;
// Store current player position on current (title screen) board
x=BM.BRDOBJ[currentboard][0].XPos;
y=BM.BRDOBJ[currentboard][0].YPos;
// Read a character from the keyboard buffer.
// This method of MM does not wait for user input.
c=MM.ReadKeyboard();
// Get the modifiers from the keyboard
mod=MM.ReadKeyboardModifiers();
// check whether left or right shift was pressed
shift=((mod & KMOD_LFT) || (mod & KMOD_RGT));
// now, interpret the command.
switch (c)
{
// Escape or Quit was pressed.
case 'q':
case 'Q':
case ESC: xit=Quit(); break;
// Player movement
// Player goes up
case UP:
if (shift)
{
// FIRE UP
}
else
{
y-=BM.Try(x,y-1)?1:0; BM.MovePlayer(x,y);
}
break;
// Player goes down
case DOWN:
if (shift)
{
// FIRE DOWN
}
else
{
y+=BM.Try(x,y+1)?1:0; BM.MovePlayer(x,y); break;
}
break;
// Player goes left
case LEFT:
if (shift)
{
// FIRE LEFT
}
else
{
x-=BM.Try(x-1,y)?1:0; BM.MovePlayer(x,y); break;
}
//.........这里部分代码省略.........