本文整理汇总了C++中Cone::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Cone::Update方法的具体用法?C++ Cone::Update怎么用?C++ Cone::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cone
的用法示例。
在下文中一共展示了Cone::Update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main()
{
std::srand(static_cast<unsigned int>(std::time(NULL)));
// Define some constants
const int gameWidth = 800;
const int gameHeight = 600;
const int runSpeed = 200;
const int gravity = 200;
sf::Sprite backgroundSprite;
sf::Texture backgroundTexture;
backgroundTexture.loadFromFile("background.png");
backgroundSprite.setTexture(backgroundTexture);
// Create the window of the application
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "Zooki");
window.setVerticalSyncEnabled(true);
// Create items
Zooki zooki;
Igloo igloo;
Cone cone;
TitleScreen titleScreen;
titleScreen.setText();
//HardCode Level. Will be replaced with loading a level////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Loading ice texture
sf::Texture iceTexture;
iceTexture.loadFromFile("ice.jpg");
// Creating a vector because we have more blocks and we will need them into a container
std::vector<sf::Sprite> ice;
// Add ice blocks to the container
ice.resize(8);
for (std::size_t i = 0; i<7; ++i)
{
ice[i].setTexture(iceTexture);
ice[i].setPosition(128 * i, 450);
}
// Last ice block will bo above the first one
ice[7].setTexture(iceTexture);
ice[7].setPosition(0, 350);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Define the paddles properties
sf::Clock AITimer;
const sf::Time AITime = sf::seconds(0.1f);
const float paddleSpeed = 400.f;
float rightPaddleSpeed = 0.f;
sf::Clock clock;
bool isPlaying = false;
while (window.isOpen())
{
// Handle events
sf::Event event;
while (window.pollEvent(event))
{
// Window closed or escape key pressed: exit
if ((event.type == sf::Event::Closed) ||
((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Escape)))
{
window.close();
break;
}
// Space key pressed: play
if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Space))
{
if (!isPlaying)
{
// (re)start the game
isPlaying = true;
clock.restart();
// Reset position of zooki
zooki.resetPos(22.5, 200);
zooki.Update();
zooki.has_cones = false;
zooki.onGround = false;
cone.collected = false;
}
}
}
//.........这里部分代码省略.........