diff --git a/src/main.cpp b/src/main.cpp index e1aec12..f75b2d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,15 @@ #include +#include +#include int main() { - auto window = sf::RenderWindow(sf::VideoMode({1920u, 1080u}), "CMake SFML Project"); + auto window = sf::RenderWindow(sf::VideoMode({1920u, 1080u}), "Pacmen"); window.setFramerateLimit(144); + sf::CircleShape pacman(25.0f); + pacman.setFillColor(sf::Color(255, 255, 0)); + while (window.isOpen()) { while (const std::optional event = window.pollEvent()) @@ -16,6 +21,25 @@ int main() } window.clear(); + + window.draw(pacman); + + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) { + pacman.move({0, -5.0f}); + } + + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) { + pacman.move({-5.0f, 0}); + } + + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S)) { + pacman.move({0, 5.0f}); + } + + if (sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D)) { + pacman.move({5.0f, 0}); + } + window.display(); } }