- Timestamp:
- Feb 18, 2018, 4:02:50 PM (6 years ago)
- Location:
- code/branches/Presentation_HS17_merge
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge
-
code/branches/Presentation_HS17_merge/src/modules/superorxobros/SOBGumba.cc
r11416 r11766 60 60 changeAllowed_ = true; 61 61 changedOn_ = 0.0; 62 creator_ = nullptr; 63 maxLifetime_ = 10; 64 lifetime_ = 0; 62 65 63 66 } … … 91 94 } 92 95 96 void SOBGumba::setDirection(const bool direction) 97 { 98 if(direction) 99 { 100 goesRight_=true; 101 } 102 else 103 { 104 goesRight_=false; 105 } 106 } 93 107 108 void SOBGumba::die(){ 109 Vector3 velocity = this->getVelocity(); 110 velocity.y = speed_; 111 this->setVelocity(velocity); 112 } 94 113 95 114 void SOBGumba::tick(float dt) … … 100 119 changedOn_+= dt; 101 120 // 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) {121 if (changedOn_> 0.400) { 103 122 changeAllowed_ = true; 104 123 changedOn_ = 0.0; … … 106 125 } 107 126 } 108 127 109 128 110 129 int dir = 1; … … 113 132 114 133 Vector3 velocity = getVelocity(); 134 if(velocity.z > -1 && velocity.z < 1) 135 { 136 velocity.x = dir*speed_; 137 } 138 115 139 velocity.z -= gravityAcceleration_*dt; 116 velocity.x = dir*speed_;117 140 setVelocity(velocity); 118 141 119 142 lastPos_ = getPosition(); 143 144 if (creator_ != nullptr) 145 { 146 lifetime_ += dt; 147 if(lifetime_>maxLifetime_) 148 { 149 150 } 151 } 152 153 if(abs(this->getPosition().z) > 1000) delete this; 154 120 155 } 121 122 123 156 }
Note: See TracChangeset
for help on using the changeset viewer.