purxiz

bullet.cpp

May 9th, 2018
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include "bullet.h"
  2.  
  3. SnModel * bullet::bullet_model = new SnModel;
  4. std::vector<bullet *> bullet::bullet_list;
  5. bullet::bullet(GsVec position, GsVec direction, bool parent)
  6. {
  7.     this->direction = direction - position;
  8.     this->position = position + GsVec(0, 1.7f, 0);
  9.     //this->position += GsVec(this->direction.x, 0.0f, this->direction.z) * 7.0f;
  10.     this->position += this->direction * 7.0f;
  11.     if (parent) {
  12.         bullet_model = new SnModel;
  13.         bullet_model->model()->load_obj("../bullet.obj");
  14.         bullet_manip = new SnManipulator;
  15.         bullet_manip->visible(false);
  16.         bullet_manip->child(bullet_model);
  17.         m.scaling(.00000001f);
  18.         bullet_manip->initial_mat(m);
  19.         age = 500000;
  20.     }
  21.     else {
  22.         age = 0;
  23.         bullet_manip = new SnManipulator;
  24.         bullet_manip->visible(false);
  25.         bullet_manip->child(bullet_model);
  26.         bullet_list.push_back(this);
  27.     }
  28. }
  29.  
  30. void bullet::update() {
  31.     position += direction * BULLET_SPEED;
  32.     age++;
  33.     m.rot(GsVec(0, 0, 1), direction);
  34.     m.lcombtrans(position);
  35.     bullet_manip->initial_mat(m);
  36. }
  37. void bullet::setAge(int new_age) {
  38.     age = new_age;
  39. }
  40. int bullet::getAge() {
  41.     return age;
  42. }
  43. GsVec bullet::getPos() {
  44.     return position;
  45. }
  46. SnManipulator * bullet::getManip() {
  47.     return bullet_manip;
  48. }
  49. const std::vector<bullet *> bullet::getList() {
  50.     return bullet_list;
  51. }
  52. void bullet::setList(std::vector<bullet *> list) {
  53.     bullet_list = list;
  54. }
  55. bullet::~bullet()
  56. {
  57. }
Add Comment
Please, Sign In to add comment