本文整理汇总了C++中CInput类的典型用法代码示例。如果您正苦于以下问题:C++ CInput类的具体用法?C++ CInput怎么用?C++ CInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main (int argc, char *argv[])
{
CWindow a ("Sample window", 10, 10, 600, 480);
a.Add (CButton (1, 0.1, 0.8, 0.3, 0.1, "Ok"))
.Add (CButton (2, 0.6, 0.8, 0.3, 0.1, "Cancel"));
a.Add (CLabel (10, 0.1, 0.1, 0.2, 0.1, "Username:"));
a.Add (CInput (11, 0.4, 0.1, 0.5, 0.1, "chucknorris"));
a.Add (CComboBox (20, 0.1, 0.3, 0.8, 0.1)
.Add ("Karate")
.Add ("Judo")
.Add ("Box")
.Add ("Progtest"));
cout << a;
CWindow b = a;
CControl *ctl = b.Search (20);
cout << *ctl;
CComboBox *cb = dynamic_cast<CComboBox *> (b.Search (20));
cb->SetSelected (3);
CInput *il = dynamic_cast<CInput *> (b.Search (11));
il->SetValue ("[email protected]");
b.Add (CComboBox (21, 0.1, 0.5, 0.8, 0.1)
.Add ("PA2")
.Add ("OSY")
.Add ("Both"));
cout << b;
b.SetPosition (20, 30, 640, 520);
cout << b;
return 0;
}
示例2: main
int main(int argc, char *argv[])
{
CBall *cPlayer;
cPlayer = new CBall();
CDisplay *cDsp;
cDsp = new CDisplay(XRES,YRES,BPP,SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_ANYFORMAT,0);
CInput *cInp;
cInp = new CInput(1);
CPaddle *cPdl;
cPdl = new CPaddle();
cout << cPlayer->GetLives()<<endl;
cPlayer->LoadIMG("images/ball.png");
cPdl->LoadIMG("images/paddle.png");
cPdl->setY((YRES/3)*2);
cPdl->setX((XRES/2));
cout << cPdl->getX() << " " << cPdl->getY();
cPdl->srect.w = cPdl->Surface->w;
cPdl->srect.h = cPdl->Surface->h;
cPdl->srect.x = cPdl->srect.y = 0;
cPdl->drect.w = cPdl->Surface->w;
cPdl->drect.h = cPdl->Surface->h;
while (CBall::running)
{
cPdl->drect.x = cPdl->xco;
cPdl->drect.y = cPdl->yco;
SDL_Event event;
while(SDL_PollEvent(&event))
{
CInput *cInp;
cInp = new CInput(1);
cout<<(cInp->updateInput(event))<<endl;
delete cInp;
}
cPdl->Blit(*cDsp->Surface,cPdl->srect);//,&cPdl->drect);
updateGameData();
SDL_Flip(cDsp->Surface);
}
return(0);
}
示例3: HandleGameInput
void HandleGameInput()
{
// This is not a function in our CInput class. We wanted the CInput class
// to be generic and not actually handle our game code, but just tell us what
// the user did. We can then make different function to handle the input
// for a given situation. We do this for character movement, save\load prompts,
// menus, etc...
// Let's get the key that the user pressed
int keyCode = g_Input.GetKeyCode();
// If we just hit a key from the keyboard, handle the input accordingly.
if(g_Input.IsKeyboardEvent() && g_Input.IsKeyDown())
{
if(keyCode == VK_ESCAPE) // If escape was pressed
exit(0); // Quit the game
else if(keyCode == VK_UP) // If up arrow key was pressed
g_Player.Move(kUp); // Move the character up
else if(keyCode == VK_DOWN) // If down arrow key was pressed
g_Player.Move(kDown); // Move the character down
else if(keyCode == VK_LEFT) // If left arrow key was pressed
g_Player.Move(kLeft); // Move the character left
else if(keyCode == VK_RIGHT) // If right arrow key was pressed
g_Player.Move(kRight); // Move the character right
// If the key pressed was for character movement, let's check for special tiles
if(keyCode == VK_RIGHT || keyCode == VK_LEFT || keyCode == VK_UP || keyCode == VK_DOWN)
{
// Here we check if the character stepped on an exit, if so .... exit.
g_Map.CheckForExit(g_Player.GetPosition().X, g_Player.GetPosition().Y);
// We want to draw the screen again if the character moved
g_Map.SetDrawFlag(true);
}
}
}
示例4: cmdLine
void FuzzwinAlgorithm::callPintool()
{
// ligne de commande pour appel de PIN avec l'entree en cours
std::string cmdLine(this->getCmdLinePintool());
// mise à zéro de la formule
_formula.erase();
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
if (CreateProcess(nullptr,
(LPSTR) cmdLine.c_str(),
NULL, // process security attributes
NULL, // primary thread security attributes
TRUE, // handles are inherited
CREATE_NO_WINDOW, // creation flags
NULL, // use parent's environment
NULL, // use parent's current directory
&si, &pi))
{
/***********************/
/** CONNEXION AU PIPE **/
/***********************/
BOOL fSuccess = ConnectNamedPipe(_hPintoolPipe, NULL);
if (!fSuccess && GetLastError() != ERROR_PIPE_CONNECTED)
{
this->logTimeStamp();
this->log("erreur de connexion au pipe FuzzWin GLE=" + std::to_string(GetLastError()));
this->logEndOfLine();
return; // formule vide
}
// envoi dans le pipe du chemin vers l'entrée étudiée
if (EXIT_FAILURE == sendArgumentToPintool(_pCurrentInput->getFilePath()))
{
return; // formule vide
}
/********************************************************/
/** ATTENTE DE L'ARRIVEE DES DONNEES DEPUIS LE PINTOOL **/
/********************************************************/
char buffer[512]; // buffer de récupération des données
DWORD cbBytesRead = 0;
// lecture successive de blocs de 512 octets
// et construction progressive de la formule
do
{
fSuccess = ReadFile(_hPintoolPipe, // pipe handle
&buffer[0], // buffer to receive reply
512, // size of buffer
&cbBytesRead, // number of bytes read
NULL); // not overlapped
if ( ! fSuccess && (GetLastError() != ERROR_MORE_DATA) ) break;
// ajout des données lues au resultat
_formula.append(&buffer[0], cbBytesRead);
} while (!fSuccess); // repetition si ERROR_MORE_DATA
// deconnexion du pipe
DisconnectNamedPipe(_hPintoolPipe);
// attente de la fermeture de l'application
WaitForSingleObject(pi.hProcess, INFINITE);
// recupération du code de retour du pintool
// (NON ENCORE IMPLEMENTE)
DWORD exitCode = 0;
GetExitCodeProcess(pi.hProcess, &exitCode);
// fermeture des handles processus et thread
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
// si option 'keepfiles' ou 'traceonly': sauvegarde de la formule (extension .smt2)
if (_keepFiles || _traceOnly)
{
std::ofstream ofs(_pCurrentInput->getLogFile());
// entete (version pin Z3 etc) et nom de l'entrée
ofs << infoHeader << '\n';
ofs << "; Fichier instrumenté : ";
ofs << _pCurrentInput->getFileName();
// ajout de l'arbre généalogique (si objet non-root et mode verbeux)
CInput *pFather = _pCurrentInput->getFather();
if (_verbose && pFather)
{
ofs << '(';
do // boucle récursive de déclaration des parents de chaque fichier
{
ofs << " <- " << pFather->getFileName();
pFather = pFather->getFather();
//.........这里部分代码省略.........
示例5: WinMain
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow )
{
CoInitialize(NULL);
Mycapp.Initilize(hInstance,TEXT("MY"),WndProc);
hwnd = Mycapp.GetHWND();
ghInstance = hInstance;
w.Initialize(Mycapp);
CInput cinput;
cinput.Initialize(hInstance,Mycapp.GetHWND());
pcinput = &cinput;
RECT _rect ={0,0,640,480};
PlaySound(TEXT("melody of life.wav"),hInstance,SND_LOOP|SND_FILENAME|SND_ASYNC );
LeadReader r;
Attribute attr = r.GetAttr();
CLead lead(&w,attr);
lead.Initialize();
CWeaponReader cwR;
CSceneReader cr;
vector<WeaponInfo> vecWeapon = cwR.GetWeapons();
CWeapons Weapon(&w);
Weapon.SetVec(vecWeapon);
psmanger.SetWeapon(&Weapon);
psmanger.SetDraw(&w);
psmanger.SetOverImage(TEXT("gameover.bmp"));
CSceneInit csi;
CScene* pscene = csi.InitScene("4096",&lead,&w,pcinput);
CScene* pscene2 = csi.InitScene("4097",&lead,&w,pcinput);
CScene* pscene3 = csi.InitScene("4098",&lead,&w,pcinput);
CScene* pscene4 = csi.InitScene("4099",&lead,&w,pcinput);
CScene* pscene5 = csi.InitScene("4100",&lead,&w,pcinput);
CPathReader cpr;
psmanger.SetPaths(cpr.GetPaths());
psmanger.RegisterScene(pscene);
psmanger.RegisterScene(pscene2);
psmanger.RegisterScene(pscene3);
psmanger.RegisterScene(pscene4);
psmanger.RegisterScene(pscene5);
CSceneReader sr;
SceneDesc scenedesc = sr.GetDesc("4097");
scenedesc.lpImage = NULL;
scenedesc.pCDraw = &w;
scenedesc.pcInput = &cinput;
scenedesc.lpwFileName = TEXT("4.bmp");
scenedesc.bIsFightable = true;
CMyMenu menuRectVictory(TEXT("6.bmp"),pcinput,&w,250,400);
CMyMenu menuSelect(TEXT("6.bmp"),pcinput,&w,250,200);
menuSelect.Initialize();
menuSelect.AddItem(TEXT("Attack!"));
menuSelect.AddItem(TEXT("使用药水:10个"));
CMyMenu menuStatus(TEXT("6.bmp"),pcinput,&w,250,200);
menuStatus.Initialize();
menuStatus.AddItem(TEXT("主 角 H P:"));
menuStatus.AddItem(TEXT("主角攻击力:"));
menuStatus.AddItem(TEXT("主角防御力:"));
menuRectVictory.Initialize();
CFightScene csceneFight(scenedesc,&menuRectVictory,&menuSelect,TEXT("bomb.bmp"),&menuStatus);
CMyMenu menuSelectBuy(TEXT("6.bmp"),pcinput,&w,250,400);
menuSelectBuy.Initialize();
cwR.FillItems( vecWeapon,menuSelectBuy);
CSellScene css(scenedesc,&menuSelectBuy);
css.Initialize();
css.SetWeapons(&Weapon);
css.RegisterLead(&lead);
psmanger.SetSellScene(&css);
csceneFight.Initialize();
psmanger.SetFightScene(&csceneFight);
#ifndef WINDOW_DEBUG
psmanger.Draw();
#else
psmanger.Draw(Mycapp.GetHWND());
#endif
MSG msg;
msg.message = WM_NULL;
for(;;)
{ if(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(msg.message == WM_QUIT) break;
else
//.........这里部分代码省略.........
示例6: Input
bool WinState::Input(CInput& _input )
{
_input.ReadMouse();
_input.ReadKeyboard();
static bool ifPressedD_WIN = false;
static bool ifPressedU_WIN = false;
static bool ifPressedEnter_WIN = false;
// Updates the reticle location based on the mouse pos.
m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f);
m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f);
m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight());
//Mouse Active over keybard
if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY)
{
m_bMouseActive = false;
}
if(_input.GetMousePosX() != m_PrevMousePosX)
{
m_bMouseActive = true;
m_PrevMousePosX = _input.GetMousePosX();
}
if(_input.GetMousePosY() != m_PrevMousePosY)
{
m_bMouseActive = true;
m_PrevMousePosY = _input.GetMousePosY();
}
static bool ifPressedEsc_WIN = false;
if(!ifPressedEsc_WIN)
{
ifPressedEsc_WIN = true;
if(_input.KeyDown(DIK_ESCAPE))
{
m_bFadeOut = true;
if (m_bEsc)
{
m_bEsc = false;
}
if (m_bSoundCheck)
{
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);
m_bSoundCheck = false;
}
return true;
}
}
else
ifPressedEsc_WIN = false;
//MOUSE INPUT FOR SELECTING BUTTONS----------------------------------------------------------------------
#pragma region Mouse Input for Selecting Buttons
int _mouseX = _input.GetMousePosX();
int _mouseY = _input.GetMousePosY();
//MAIN MENU BUTTON
//float _mainWidth1 = m_WinElements[WIN_MAIN_ELEMENT].GetRect().GetWidth(); //256
//float _mainHeight1 = m_WinElements[WIN_MAIN_ELEMENT].GetRect().GetHeight(); //64
//float _mainPosX1 = m_WinElements[WIN_MAIN_ELEMENT].GetPosX(); //280
//float _mainPosY1 = m_WinElements[WIN_MAIN_ELEMENT].GetPosY(); //612
//float _mainCombinedX1 = _mainPosX1 + _mainWidth1; //536
//float _mainCombinedY1 = _mainPosY1 + _mainHeight1; //676
//if (_mouseX >= _mainPosX1 && _mouseX <= _mainCombinedX1 && _mouseY <= _mainCombinedY1 && _mouseY >= _mainPosY1)
//{
// if (m_FadeTimer <= 1.0f && !m_bFadeOut) //Fadded in, set to 0, and not FadeOut.
// {
// if (m_bMouseActive)
// {
// m_Choice = W_MAIN_MENU;
// if (m_bSoundMain)
// {
// // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER);
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER);
// m_bSoundMain = false;
// m_bSoundCredits = true;
// }
// }
// if (m_Timer > 0.5f)
// {
// if (_input.IsLeftClicked())
// {
// // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);
// m_bFadeOut = true;
// }
// /*ProcessStates((eWinChoices)m_Choice);*/
// }
// }
//}
//CREDITS BUTTON
float _creditsWidth1 = m_WinElements[WIN_CREDITS_ELEMENT].GetRect().GetWidth(); //256
//.........这里部分代码省略.........
示例7: Input
bool CDifficultyMenu::Input( CInput& _input )
{
_input.ReadMouse();
_input.ReadKeyboard();
static bool ifPressedDown = false;
static bool ifPressedUp = false;
static bool ifPressedEnter1 = false;
static bool ifPressedEnter2 = false;
//static bool ifPressedEsc = false;
// Updates the reticle location based on the mouse pos.
m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f);
m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f);
m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight());
if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY)
m_MouseActive = true;
if(_input.GetMousePosX() != m_PrevMousePosX || _input.GetMousePosY() != m_PrevMousePosY)
{
m_MouseActive = true;
m_PrevMousePosX = _input.GetMousePosX();
m_PrevMousePosY = _input.GetMousePosY();
}
//Esc (EXIT THE PROGRAM)
static bool ifPressedEsc_Cred = false;
if(!ifPressedEsc_Cred)
{
if(_input.KeyDown(DIK_ESCAPE))
{
m_Choice = CHOICE_BACK;
m_FadeOut = true;
ifPressedEsc_Cred = true;
return true;
}
}
else
ifPressedEsc_Cred = false;
#pragma region Keyboard inputs
if(_input.KeyDown(DIK_S) || _input.KeyDown(DIK_DOWN) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN )
{
if(m_FadeTimer <= 1.0f && !m_FadeOut)
{
if(!ifPressedDown)
{
m_Choice++;
if(m_Choice == CHOICE_TOTAL)
{
m_Choice = CHOICE_EASY;
}
ifPressedDown = true;
}
}
}
else
ifPressedDown = false;
if(_input.KeyDown(DIK_W) || _input.KeyDown(DIK_UP) || _input.GetController().GetControllerState().Gamepad.sThumbLY > 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP)
{
if(m_FadeTimer <= 1.0f && !m_FadeOut)
{
if(!ifPressedUp)
{
m_Choice--;
if(m_Choice < 0)
{
m_Choice = CHOICE_BACK;
}
ifPressedUp = true;
}
}
}
else
ifPressedUp = false;
#pragma endregion
switch(m_Choice)
{
case CHOICE_EASY:
{
if(m_SoundEasy)
{
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER);
AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER);
m_SoundEasy = false;
m_SoundNormal = true;
m_SoundHard = true;
m_SoundBack = true;
m_isHighlighted = true;
}
}
break;
case CHOICE_NORMAL:
{
if(m_SoundNormal)
{
//.........这里部分代码省略.........
示例8: InitKeyboardMouseListening
void CController::InitKeyboardMouseListening()
{
//Input模块会自动把信息发送到Controller的单例来,因此这样就好了
CInput input;
input.InitListener();
}
示例9: Input
bool CPauseState::Input( CInput& _input )
{
static bool ifPressedD = false;
static bool ifPressedU = false;
static bool ifPressedEnter_Paused = false;
// Updates the reticle location based on the mouse pos.
m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f);
m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f);
m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight());
//Mouse Active over keybard
if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY)
{
m_bMouseActive = false;
}
if(_input.GetMousePosX() != m_PrevMousePosX)
{
m_bMouseActive = true;
m_PrevMousePosX = _input.GetMousePosX();
}
if(_input.GetMousePosY() != m_PrevMousePosY)
{
m_bMouseActive = true;
m_PrevMousePosY = _input.GetMousePosY();
}
if (m_Timer > 0.5f)
{
static bool ifPressEsc = true;
if(_input.IsEscapePressed() )
{
if(!ifPressEsc)
{
m_bFadeOut = true;
m_Esc = true;
m_Choice = P_PLAY;
ifPressEsc = true;
/// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUUNPAUSE);
}
}
else
ifPressEsc = false;
}
if (m_bFadeOut && m_FadeTimer >= 1.0f )
{
switch(m_Choice)
{
case P_PLAY:
{
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUUNPAUSE);
m_Game->GetStateManager()->PopState();
return true;
}
break;
case P_OPTIONS:
{
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);
m_Game->GetStateManager()->PushState(OPTIONS_STATE);
return true;
}
break;
case P_EXIT:
{
// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT);
AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT);
m_Game->GetStateManager()->ChangeState(MAINMENU_STATE);
return true;
}
break;
};
}
//KEYBOARD INPUT FOR SELECTING BUTTONS----------------------------------------------------------------------
#pragma region Keyboard Input for Selecting Buttons
if((_input.KeyDown(DIK_S) || _input.KeyDown(DIK_DOWN) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 ||
_input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) && !m_bFadeOut )
{
if(!ifPressedD)
{
m_Choice++;
//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosX((m_Game->GetScreenWidth() / 2.0f) - 150);
//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(m_Choice * 128.0f + 128.0f);
//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry();
if(m_Choice == PAUSE_NUM_CHOICES)
{
m_Choice = P_PLAY;
//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY((m_Game->GetScreenHeight() / 2.0f) - 160);
//m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry();
}
ifPressedD = true;
//.........这里部分代码省略.........
示例10: PrintHeader
bool CInputs::ConfigureInputs(const GameInfo *game)
{
m_system->UngrabMouse();
// Print header and help message
int gameFlags;
if (game != NULL)
{
PrintHeader("Configure Inputs for %s", game->title);
gameFlags = game->inputFlags;
}
else
{
PrintHeader("Configure Inputs");
gameFlags = GAME_INPUT_ALL;
}
PrintConfigureInputsHelp();
// Get all inputs to be configured
vector<CInput*> toConfigure;
vector<CInput*>::iterator it;
for (it = m_inputs.begin(); it != m_inputs.end(); it++)
{
if ((*it)->IsConfigurable() && ((*it)->gameFlags & gameFlags))
toConfigure.push_back(*it);
}
// Remember current mappings for each input in case changes need to be undone later
vector<string> oldMappings(toConfigure.size());
size_t index = 0;
for (it = toConfigure.begin(); it != toConfigure.end(); it++)
oldMappings[index++] = (*it)->GetMapping();
const char *groupLabel = NULL;
bool cancelled = false;
// Loop through all the inputs to be configured
index = 0;
while (index < toConfigure.size())
{
// Get the current input
CInput *input = toConfigure[index];
// If have moved to a new input group, print the group heading
const char *itGroupLabel = input->GetInputGroup();
if (groupLabel == NULL || stricmp(groupLabel, itGroupLabel) != 0)
{
groupLabel = itGroupLabel;
printf("%s:\n", groupLabel);
}
Redisplay:
// Print the input label, current input mapping and available options
if (index > 0)
printf(" %s [%s]: Ret/c/s/a/r/Up/Down/b/h/q/Esc? ", input->label, input->GetMapping());
else
printf(" %s [%s]: Ret/c/s/a/r/Down/h/b/q/Esc? ", input->label, input->GetMapping());
fflush(stdout); // required on terminals that use buffering
// Loop until user has selected a valid option
bool done = false;
char mapping[50];
while (!done)
{
// Wait for input from user
if (!m_system->ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, uiExit->GetMapping()))
{
// If user pressed aborted input, then undo all changes and finish configuration
index = 0;
for (it = toConfigure.begin(); it != toConfigure.end(); it++)
{
(*it)->SetMapping(oldMappings[index].c_str());
index++;
}
cancelled = true;
goto Finish;
}
if (stricmp(mapping, "KEY_RETURN") == 0 || stricmp(mapping, "KEY_S") == 0)
{
// Set the input mapping
printf("Setting... ");
fflush(stdout); // required on terminals that use buffering
if (input->Configure(false, uiExit->GetMapping()))
{
puts(input->GetMapping());
if (stricmp(mapping, "KEY_RETURN") == 0)
index++;
done = true;
}
else
{
puts("[Cancelled]");
goto Redisplay;
}
}
else if (stricmp(mapping, "KEY_A") == 0)
{
//.........这里部分代码省略.........
示例11: HandleSingleTouchButtonCB
//
// HandleSingleTouchButtonCB - The system will call this callback when the user touches the screen
//
void HandleSingleTouchButtonCB(s3ePointerEvent* event)
{
CTouch* touch = g_Input.getTouch(0);
touch->active = event->m_Pressed != 0;
touch->x = event->m_x;
touch->y = event->m_y;
}
示例12: main
int main()
{
// Initialize our data
Init();
// Below we do our basic game loop. This is what control the game primarily.
// We only want the game to keep going as long as the character is alive. Of
// course, in this tutorial the character can't die, but we set this up for later.
// In the game loop we always check for input every frame, then we draw the map.
// We don't draw the map every frame, but inside the Draw() function there is
// a check to see if the draw flag is set. That is why we use the SetDrawFlag()
// function to tell the map to draw. If we don't set that each frame, the map
// will not draw, even though we call the Draw() flag.
// Keep the game going while the player is alive
while(g_Player.IsAlive())
{
// If the user did some input, let's check it and handle it
if(g_Input.CheckInput())
HandleGameInput();
// Let's draw the map when we need to draw (if the draw flag = true).
g_Map.Draw();
}
// Return a success with no problems
return 1;
}
示例13: HandleMultiTouchMotionCB
//
// HandleMultiTouchMotionCB - For multitouch devices the system will call this callback when the user moves their finger on the screen. This callback is called once for each screen touch
//
void HandleMultiTouchMotionCB(s3ePointerTouchMotionEvent* event)
{
// Check to see if the touch already exists
CTouch* touch = g_Input.findTouch(event->m_TouchID);
if (touch != NULL)
{
// Updates the touches positional information
touch->x = event->m_x;
touch->y = event->m_y;
}
}
示例14: HandleMultiTouchButtonCB
//
//
// Input callback handlers
//
//
//
// HandleMultiTouchButtonCB - For multitouch devices the system will call this callback when the user touches the screen. This callback is called once for each screen touch
//
void HandleMultiTouchButtonCB(s3ePointerTouchEvent* event)
{
// Check to see if the touch already exists
CTouch* touch = g_Input.findTouch(event->m_TouchID);
if (touch != NULL)
{
// Yes it does, so update the touch information
touch->active = event->m_Pressed != 0;
touch->x = event->m_x;
touch->y = event->m_y;
}
}
示例15: HandleGameInput
void HandleGameInput()
{
// Store the position of the player before we possibly move
POINT lastPosition = g_Player.GetLastPosition();
if(g_Input.IsKeyDown(VK_ESCAPE)) // If escape was pressed
g_Menu.BringUpMenu(); // Bring up the main menu
else if(g_Input.IsKeyDown(VK_UP)) // If up arrow key was pressed
g_Player.Move(kUp); // Move the character up
else if(g_Input.IsKeyDown(VK_DOWN)) // If down arrow key was pressed
g_Player.Move(kDown); // Move the character down
else if(g_Input.IsKeyDown(VK_LEFT)) // If left arrow key was pressed
g_Player.Move(kLeft); // Move the character left
else if(g_Input.IsKeyDown(VK_RIGHT)) // If right arrow key was pressed
g_Player.Move(kRight); // Move the character right
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
// If we hit space let's toggle on and off the stats at the botton of the screen
else if(g_Input.IsKeyDown(VK_SPACE))
g_Map.ToggleStatsFlag();
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
// Store the new current position of the player
POINT curPosition = g_Player.GetPosition();
// Check if the player moved by testing the current position against the last position
if(lastPosition.x != curPosition.x || lastPosition.y != curPosition.y)
{
// We want to draw the screen again if the character moved
g_Map.SetDrawFlag(true);
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
// Since we need to pick up items, we need to check for them just like exits, etc.
g_Map.CheckForItem(curPosition.x, curPosition.y);
//////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** ////////////////////
// If we run into an NPC, we need to know so we can display dialog
g_Map.CheckForNpc(curPosition.x, curPosition.y);
// Set the previous position of the player
g_Player.SetLastPosition(curPosition);
// Here we check to see if the player moved into an exit. If so, exit!
g_Map.CheckForExit(curPosition.x, curPosition.y);
}
}