本文整理汇总了C++中Input::KeyUp方法的典型用法代码示例。如果您正苦于以下问题:C++ Input::KeyUp方法的具体用法?C++ Input::KeyUp怎么用?C++ Input::KeyUp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::KeyUp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv) {
SDL_Init(SDL_INIT_EVERYTHING);
SDL_Window* window = nullptr;
SDL_Renderer* gRenderer = NULL;
window = SDL_CreateWindow("Hi", 50, 50, 1000, 500, SDL_WINDOW_SHOWN);
gRenderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
Uint32 tick;
bool pauseReset = true;
bool running = true;
float frame = 0.0f;
//Initialize renderer color
SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
//Initialize PNG loading
int imgFlags = IMG_INIT_PNG;
if (!(IMG_Init(imgFlags) & imgFlags))
{
printf("SDL_image could not initialize! SDL_image Error: %s\n", IMG_GetError());
}
Game game;
Entity entity;
game.LoadMobList(gRenderer);
game.LoadPlayerAnims(gRenderer, &entity);
game.InitSpawnManager();
//IDENFITY A MOB
//Entity mush = *game.IdentifyMob("mush");
Input PlayerInput;
GameMap map;
SDL_Rect mapPos;
mapPos.w = 1387;
mapPos.h = 907;
mapPos.x = 0;
mapPos.y = -407;
map.InitMap("content\\maps\\hennesys\\map01.png", mapPos, gRenderer);
entity.SetPositionY(190);
while (running) {
tick = SDL_GetTicks();
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
break;
case SDL_KEYDOWN:
PlayerInput.KeyDown(event.key.keysym.scancode);
break;
case SDL_KEYUP:
PlayerInput.KeyUp(event.key.keysym.scancode);
break;
}
}
//Clear screen
SDL_RenderClear(gRenderer);
if (PlayerInput.IsKeyPressed(SDL_SCANCODE_LEFT)) {
entity.Walk(Left);
}
else if (PlayerInput.IsKeyPressed(SDL_SCANCODE_RIGHT)) {
entity.Walk(Right);
}
else {
entity.Station();
}
map.DrawMap(mapPos);
entity.Draw();
game.ManageMobPool();
//Update screen
SDL_RenderPresent(gRenderer);
//SpawnManager
game.spawn_manager.ManagePool(tick);
//LIMIT FPS
frame += 0.1f;
unsigned int fps = 60;
if ((1000 / fps) > SDL_GetTicks() - tick) {
SDL_Delay(1000 / fps - (SDL_GetTicks() - tick));
}
}
SDL_DestroyWindow(window);
return 1;
//.........这里部分代码省略.........