add detailed sfml example

add simple wxWidgets example
This commit is contained in:
2025-02-26 12:59:43 +01:00
parent 803701d6ef
commit 9e336c5677
7 changed files with 238 additions and 2 deletions
+36 -2
View File
@@ -1,13 +1,47 @@
#include "SFML/Graphics.hpp"
//using namespace sf;
using namespace sf;
int main()
{
sf::RenderWindow window(sf::VideoMode({ 640, 480 }), "Hello World Example");
RenderWindow window(VideoMode({ 640, 480 }), "Hello World Example");
CircleShape circle(100.0f);
circle.setFillColor(Color(200, 0, 0));
Texture texture("assets/card_clubs_02.png");
Sprite sprite(texture);
while (window.isOpen())
{
while (const std::optional event = window.pollEvent())
{
if (event->is<Event::Closed>())
{
window.close();
}
//else if (event->is<Event::KeyPressed>()) {
else if (const Event::KeyPressed* keyPressed = event->getIf<Event::KeyPressed>())
{
if (keyPressed->scancode == Keyboard::Scancode::Escape)
{
window.close();
}
}
}
// move circle
//circle.setPosition(circle.getPosition() + Vector2f(1, 0));
if (Keyboard::isKeyPressed(Keyboard::Scancode::Right))
{
circle.setPosition(circle.getPosition() + Vector2f(1, 0));
}
// clear window to start each frame from scratch
window.clear();
window.draw(circle);
window.draw(sprite);
window.display();
}