本文整理汇总了C++中Tilemap::update方法的典型用法代码示例。如果您正苦于以下问题:C++ Tilemap::update方法的具体用法?C++ Tilemap::update怎么用?C++ Tilemap::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tilemap
的用法示例。
在下文中一共展示了Tilemap::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int App::main(const std::vector<std::string>& args)
{
clan::DisplayWindowDescription desc;
desc.set_position(clan::Rect(-800, 100, clan::Size(800, 600)), false);
desc.set_title("ClanLib 2D Dijkstra Test");
desc.set_allow_resize(false);
clan::DisplayWindow win(desc);
clan::Canvas canvas(win);
m_canvas = canvas;
Tilemap map;
map.build_map(31);
clan::GameTime game_time;
while(!win.get_ic().get_keyboard().get_keycode(clan::keycode_escape))
{
game_time.update();
canvas.clear();
map.draw(canvas);
map.update(win.get_ic(), game_time.get_time_elapsed());
win.flip();
clan::KeepAlive::process();
}
map.reset();
return 0;
}
示例2: 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;
}
//.........这里部分代码省略.........