window
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#include <SFML/Audio.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
int main() {
|
||||
// sf::RenderWindow window(sf::VideoMode({600, 400}), "SFML window");
|
||||
sf::RenderWindow window(sf::VideoMode({600, 400}), "SFML window");
|
||||
// window.setVerticalSyncEnabled(true);
|
||||
window.setFramerateLimit(60);
|
||||
|
||||
|
||||
// Load a sprite to display
|
||||
// const sf::Texture texture("original.jpeg");
|
||||
// sf::Sprite sprite(texture);
|
||||
|
||||
// Create a graphical text to display
|
||||
// const sf::Font font("MapleMono-Regular.ttf");
|
||||
// sf::Text text(font, "Hello SFML", 50);
|
||||
|
||||
// Load a music to play
|
||||
sf::RectangleShape player({40, 40});
|
||||
player.setFillColor(sf::Color::Black);
|
||||
player.setOutlineThickness(2);
|
||||
player.setOutlineColor(sf::Color::White);
|
||||
player.setPosition({40, 40});
|
||||
|
||||
// Start the game loop
|
||||
while (window.isOpen()) {
|
||||
// Process events
|
||||
while (const std::optional event = window.pollEvent())
|
||||
{
|
||||
// Close window: exit
|
||||
if (event->is<sf::Event::Closed>())
|
||||
window.close();
|
||||
}
|
||||
|
||||
// Clear screen
|
||||
// window.clear();
|
||||
|
||||
// Draw the sprite
|
||||
window.clear(sf::Color::Black);
|
||||
window.draw(player);
|
||||
window.display();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user