[ create a new paste ] login | about

Link: http://codepad.org/5E9WkDMx    [ raw code | output | fork ]

C++, pasted on Mar 17:
class Shoot{
	public:
		
		Shoot(sf::Vector2f size) {
			shoot.setSize(size);
			shoot.setFillColor(sf::Color::Red);
		}
		
		void fire(float speed) {
			shoot.move(speed , 0);
		}
		int getRight() {
			return shoot.getPosition().x + shoot.getSize().x;
		}
		int getLeft() {
			return shoot.getPosition().x ;
		}
		int getTop() {
			return shoot.getPosition().y;

		}
		int getBottom() {
			return shoot.getPosition().y + shoot.getSize().y;
		}
		void draw(sf::RenderWindow &window) {
			window.draw(shoot);
		}
		void setPos(sf::Vector2f newPos) {
			shoot.setPosition(newPos);
		}
		void rotate(float angle)
		{
			shoot.setRotation(angle);
		}
		
private:
	sf::RectangleShape shoot;
};

//shooting
	
	if (isFiring == true) {
		Shoot newShoot(sf::Vector2f(20, 5));
		newShoot.setPos(sf::Vector2f(circle.getPosition().x, circle.getPosition().y));
		newShoot.rotate(90 + atan2f((mousePosition.y - circle.getPosition().y ), (mousePosition.x - circle.getPosition().x )) * 180 / Pi);
		shootVect.push_back(newShoot);
		isFiring = false;
	}
	for (int i = 0; i < shootVect.size(); i++) {
		shootVect[i].draw(window);
		shootVect[i].fire(speed);
	}


Output:
1
2
Line 4: error: 'sf' has not been declared
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: