本文整理汇总了C++中Render::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Render::load方法的具体用法?C++ Render::load怎么用?C++ Render::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Render
的用法示例。
在下文中一共展示了Render::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
Render mapView;
short x = 1;
short y = 1;
View v;
sf::RenderWindow window(sf::VideoMode(160, 160), "Tilemap");
window.setVerticalSyncEnabled(true);
v.height = 5;
v.width = 5;
v.current = new char[v.height * v.width];
Map * worldMap = new Map(v);
worldMap -> getView(v.current, x - 2, y - 2);
mapView.load("tilemap.png", sf::Vector2u(32, 32), v.current, 5, 5);
short newX;
short newY;
while(window.isOpen())
{
newX = x;
newY = y;
sf::Event event;
while(window.pollEvent(event))
{
switch(event.type)
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::LostFocus:
//.pause();
break;
case sf::Event::GainedFocus:
//.resume();
break;
case sf::Event::KeyPressed:
worldMap -> setTile(' ', x, y);
switch(event.key.code)
{
case sf::Keyboard::Up:
newY--;
break;
case sf::Keyboard::Down:
newY++;
break;
case sf::Keyboard::Left:
newX--;
break;
case sf::Keyboard::Right:
newX++;
break;
default:
break;
}
if(worldMap -> spaceIsOpen(newX, newY))
{
x = newX;
y = newY;
worldMap -> setTile('c', newX, newY);
} else {
worldMap -> setTile('c', x, y);
}
worldMap -> getView(v.current, x - 2, y - 2);
mapView.load("tilemap.png", sf::Vector2u(32, 32), v.current, 5, 5);
break;
default:
break;
}
//.........这里部分代码省略.........