本文整理汇总了C++中Tilemap::loadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ Tilemap::loadFile方法的具体用法?C++ Tilemap::loadFile怎么用?C++ Tilemap::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tilemap
的用法示例。
在下文中一共展示了Tilemap::loadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
init();
Spritesheet levelSprites("testpic.png", 32, &mainWindow);
gameMap.sprites = &levelSprites;
gameMap.loadFile("testmap.map");
gameMap.update(&mainWindow);
Character Player;
Player.position.x = 100;
Player.position.y = SCREEN_HEIGHT - 90;
Player.gravity = 5000.0;
Player.runSpeed = 500.0;
Player.jumpVelocity = 800.0;
Player.jumpHeightMax = 128.0;
Player.terminalVelocity = 1024.0;
Player.rect.w = 32;
Player.rect.h = 64;
Player.rect.x = int(Player.position.x);
Player.rect.y = int(Player.position.y);
Player.origin.x = (double)(Player.rect.w / 2);
Player.origin.y = (double)Player.rect.h;
const Uint8 *keystate = SDL_GetKeyboardState(NULL);
SDL_Event e;
bool quit = false;
double frameTime = 0.0;
system_clock::time_point lastTime = system_clock::now();
while (!quit)
{
frameTime = duration_cast<microseconds>(system_clock::now() - lastTime).count() / 1000000.0;
if (frameTime > 0.1) frameTime = 0.1; //at low framerates game becomes frame dependent to avoid collision errors etc.
lastTime = system_clock::now();
//event block
SDL_PumpEvents();
while (SDL_PollEvent(&e))
{
if (e.type == SDL_WINDOWEVENT)
{
mainWindow.handleEvents(&e);
}
if (e.type == SDL_QUIT)
{
quit = true;
}
if (e.type == SDL_KEYDOWN)
{
switch (e.key.keysym.sym)
{
case SDLK_a:
case SDLK_LEFT:
{
Player.velocity.x = -Player.runSpeed;
break;
}
case SDLK_d:
case SDLK_RIGHT:
{
Player.velocity.x = Player.runSpeed;
break;
}
default: break;
}
}
else if (e.type == SDL_KEYUP)
{
switch (e.key.keysym.sym)
{
case SDLK_a:
case SDLK_LEFT:
{
if (keystate[SDL_SCANCODE_RIGHT] || keystate[SDL_SCANCODE_D]) Player.velocity.x = Player.runSpeed;
else Player.velocity.x = 0.0;
break;
}
case SDLK_d:
case SDLK_RIGHT:
{
if (keystate[SDL_SCANCODE_LEFT] || keystate[SDL_SCANCODE_A]) Player.velocity.x = -Player.runSpeed;
else Player.velocity.x = 0.0;
break;
}
default: break;
}
}
}
if (!Player.freeFall && (keystate[SDL_SCANCODE_UP] || keystate[SDL_SCANCODE_W]))
{
Player.jump();
}
else if (Player.airBorne)
{
Player.freeFall = true;
}
//.........这里部分代码省略.........