Changeset 5435 in orxonox.OLD for trunk/src/world_entities
- Timestamp:
- Oct 25, 2005, 5:31:54 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/player.cc
r5420 r5435 92 92 wpLeft->setName("testGun Left"); 93 93 94 Weapon* turret1 = new Turret(this->weaponMan);95 turret1->setName("Turret1");96 turret1->setStateDuration(WS_SHOOTING, .2);97 Weapon* turret2 = new Turret(this->weaponMan);98 turret2->setName("Turret2");99 turret2->setStateDuration(WS_SHOOTING, .3);100 Weapon* turret3 = new Turret(this->weaponMan);101 turret3->setName("Turret3");102 turret3->setStateDuration(WS_SHOOTING, .17);103 104 Weapon* turret4 = new Turret(this->weaponMan);105 turret4->setName("Turret4");106 turret4->setStateDuration(WS_SHOOTING, .3);107 108 109 94 this->weaponMan->addWeapon(wpLeft, 1, 0); 110 95 this->weaponMan->addWeapon(wpRight,1 ,1); 111 this->weaponMan->addWeapon(turret1, 2, 2);112 this->weaponMan->addWeapon(turret2, 2, 3);113 this->weaponMan->addWeapon(turret3, 2, 4);114 this->weaponMan->addWeapon(turret4, 2, 5);115 116 96 //this->weaponMan->addWeapon(turret, 3, 0); 117 97 118 this->weaponMan->changeWeaponConfig( 0);98 this->weaponMan->changeWeaponConfig(1); 119 99 } 120 100 … … 153 133 154 134 this->weaponMan = new WeaponManager(this); 155 this->weaponMan->setSlotCount( 6);135 this->weaponMan->setSlotCount(10); 156 136 157 137 this->weaponMan->setSlotPosition(0, Vector(-2.6, .1, -3.0)); … … 171 151 this->weaponMan->setSlotDirection(5, Quaternion(+M_PI_4*.5-M_PI, Vector(1,0,0))); 172 152 153 this->weaponMan->setSlotPosition(6, Vector(-2.0, 0.1, -2.0)); 154 this->weaponMan->setSlotPosition(7, Vector(-2.0, 0.1, 2.0)); 155 156 this->weaponMan->setSlotPosition(8, Vector(-2.5, -0.3, -2.0)); 157 this->weaponMan->setSlotDirection(8, Quaternion(-M_PI, Vector(1,0,0))); 158 159 this->weaponMan->setSlotPosition(9, Vector(-2.5, -0.3, 2.0)); 160 this->weaponMan->setSlotDirection(9, Quaternion(+M_PI, Vector(1,0,0))); 161 173 162 } 174 163 … … 222 211 223 212 224 225 /** 226 * if the player is hit, call this function 227 * @param weapon hit by this weapon 228 * @param loc ?? 229 */ 230 void Player::hit (WorldEntity* weapon, Vector* loc) 231 { 232 } 233 234 235 /** 236 * Collision with another Entity has this effect 237 * @param other the other colider 238 * @param ownhitflags ?? 239 * @param otherhitflags ?? 240 */ 241 void Player::collide (WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags) 242 { 243 } 244 213 WorldEntity* ref = NULL; 214 /** 215 * this function is called, when two entities collide 216 * @param entity: the world entity with whom it collides 217 * 218 * Implement behaviour like damage application or other miscellaneous collision stuff in this function 219 */ 220 void Player::collidesWith(WorldEntity* entity, const Vector& location) 221 { 222 if (entity->isA(CL_TURRET_POWER_UP) && entity != ref) 223 { 224 this->ADDWEAPON(); 225 ref = entity; 226 } 227 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 228 } 245 229 246 230 /** … … 343 327 this->weaponMan->previousWeaponConfig(); 344 328 } 329 330 // FIXME THIS MIGHT BE CONSIDERED EITHER A FEATURE, OR A BUG 331 int slot = 2; 332 void Player::ADDWEAPON() 333 { 334 Weapon* turret1 = new Turret(this->weaponMan); 335 turret1->setName("Turret"); 336 turret1->setStateDuration(WS_SHOOTING, (float)rand()/RAND_MAX*.5+.1); 337 338 this->weaponMan->addWeapon(turret1, 2, slot++); 339 340 this->weaponMan->changeWeaponConfig(2); 341 } -
trunk/src/world_entities/player.h
r5257 r5435 41 41 virtual void postSpawn(); 42 42 virtual void leftWorld(); 43 virtual void hit(WorldEntity* weapon, Vector* loc);44 virtual void collide(WorldEntity* other, Uint32 ownhitflags, Uint32 otherhitflags);45 43 44 virtual void collidesWith(WorldEntity* entity, const Vector& location); 46 45 virtual void tick(float time); 47 46 virtual void draw(); … … 54 53 void weaponAction(); 55 54 55 // !! temporary !! 56 void ADDWEAPON(); 56 57 57 58 private: -
trunk/src/world_entities/power_ups/turret_power_up.cc
r5434 r5435 17 17 #include "turret_power_up.h" 18 18 #include "factory.h" 19 #include "state.h" 20 #include "list.h" 19 21 20 22 using namespace std; 21 23 22 24 CREATE_FACTORY(TurretPowerUp); 25 26 GLUquadricObj* TurretPowerUp_sphereObj = NULL; 27 Material* TurretPowerUp_sphereMat = NULL; 23 28 24 29 … … 36 41 37 42 38 TurretPowerUp::~TurretPowerUp () {} 43 TurretPowerUp::~TurretPowerUp () { 44 45 } 39 46 40 47 … … 42 49 { 43 50 this->setClassID(CL_TURRET_POWER_UP, "TurretPowerUp"); 44 this->loadModel("models/guns/turret1.obj"); 51 this->loadModelWithScale("models/guns/turret1.obj", 2.0); 52 53 if (TurretPowerUp_sphereObj == NULL) 54 TurretPowerUp_sphereObj = gluNewQuadric(); 55 if(TurretPowerUp_sphereMat == NULL) 56 { 57 TurretPowerUp_sphereMat = new Material("TurretPowerUp_Sphere"); 58 TurretPowerUp_sphereMat->setTransparency(.1); 59 } 60 this->rotation = Vector(0,1,0); 61 this->cycle = 0; 45 62 } 46 63 … … 51 68 52 69 } 70 71 72 /** 73 * this function is called, when two entities collide 74 * @param entity: the world entity with whom it collides 75 * 76 * Implement behaviour like damage application or other miscellaneous collision stuff in this function 77 */ 78 void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location) 79 { 80 // PRINTF(3)("collision %s vs %s @ (%f,%f,%f)\n", this->getClassName(), entity->getClassName(), location.x, location.y, location.z); 81 if (entity->isA(CL_PLAYER)) 82 State::getWorldEntityList()->remove(this); 83 } 84 85 /** 86 * this method is called every frame 87 * @param time: the time in seconds that has passed since the last tick 88 * 89 * Handle all stuff that should update with time inside this method (movement, animation, etc.) 90 */ 91 void TurretPowerUp::tick(float dt) 92 { 93 this->shiftDir(Quaternion(dt, this->rotation)); 94 this->cycle+=dt; 95 96 } 97 98 /** 99 * the entity is drawn onto the screen with this function 100 * 101 * This is a central function of an entity: call it to let the entity painted to the screen. 102 * Just override this function with whatever you want to be drawn. 103 */ 104 void TurretPowerUp::draw() 105 { glMatrixMode(GL_MODELVIEW); 106 glPushMatrix(); 107 /* translate */ 108 glTranslatef (this->getAbsCoor ().x, 109 this->getAbsCoor ().y + cos(this->cycle*3.0)*2.0, 110 this->getAbsCoor ().z); 111 /* rotate */ 112 Vector tmpRot = this->getAbsDir().getSpacialAxis(); 113 glRotatef (this->getAbsDir().getSpacialAxisAngle(), tmpRot.x, tmpRot.y, tmpRot.z ); 114 TurretPowerUp_sphereMat->select(); 115 // gluSphere(TurretPowerUp_sphereObj, 3, 5, 5); 116 this->model->draw(); 117 glPopMatrix(); 118 119 } 120 -
trunk/src/world_entities/power_ups/turret_power_up.h
r5434 r5435 16 16 virtual ~TurretPowerUp (); 17 17 18 virtual void TurretPowerUp::collidesWith(WorldEntity* entity, const Vector& location); 19 virtual void tick(float dt); 20 virtual void draw(); 21 18 22 private: 19 23 void init(); 20 24 void loadParams(const TiXmlElement* root); 25 26 private: 27 Vector rotation; 28 float cycle; 21 29 }; 22 30 -
trunk/src/world_entities/weapons/weapon_manager.cc
r5208 r5435 152 152 * this is used, to identify to which ship/man/whatever this WeaponManager is connected. 153 153 * also all the Slots will be subconnected to this parent. 154 * 155 * The reason this function exists is that the WeaponManager is neither a WorldEntity nor 156 * a PNode. 154 157 */ 155 158 void WeaponManager::setParent(PNode* parent) -
trunk/src/world_entities/weapons/weapon_manager.h
r4972 r5435 20 20 21 21 22 #define WM_MAX_SLOTS 8//!< How many slots the WeaponManager has at its max22 #define WM_MAX_SLOTS 10 //!< How many slots the WeaponManager has at its max 23 23 #define WM_MAX_CONFIGS 4 //!< The maximum number of predefined Configurations 24 24 #define WM_MAX_LOADED_WEAPONS 20 //!< The -
trunk/src/world_entities/world_entity.cc
r5431 r5435 203 203 this->getAbsCoor ().y, 204 204 this->getAbsCoor ().z); 205 /* rotate */ 205 /* rotate */ // FIXME: devise a new Way to rotate this 206 206 this->getAbsDir ().matrix (matrix); 207 207 glMultMatrixf((float*)matrix);
Note: See TracChangeset
for help on using the changeset viewer.