Changeset 11783 for code/trunk/src/modules/superorxobros/SOBGumba.cc
- Timestamp:
- Feb 20, 2018, 12:14:40 AM (6 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/superorxobros/SOBGumba.cc
- Property svn:eol-style set to native
r11416 r11783 48 48 RegisterObject(SOBGumba); 49 49 50 attachedToFigure_ = false;51 50 setAngularFactor(0.0); 52 figure_ = nullptr;53 51 this->enableCollisionCallback(); 54 52 gravityAcceleration_ = 350.0; … … 56 54 hasCollided_=false; 57 55 goesRight_ = true; 58 lastPos_ = getPosition();59 lastPos_.x -= 20;60 56 changeAllowed_ = true; 61 57 changedOn_ = 0.0; 58 creator_ = nullptr; 59 maxLifetime_ = 10; 60 lifetime_ = 0; 62 61 63 62 } … … 86 85 87 86 88 void SOBGumba::set Figure(SOBFigure* newFigure)87 void SOBGumba::setDirection(const bool direction) 89 88 { 90 figure_ = newFigure; 89 if(direction) 90 { 91 goesRight_=true; 92 } 93 else 94 { 95 goesRight_=false; 96 } 91 97 } 92 98 93 99 void SOBGumba::die(){ 100 Vector3 velocity = this->getVelocity(); 101 velocity.y = speed_; 102 this->setVelocity(velocity); 103 } 94 104 95 105 void SOBGumba::tick(float dt) … … 100 110 changedOn_+= dt; 101 111 // After a collision, we don't listen for collisions for 200ms - that's because one wall can cause several collisions! 102 if (changedOn_> 0. 200) {112 if (changedOn_> 0.400) { 103 113 changeAllowed_ = true; 104 114 changedOn_ = 0.0; … … 106 116 } 107 117 } 108 118 109 119 110 120 int dir = 1; … … 113 123 114 124 Vector3 velocity = getVelocity(); 125 if(velocity.z > -1 && velocity.z < 1) 126 { 127 velocity.x = dir*speed_; 128 } 129 115 130 velocity.z -= gravityAcceleration_*dt; 116 velocity.x = dir*speed_;117 131 setVelocity(velocity); 118 132 119 lastPos_ = getPosition(); 133 if (creator_ != nullptr) 134 { 135 lifetime_ += dt; 136 if(lifetime_>maxLifetime_) 137 { 138 139 } 140 } 141 142 if(abs(this->getPosition().z) > 1000) this->destroyLater(); 143 120 144 } 121 122 123 145 }
Note: See TracChangeset
for help on using the changeset viewer.