本文整理汇总了C++中Level::Render方法的典型用法代码示例。如果您正苦于以下问题:C++ Level::Render方法的具体用法?C++ Level::Render怎么用?C++ Level::Render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level::Render方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
srand(time(0));
sf::ContextSettings settings;
settings.antialiasingLevel = 8;
// create the window
sf::RenderWindow window(sf::VideoMode(928, 448), "Labshooter", sf::Style::Default, settings);
sf::Clock clock;
sf::Texture playerTexture;
playerTexture.loadFromFile("assets/player.png");
sf::Texture tileTexture;
tileTexture.loadFromFile("assets/tile.png");
sf::Sprite playerSprite;
playerSprite.setTexture(playerTexture);
sf::Sprite tileSprite;
tileSprite.setTexture(tileTexture);
SoundManager::LoadSound("shoot", "assets/shoot.wav");
SoundManager::LoadSound("shoot2", "assets/shoot2.wav");
SoundManager::LoadSound("hurt", "assets/hurt.wav");
level.LoadLevel("assets/level1");
// run the program as long as the window is open
while (window.isOpen())
{
sf::Time elapsed = clock.restart();
// check all the window's events that were triggered since the last iteration of the loop
sf::Event event;
while (window.pollEvent(event))
{
// "close requested" event: we close the window
if (event.type == sf::Event::Closed)
window.close();
}
level.Update(elapsed.asMilliseconds());
/*if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
move(0.5 * elapsed.asMilliseconds(), 0, playerSprite, tileSprite);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
move(-0.5 * elapsed.asMilliseconds(), 0, playerSprite, tileSprite);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
move(0, -0.5 * elapsed.asMilliseconds(), playerSprite, tileSprite);
}
if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
move(0, 0.5 * elapsed.asMilliseconds(), playerSprite, tileSprite);
}*/
tileSprite.setPosition(50, 50);
// clear the window with black color
window.clear(sf::Color::White);
// draw everything here...
//window.draw(playerSprite);
//window.draw(tileSprite);
level.Render(&window);
// end the current frame
window.display();
}
return 0;
}
示例2: mainloop
int mainloop(SDL_Surface* screen)
{
Level tmp;
SDL_Event event;
int x = 0, y = 0;
int xscroll = 0, yscroll = 0;
if (tmp.FromFile("herpaderp.lvl"))
{
fprintf(stderr, "%s: error: file \"herpaderp.lvl\" doesn't exist\n", PROGNAME);
return 1;
}
tmp.Render(screen, x, y);
SDL_UpdateRect(screen, 0,0,0,0);
while (1)
{
x += xscroll;
y += yscroll;
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 0, 0, 0));
tmp.Render(screen, x, y);
SDL_UpdateRect(screen, 0,0,0,0);
if (SDL_PollEvent(&event))
{
switch (event.type)
{
case SDL_QUIT:
return 1;
break;
}
// This will be massively cleaned up later
if (event.type == SDL_KEYDOWN || event.type == SDL_KEYUP)
{
SDLKey key = event.key.keysym.sym;
if (event.type == SDL_KEYDOWN)
{
switch (key)
{
case SDLK_ESCAPE: return 1;
case SDLK_LEFT: xscroll--; break;
case SDLK_RIGHT: xscroll++; break;
case SDLK_UP: yscroll--; break;
case SDLK_DOWN: yscroll++; break;
default: break;
}
}
else // must be KEYUP
{
switch (key)
{
case SDLK_LEFT: xscroll++; break;
case SDLK_RIGHT: xscroll--; break;
case SDLK_UP: yscroll++; break;
case SDLK_DOWN: yscroll--; break;
default: break;
}
}
}
}
SDL_Delay(1);
}
return 0;
}