Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2006, 2:12:41 AM (18 years ago)
Author:
marcscha
Message:

Some surprises for comming wednesday

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/playability/src/world_entities/space_ships/space_ship.cc

    r10078 r10081  
    3434#include "particles/emitter_node.h"
    3535#include "particles/sprite_particles.h"
     36#include "effects/explosion.h"
     37#include "effects/trail.h"
    3638
    3739#include "util/loading/factory.h"
     
    120122{
    121123  this->init();
     124  //this->setParentMode(PNODE_REPARENT_DELETE_CHILDREN);
    122125  if (root != NULL)
    123126    this->loadParams(root);
     
    139142  PRINTF(4)("SPACESHIP INIT\n");
    140143
    141   secWeaponMan.showCrosshair();
    142 
    143144  //weapons:
    144 
     145  /*
    145146  Weapon* wpRight1 = new LightBlaster ();
    146147  wpRight1->setName( "LightBlaster");
     
    148149  Weapon* wpLeft1 = new LightBlaster ();
    149150  wpLeft1->setName( "LightBlaster");
    150   wpLeft1->setParent( this);
     151  wpLeft1->setParent( this);*/
    151152
    152153  Weapon* wpRight2 = new MediumBlaster ();
     
    156157  wpLeft2->setName( "MediumBlaster");
    157158  wpLeft2->setParent( this);
    158 
     159  /*
    159160  Weapon* wpRight3 = new HeavyBlaster ();
    160161  wpRight3->setName( "HeavyBlaster");
     
    162163  Weapon* wpLeft3 = new HeavyBlaster ();
    163164  wpLeft3->setName( "HeavyBlaster");
    164   wpLeft3->setParent( this);
     165  wpLeft3->setParent( this);*/
    165166
    166167  Weapon* cannon = new SwarmLauncher();
     
    169170
    170171
    171   this->weaponMan.addWeapon( wpLeft1, 0, 0);
    172   this->weaponMan.addWeapon( wpRight1, 0, 1);
     172  //this->weaponMan.addWeapon( wpLeft1, 0, 0);
     173  //this->weaponMan.addWeapon( wpRight1, 0, 1);
    173174  this->weaponMan.addWeapon( wpLeft2, 0, 2);
    174175  this->weaponMan.addWeapon( wpRight2, 0, 3);
    175   this->weaponMan.addWeapon( wpLeft3, 0, 4);
    176   this->weaponMan.addWeapon( wpRight3, 0, 5);
     176  //this->weaponMan.addWeapon( wpLeft3, 0, 4);
     177  //this->weaponMan.addWeapon( wpRight3, 0, 5);
    177178
    178179  this->secWeaponMan.addWeapon( cannon, 1, 0);
     
    181182  this->secWeaponMan.changeWeaponConfig(1);
    182183
    183   wpRight1->requestAction(WA_ACTIVATE);
    184   wpLeft1->requestAction(WA_ACTIVATE);
     184  //wpRight1->requestAction(WA_ACTIVATE);
     185  //wpLeft1->requestAction(WA_ACTIVATE);
    185186  wpRight2->requestAction(WA_ACTIVATE);
    186187  wpLeft2->requestAction(WA_ACTIVATE);
    187   wpRight3->requestAction(WA_ACTIVATE);
    188   wpLeft3->requestAction(WA_ACTIVATE);
     188  //wpRight3->requestAction(WA_ACTIVATE);
     189  //wpLeft3->requestAction(WA_ACTIVATE);
    189190
    190191  cannon->requestAction(WA_ACTIVATE);
     
    301302  dynamic_cast<Element2D*>(this->weaponMan.getFixedTarget())->setVisibility( false);
    302303
    303   this->burstEmitter = new DotEmitter(800, 0.0, .01);
    304   this->burstEmitter->setParent(this);
    305   this->burstEmitter->setRelCoor(-1, .5, 0);
    306   this->burstEmitter->setName("SpaceShip_Burst_emitter");
    307   this->burstEmitter->setEmissionRate(800);
    308 
    309   this->burstSystem = new SpriteParticles(400);
    310   this->burstSystem->addEmitter(this->burstEmitter);
    311   this->burstSystem->setName("SpaceShip_Burst_System");
    312   ((SpriteParticles*)this->burstSystem)->setMaterialTexture("maps/radial-trans-noise.png");
    313   this->burstSystem->setLifeSpan(0.3, .3);
    314   this->burstSystem->setRadius(0.0, 1.0);
    315   this->burstSystem->setRadius(0.05, 1.0);
    316   this->burstSystem->setRadius(.5, .6);
    317   this->burstSystem->setRadius(1.0, 0);
    318   this->burstSystem->setColor(0.0, .7,.7,1,.5);
    319   this->burstSystem->setColor(0.2, 0,0,0.8,.7);
    320   this->burstSystem->setColor(0.5, .5,.5,.8,.8);
    321   this->burstSystem->setColor(1.0, .8,.8,.8,.0);
    322304
    323305  registerVar( new SynchronizeableBool( &bForward, &bForward, "bForward", PERMISSION_OWNER ) );
     
    342324
    343325  this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical);
     326
     327 
     328  this->trail = new Trail( 15, 10, .2);
     329  this->trail->setParent( this);
     330  this->trail->setTexture( "maps/engine.png");
     331
     332  this->trailL = new Trail( 15, 10, .2);
     333  this->trailL->setParent( this);
     334  this->trailL->setTexture( "maps/engine.png");
     335
     336  this->trailR = new Trail( 15, 10, .2);
     337  this->trailR->setParent( this);
     338  this->trailR->setTexture( "maps/engine.png");
    344339}
    345340
     
    376371{
    377372  this->secWeaponMan.showCrosshair();
     373  /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
     374  {
     375    if( likely( dynamic_cast<WorldEntity*>(*it) != NULL))
     376      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_01);
     377  }*/
    378378  this->toList( OM_GROUP_01 );
    379   /*for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); it++)
    380   {
    381     (*it)->toList( OM_GROUP_01);
    382   }*/
    383379  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true);
    384380  //this->attachCamera();
     
    389385{
    390386  this->secWeaponMan.hideCrosshair();
     387  /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
     388  {
     389    if( likely(dynamic_cast<WorldEntity*>(*it) != NULL))
     390      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00);
     391  }*/
    391392  this->toList( OM_GROUP_00);
    392   /*for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); it++)
    393   {
    394     (*it)->toList( OM_GROUP_00);
    395   }*/
    396393  //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( false);
    397394  //this->detachCamera();
     
    424421void SpaceShip::collidesWith(WorldEntity* entity, const Vector& location)
    425422{
     423  PRINTF(0)("SPACESHIP COLLIDED WITH %s\n",entity->getCName());
    426424}
    427425
     
    433431  WorldEntity::draw();
    434432
     433  glMatrixMode(GL_MODELVIEW);
     434  glPushMatrix();
     435
     436  float matrix[4][4];
     437  glTranslatef (this->getAbsCoor ().x-1, this->getAbsCoor ().y-.2, this->getAbsCoor ().z);
     438  this->getAbsDir().matrix (matrix);
     439  glMultMatrixf((float*)matrix);
     440  //glScalef(2.0, 2.0, 2.0);  // no double rescale
     441 
     442  this->trail->draw();
     443 
     444  glTranslatef(0,0,-.5);
     445  this->trailL->draw();
     446
     447  glTranslatef(0,0,1);
     448  this->trailR->draw();
     449  glPopMatrix();
    435450  //this->debug(0);
    436451}
     
    512527  this->cameraNode.setRelDirSoft(this->getAbsDir(), 30.0f);
    513528
    514   this->burstEmitter->setEmissionRate(this->cameraSpeed + (velocity.z>0)*velocity.z);
    515   this->burstEmitter->setEmissionVelocity(this->cameraSpeed + (velocity.z>0)*velocity.z, travelSpeed *.1);
    516 
     529  this->trail->tick(time);
     530  this->trailL->tick(time);
     531  this->trailR->tick(time);
    517532  //orient the spaceship in direction of the mouse
    518533  /*
     
    585600{
    586601  PRINTF(0)("spaceship destroy\n");
    587 
     602  /*
    588603  EmitterNode* node  = NULL;
    589604  DotEmitter* emitter = NULL;
     
    613628  node->setVelocity( this->getParent()->getVelocity());
    614629  node->setAbsCoor( this->getAbsCoor());
    615   node->start();
     630  node->start();*/
     631  PNode* node          = new PNode();
     632  node->setAbsCoor(this->getAbsCoor());
     633  Explosion* explosion = new Explosion();
     634  explosion->explode( node, Vector(5,5,5));
    616635
    617636  this->setAbsCoor(Vector(-10000,10000,10000));
     
    619638
    620639  this->toList( OM_DEAD);
    621   /*for(ObjectList<WorldEntity>::const_iterator it = WorldEntity::objectList().begin(); it != WorldEntity::objectList().end(); it++)
     640  /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
    622641  {
    623     (*it)->toList( OM_DEAD);
     642    if( dynamic_cast<WorldEntity*>(*it) != NULL)
     643      dynamic_cast<WorldEntity*>(*it)->toList( OM_DEAD);
    624644  }*/
    625645    PRINTF(0)("spaceship destroy == ship translated \n");
     
    628648void SpaceShip::respawn( )
    629649{
    630   //this->show();
    631   //this->toList( OM_GROUP_00);
     650  this->unhide();
     651  /*for(ObjectList<PNode>::const_iterator it = this->getNodesChildren().begin(); it != this->getNodesChildren().end(); it++)
     652  {
     653    if( dynamic_cast<WorldEntity*>(*it) != NULL)
     654      dynamic_cast<WorldEntity*>(*it)->toList( OM_GROUP_00);
     655  }*/
     656  /*if( this->hasPlayer())
     657    this->toList( OM_GROUP_01);
     658  else
     659    this->toList( OM_GROUP_00);*/
     660
    632661}
    633662
    634663
    635664void SpaceShip::damage(float pDamage, float eDamage){
    636   PRINTF(0)("ship hit");
    637   printf("Shit hit");
     665  PRINTF(0)("ship hit for (%f,%f) \n",pDamage,eDamage);
     666  PRINTF(0)("SHIP HIT - SHIP HIT - SHIP HIT\n");
     667
    638668  if( this->shieldActive) {
    639669    if( this->shieldCur > pDamage) {
     
    643673      this->shieldCur -=pDamage;
    644674      this->shieldActive = false; //shield collapses
    645       pDamage = pDamage - this->shieldCur;
     675      pDamage += this->shieldCur;
    646676      if( !this->shieldActive) {
    647677        this->armorCur -= pDamage / 2; // remaining damages hits armor at half rate
Note: See TracChangeset for help on using the changeset viewer.