Jump to content
  • Advertisement

Mateusz Kin

Member
  • Content Count

    2
  • Joined

  • Last visited

Everything posted by Mateusz Kin

  1. In Zombienation (my project) class Bullet : public sf::RectangleShape { public: Bullet(float speed,sf::Vector2f direct,sf::Vector2f pos); bool update(float dt); double getDistance() { return distanceTraveled; } private: float speed; sf::Vector2f direction; double distanceTraveled; // if distance is to long then delete bullet from memory sf::Vector2f position, startingPosition; }; bool Weapon::shot(sf::Vector2f pos, sf::Vector2f direction) { if((roundsIn > 0) && canShot) { isShooting = true; for(unsigned int x = 0; x < bulletCont.size(); x++) { if(bulletCont[x] == nullptr) // when one is empty fill it with new bullet { bulletCont[x] = new Bullet(1600,direction,pos); canShot = false; // each weapon have different fire rate roundsIn--; return true; break; } } bulletCont.push_back(new Bullet(1600,direction,pos)); canShot = false; roundsIn--; } else { isShooting = false; // weapon is empty or have to wait for new bullet return false; } if(roundsIn == 0) { reloadingCall = true; } } where bulletCont is a vector of Bullet's pointers. Simple.   And direction void CCharacter::shot() { sf::Vector2f tempDirect(aim); // aim store where mouse is recoil(&tempDirect); if(actual->shot(pos,tempDirect)) // player tried too shot { crosshair->pushSize(1.1); } } void CCharacter::updateDirection() { direct.x = (aim.x-400); direct.y = (aim.y-300); double len = sqrtf(direct.x*direct.x+direct.y*direct.y); direct.x/=len; direct.y/=len; } If you want I could send you all files (cpp + hpp of those 3 classes)
  2. Mateusz Kin

    SFML - Is there a way to implement lights?

    As well you can create your own drawable class.   http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!