- Timestamp:
- Nov 13, 2005, 4:30:07 PM (19 years ago)
- Location:
- branches/world_entities/src/world_entities
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/world_entities/src/world_entities/player.cc
r5558 r5559 341 341 void Player::ADDWEAPON() 342 342 { 343 Weapon* turret1; 344 if ((float)rand()/RAND_MAX < .7) 345 turret1 = new Turret(this->weaponMan); 343 Weapon* turret; 344 if ((float)rand()/RAND_MAX < .1) 345 { 346 turret = new Turret(this->weaponMan); 347 this->weaponMan->addWeapon(turret, 2); 348 this->weaponMan->changeWeaponConfig(2); 349 } 346 350 else 347 turret1 = new AimingTurret(this->weaponMan); 348 349 turret1->setName("Turret"); 350 turret1->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1); 351 352 this->weaponMan->addWeapon(turret1, 2); 353 354 this->weaponMan->changeWeaponConfig(2); 355 } 351 { 352 turret = new AimingTurret(this->weaponMan); 353 this->weaponMan->addWeapon(turret, 3); 354 355 this->weaponMan->changeWeaponConfig(3); 356 } 357 358 turret->setName("Turret"); 359 turret->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1); 360 } -
branches/world_entities/src/world_entities/weapons/aim.cc
r5558 r5559 20 20 #include "load_param.h" 21 21 #include "graphics_engine.h" 22 #include "glincl.h"23 22 #include "state.h" 23 #include "list.h" 24 24 #include "material.h" 25 26 #include "world_entity.h" 25 27 26 28 using namespace std; … … 58 60 59 61 this->setLayer(E2D_LAYER_TOP); 60 this->setRotationSpeed( 5);62 this->setRotationSpeed(30.0* (float)rand()/RAND_MAX + 10.0); 61 63 this->setSize(GraphicsEngine::getInstance()->getResolutionX()/10.0); 62 64 63 //this->setBindNode(this);65 this->setBindNode(this); 64 66 this->material = new Material; 65 67 } … … 79 81 .describe("the Speed with which the Aim should rotate"); 80 82 } 83 84 void Aim::searchTarget(PNode* source) 85 { 86 tIterator<WorldEntity>* iterator = State::getWorldEntityList()->getIterator(); 87 WorldEntity* entity = iterator->firstElement(); 88 while (likely(entity != NULL)) 89 { 90 if (entity->isA(CL_NPC) && (source->getAbsCoor() - entity->getAbsCoor()).len() < 100) 91 { 92 this->setParent(entity); 93 delete iterator; 94 return; 95 } 96 entity = iterator->nextElement(); 97 } 98 99 delete iterator; 100 } 101 81 102 82 103 … … 109 130 110 131 111 float z = 0.0f;112 glReadPixels ((int)this->getAbsCoor2D().x,113 GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1,114 1,115 1,116 GL_DEPTH_COMPONENT,117 GL_FLOAT,118 &z);119 120 121 GLdouble objX=.0, objY=.0, objZ=.0;122 gluUnProject(this->getAbsCoor2D().x,123 GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1,124 .99, // z125 GraphicsEngine::modMat,126 GraphicsEngine::projMat,127 GraphicsEngine::viewPort,128 &objX,129 &objY,130 &objZ );131 132 this->setAbsCoor(objX, objY, objZ);132 // float z = 0.0f; 133 // glReadPixels ((int)this->getAbsCoor2D().x, 134 // GraphicsEngine::getInstance()->getResolutionY()-(int)this->getAbsCoor2D().y-1, 135 // 1, 136 // 1, 137 // GL_DEPTH_COMPONENT, 138 // GL_FLOAT, 139 // &z); 140 // 141 // 142 // GLdouble objX=.0, objY=.0, objZ=.0; 143 // gluUnProject(this->getAbsCoor2D().x, 144 // GraphicsEngine::getInstance()->getResolutionY()-this->getAbsCoor2D().y-1, 145 // .99, // z 146 // GraphicsEngine::modMat, 147 // GraphicsEngine::projMat, 148 // GraphicsEngine::viewPort, 149 // &objX, 150 // &objY, 151 // &objZ ); 152 // 153 // this->setAbsCoor(objX, objY, objZ); 133 154 } 134 155 -
branches/world_entities/src/world_entities/weapons/aim.h
r5558 r5559 28 28 inline PNode* getTarget(PNode* target) { return this->getParent(); }; 29 29 30 void searchTarget(PNode* source); 30 31 31 32 void setSize(float size); -
branches/world_entities/src/world_entities/weapons/aiming_turret.cc
r5527 r5559 18 18 19 19 #include "weapon_manager.h" 20 #include "aim.h" 20 21 #include "projectile.h" 21 22 … … 45 46 this->init(); 46 47 47 this->loadModel("models/guns/turret 1.obj");48 this->loadModel("models/guns/turret2.obj"); 48 49 49 50 … … 66 67 { 67 68 // model will be deleted from WorldEntity-destructor 69 delete this->target; 68 70 } 69 71 … … 99 101 //this->getProjectileFactory()->prepare(100); 100 102 101 this->target = NULL;103 this->target = new Aim(); 102 104 } 103 105 … … 119 121 { 120 122 Quaternion quat; 121 if (this->target == NULL)122 this->target = this->getWeaponManager()->getDistanceTarget(this, 50);123 123 Vector direction = this->target->getAbsCoor() - this->getAbsCoor(); 124 124 … … 130 130 quat = Quaternion(direction, Vector(0,1,0)) * Quaternion ( -M_PI_2, Vector(0,1,0)) ; 131 131 132 this->setAbsDirSoft(quat, 20); 132 this->setAbsDirSoft(quat, 5); 133 134 this->target->tick(dt); 133 135 } 134 136 … … 143 145 if (target != NULL) 144 146 { 145 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))* 100.0 + VECTOR_RAND(13)147 pj->setVelocity(/*this->getVelocity()+*/(this->getAbsDir().apply(Vector(1,0,0))*250.0 + VECTOR_RAND(13) 146 148 /*target->getAbsCoor() - this->getAbsCoor()*/)*.5);//this->getVelocity()); 147 149 } … … 153 155 pj->setAbsDir(this->getAbsDir()); 154 156 pj->activate(); 155 this->target = this->getWeaponManager()->getDistanceTarget(this, 50);157 this->target->searchTarget(this); 156 158 } 157 159 -
branches/world_entities/src/world_entities/weapons/aiming_turret.h
r5527 r5559 8 8 9 9 #include "weapon.h" 10 11 /* FORWARD DECLARATION */ 12 class Aim; 10 13 11 14 class AimingTurret : public Weapon … … 29 32 30 33 private: 31 PNode* target;34 Aim* target; 32 35 }; 33 36
Note: See TracChangeset
for help on using the changeset viewer.