add detailed sfml example
add simple wxWidgets example
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 190 B |
+36
-2
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user