#include #include #include #include #include std::mt19937 rng(time(0)); const int n=30; class Entity { public: float x,y; sf::RectangleShape telo; Entity() {} Entity(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja); }; Entity::Entity(sf::Vector2f pozicija, sf::Vector2f velicina,sf::Color boja) { telo.setSize(velicina); telo.setFillColor(boja); telo.setOrigin(sf::Vector2f(telo.getSize().x/2,telo.getSize().y/2)); x=pozicija.x; y=pozicija.y; } class Enemy:public Entity { public: Enemy():Entity() {} Enemy(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja):Entity(pozicija,velicina,boja) {} }; class Player:public Entity { int health; public: Player():Entity() {} Player(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja):Entity(pozicija,velicina,boja) { health=100; } }; class Game { Player igrac; Enemy neprijatelj[n]; sf::RenderWindow prozor; int visina,sirina; public: Game(); void loop(); void events(); void keyboard(); void run(); void draw(); }; Game::Game() { prozor.create(sf::VideoMode(512,512),"RPG igra"); visina=prozor.getSize().y; sirina=prozor.getSize().x; prozor.setFramerateLimit(60); igrac = Player(sf::Vector2f((float)sirina/2,(float)visina/2),sf::Vector2f(100.0f,100.0f),sf::Color::White); for(int i=0;i0) igrac.y-=dist; if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)&&igrac.x>0) igrac.x-=dist; if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)&&igrac.y