Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <iostream>
- #include "Character.cpp"
- int main() {
- enum Direction { Down, Left, Up, Right };
- sf::Vector2i source(0, Down);
- sf::RenderWindow window(sf::VideoMode(800, 800), "Adventure game");
- window.setFramerateLimit(60);
- Character player = Character();
- while (window.isOpen())
- {
- sf::Event event;
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- window.close();
- }
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
- {
- source.y = Up;
- player.Move(source.y);
- }
- else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
- {
- source.y = Down;
- player.Move(source.y);
- }
- else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
- {
- source.y = Right;
- player.Move(source.y);
- }
- else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
- {
- source.y = Left;
- player.Move(source.y);
- }
- window.clear(sf::Color::White);
- window.draw(player.chSprite);
- window.display();
- }
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment