Changeset 9793 for code/branches/invaders/src/modules
- Timestamp:
- Nov 18, 2013, 7:54:32 PM (11 years ago)
- Location:
- code/branches/invaders/src/modules/invader
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/invaders/src/modules/invader/Invader.cc
r9777 r9793 47 47 #include "InvaderCenterPoint.h" 48 48 #include "InvaderShip.h" 49 #include "InvaderEnemy.h" 49 50 50 51 #include "core/command/ConsoleCommand.h" … … 79 80 return; 80 81 81 Pawn* newPawn = new Pawn(this->center_->getContext());82 InvaderEnemy* newPawn = new InvaderEnemy(this->center_->getContext()); 82 83 newPawn->addTemplate("enemyinvader"); 83 84 -
code/branches/invaders/src/modules/invader/InvaderShip.cc
r9777 r9793 56 56 void InvaderShip::tick(float dt) 57 57 { 58 // if (camera == NULL) 59 // camera = this->getCamera(); 60 // if (camera != NULL) 61 // camera->setPosition(Vector3(0, 0, 0) + this->getWorldPosition()); 58 Vector3 pos = getPosition(); 62 59 60 //Movement calculation 61 lastTimeFront += dt * damping; 62 lastTimeLeft += dt * damping; 63 lastTime += dt; 64 65 velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f); 66 velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f); 67 68 //Execute movement 63 69 if (this->hasLocalController()) 64 70 { 65 this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x)); // 66 //this->setVelocity(this->getOrientation() * Vector3(1, 0, 0)); 71 float dist_y = velocity.y * dt; 72 if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6) 73 posforeward += dist_y; 74 else 75 velocity.y = 0; 76 // this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x)); 77 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 67 78 } 68 lastTimeFront += dt * damping;69 lastTimeLeft += dt * damping;70 velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);71 velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);72 79 73 80 if (isFireing) 74 81 ControllableEntity::fire(0); 75 82 76 if (getPosition().x > 30000) 83 // Camera 84 Camera* camera = this->getCamera(); 85 if (camera != NULL) 77 86 { 78 //level++ 79 setPosition(getPosition() - Vector3(30000, 0, 0)); 87 camera->setPosition(Vector3(-pos.z, -posforeward, 0)); 88 camera->setOrientation(Vector3::UNIT_Z, Degree(90)); 89 // orxout() << "asbhajskjasjahg" << pos << endl; 80 90 } 81 91 82 // if ((int(getPosition().x) % 1000) < 5) 92 93 94 // bring back on track! 95 if (pos.z > 42*2.5) 96 pos.z = 42*2.5; 97 else if (pos.z < -42*3) 98 pos.z = -42*3; 99 if(pos.y != 0) 100 pos.y = 0; 101 // if (camera != NULL) 83 102 // { 84 // for (ObjectList<Invader>::iterator it = ObjectList<Invader>::begin(); it != ObjectList<Invader>::end(); ++it) 85 // it->spawnEnemy(); 103 // float x = camera->getWorldPosition().x; 104 // if (pos.x > x + 20) 105 // pos.x = x + 20; 106 // else if (pos.x < x - 20) 107 // pos.x = x - 20; 86 108 // } 109 // if (abs(posforeward) < 20) 110 87 111 88 // camera->setOrientation(Vector3::UNIT_X, Degree(0)); 112 setPosition(pos); 113 setOrientation(Vector3::UNIT_Y, Degree(270)); 89 114 115 // Level up! 116 if (pos.x > 30000) 117 { 118 updateLevel(); 119 setPosition(Vector3(0, 0, 0)); // pos - Vector3(30000, 0, 0) 120 } 90 121 91 122 SUPER(InvaderShip, tick, dt); 92 123 } 93 124 94 125 void InvaderShip::updateLevel() 126 { 127 lastTime = 0; 128 //level++ 129 } 95 130 96 131 void InvaderShip::moveFrontBack(const Vector2& value) 97 132 { 98 // orxout(internal_error) << "move backfront" << value.x << value.y << endl; 99 //velocity.y = value.y * speed * 10; 100 lastTimeFront = 0; 101 desiredVelocity.y = value.y * speed * 10; 133 lastTimeLeft = 0; 134 desiredVelocity.x = -value.x * speed; 102 135 } 103 136 104 137 void InvaderShip::moveRightLeft(const Vector2& value) 105 138 { 106 // orxout(internal_error) << "right left front" << value.x << value.y << endl; 107 lastTimeLeft = 0; 108 desiredVelocity.x = value.x * speed; 109 // velocity.x = value.x * speed; 139 lastTimeFront = 0; 140 desiredVelocity.y = value.y * speed * 42; 110 141 } 111 142 void InvaderShip::boost(bool bBoost) -
code/branches/invaders/src/modules/invader/InvaderShip.h
r9777 r9793 60 60 virtual void rotateRoll(const Vector2& value){}; 61 61 62 virtual void updateLevel(); 63 62 64 // *InvaderShip getShip(){return this;} 63 65 private: 64 66 Camera* camera; 65 67 bool isFireing; 66 float speed, damping ;67 float lastTimeFront, lastTimeLeft ;68 float speed, damping, posforeward; 69 float lastTimeFront, lastTimeLeft, lastTime; 68 70 struct Velocity 69 71 {
Note: See TracChangeset
for help on using the changeset viewer.