本文整理汇总了C++中sf::View::getRotation方法的典型用法代码示例。如果您正苦于以下问题:C++ View::getRotation方法的具体用法?C++ View::getRotation怎么用?C++ View::getRotation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::View
的用法示例。
在下文中一共展示了View::getRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
int render(Phys* phys)
{
window->clear(sf::Color::Black);
sf::Vector2f viewmove(0, 0);
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) viewmove.x -= base_camera_move;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) viewmove.x += base_camera_move;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)) viewmove.y += base_camera_move;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)) viewmove.y -= base_camera_move;
viewmove *= (phys->dt * view->getSize().x / scrw);
viewmove = sv2rotate(viewmove, -view->getRotation());
view->move(viewmove);
view->zoom(pow(1.2, -mouse_wheel));
mouse_wheel = 0;
float viewrotate = 0;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::LBracket)) viewrotate += base_camera_rotate;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::RBracket)) viewrotate -= base_camera_rotate;
viewrotate *= phys->dt;
view->rotate(viewrotate);
window->setView(*view);
for (std::vector<Ship*>::iterator its = phys->ship_list.begin(); its != phys->ship_list.end(); ++its)
{
sf::ConvexShape& shape = (*its)->shape;
cpVect pos = cpBodyGetPosition((*its)->body);
cpFloat angle = cpBodyGetAngle((*its)->body);
shape.setPosition(pos.x, pos.y);
shape.setRotation(180 / PI * angle);
window->draw(shape);
}
for (std::vector<Shell*>::iterator its = phys->shell_list.begin(); its != phys->shell_list.end(); ++its)
{
sf::ConvexShape& shape = (*its)->shape;
cpVect pos = cpBodyGetPosition((*its)->body);
cpFloat angle = cpBodyGetAngle((*its)->body);
shape.setPosition(pos.x, pos.y);
shape.setRotation(180 / PI * angle);
window->draw(shape);
}
char* str = new char[30];
float acc = 0;
for (int i = 0; i < frame_time_count; i++) acc += phys->last_frame_deltas[i];
acc /= frame_time_count;
sprintf(str, "%.1f", 1./acc);
drawtext(str, 0.02, 0.98, 10);
int sc = (*phys->ship_list.begin())->score;
sprintf(str, "%d", sc);
drawtext(str, 0.98, 0.98, 10);
delete str;
window->display();
return 0;
}