#include #include #include std::mt19937 rng(time(0)); const int n=20; 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: bool ziv=1; Enemy():Entity() {} Enemy(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja):Entity(pozicija,velicina,boja) {} void kaigracu(float igracx,float igracy); }; void Enemy::kaigracu(float igracx,float igracy) { float k=(igracy-y)/(igracx-x); float r=1.0; float dx=r/std::sqrt(1+k*k); if(igracx-x<0) dx=-dx; float dy=k*dx; x+=dx; y+=dy; } class Player:public Entity { public: int health,xp; int stomprad=300; float stomptime; Player():Entity() {} Player(sf::Vector2f pozicija,sf::Vector2f velicina,sf::Color boja):Entity(pozicija,velicina,boja) { health=100; xp=0; stomptime=0; } void stomp(Enemy neprijatelj[]); }; void Player::stomp(Enemy neprijatelj[]) { stomptime=3; 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.y2.8) prozor.draw(krug); prozor.draw(igrac.telo); for(int i=0;i0) igrac.stomptime-=0.01; igrac.telo.setPosition(igrac.x,igrac.y); for(int i=0;i