Guest User

Untitled

a guest
Oct 4th, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. //main.cpp
  2.     std::vector <bullet> bullets;
  3.    
  4.     bullets.push_back(bullet(true, 25.0, sf::Vector2f(30, 40)));
  5.     bullets.push_back(bullet(false, 30.0, sf::Vector2f(0, 0)));
  6.     bullets.push_back(bullet(false, 31.0, sf::Vector2f(20, 0)));
  7.    
  8.     std::cout << "Skończyłem tworzyć obiekty.\n";
  9.    
  10.     bullets.erase(bullets.begin());
  11.     bullets.erase(bullets.begin());
  12.     bullets.erase(bullets.begin());
  13.    
  14.     std::cout << "Usunąłem obiekty.\n";
  15.  
  16. //bullet_c.h
  17.     #ifndef bullet_c_h
  18.     #define bullet_c_h
  19.  
  20.     #include <SFML/Graphics.hpp>
  21.     #include <string>
  22.     #include <iostream>
  23.  
  24.     class bullet {
  25.         sf::Vector2f pos;
  26.         bool playerIsShooter;
  27.         float vel;
  28.    
  29.     public:
  30.         bullet(bool pIS, float v, sf::Vector2f p);
  31.         ~bullet();
  32.         bool if_pIS();
  33.     };
  34.  
  35.     #endif
  36.  
  37. //bullet_c.cpp
  38.     #include "bullet_c.h"
  39.  
  40.     bullet::bullet(bool pIS, float v, sf::Vector2f p): playerIsShooter(pIS), vel(v), pos(p) {
  41.         std::cout << "Bullet at x: " << pos.x << " y: " << pos.y << " with velocity: " << vel << " created. Player is a shooter: " << playerIsShooter << "\n";
  42.     }
  43.     bullet::~bullet() {
  44.         std::cout << "Bullet removed! \n";
  45.     }
  46.  
  47.     bool bullet::if_pIS() {
  48.         return this->playerIsShooter;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment