Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 5, 2006, 4:39:02 PM (19 years ago)
Author:
bensch
Message:

merged the presentation back

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/space_ships/spacecraft_2d.cc

    r9110 r9235  
    3535#include "debug.h"
    3636
     37#include "script_class.h"
     38
     39
    3740CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D);
    3841
    39 /**
    40  *  destructs the spacecraft_2d, deletes alocated memory
    41  */
    42 Spacecraft2D::~Spacecraft2D ()
    43 {
    44   this->setPlayer(NULL);
    45   delete this->toTravelHeight;
    46 }
     42
     43CREATE_SCRIPTABLE_CLASS(Spacecraft2D, CL_SPACECRAFT_2D,
     44                        addMethod("hasPlayer", ExecutorLua0ret<Playable,bool>(&Playable::hasPlayer))
     45                        //Coordinates
     46                        ->addMethod("setAbsCoor", ExecutorLua3<PNode,float,float,float>(&PNode::setAbsCoor))
     47                        ->addMethod("getAbsCoorX", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorX))
     48                        ->addMethod("getAbsCoorY", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorY))
     49                        ->addMethod("getAbsCoorZ", ExecutorLua0ret<PNode, float>(&PNode::getAbsCoorZ))
     50                        ->addMethod("setAirFriction", ExecutorLua1<Spacecraft2D, float>(&Spacecraft2D::setAirFriction))
     51                       );
     52
    4753
    4854/**
     
    7682    this->loadParams(root);
    7783
     84
     85
    7886  //weapons:
    79   Weapon* wpRight = new TestGun(0);
    80   wpRight->setName("testGun Right");
    81   Weapon* wpLeft = new TestGun(1);
    82   wpLeft->setName("testGun Left");
    83   //Weapon* cannon = dynamic_cast<Weapon*>(Factory::fabricate(CL_HYPERBLASTER));
     87  Weapon* wpRight = dynamic_cast<Weapon*>(Factory::fabricate(CL_LASER_CANNON));
     88  wpRight->setName("Cannon_Right");
     89  Weapon* wpLeft = dynamic_cast<Weapon*>(Factory::fabricate(CL_LASER_CANNON));
     90  wpLeft->setName("Cannon_Left");
     91
     92  Weapon* turretLeft = dynamic_cast<Weapon*>(Factory::fabricate(CL_BOOMERANG_GUN));
     93  wpRight->setName("Turret_Left");
     94  Weapon* turretRight = dynamic_cast<Weapon*>(Factory::fabricate(CL_BOOMERANG_GUN));
     95  wpLeft->setName("Turret_Right");
    8496
    8597  //  cannon->setName("BFG");
     
    8799  this->addWeapon(wpLeft, 1, 0);
    88100  this->addWeapon(wpRight,1 ,1);
     101  this->addWeapon(turretLeft, 1, 2);
     102  this->addWeapon(turretRight, 1, 3);
     103
    89104  //this->addWeapon(cannon, 0, 2);
    90105
    91106  this->getWeaponManager().changeWeaponConfig(1);
    92107  dynamic_cast<Element2D*>(this->getWeaponManager().getFixedTarget())->setVisibility( false);
     108}
     109
     110
     111/**
     112 * @brief destructs the spacecraft_2d, deletes alocated memory
     113 */
     114Spacecraft2D::~Spacecraft2D ()
     115{
     116  this->setPlayer(NULL);
     117  delete this->toTravelHeight;
    93118}
    94119
     
    109134  this->cameraLook = 0.0f;
    110135  this->rotation = 0.0f;
    111   this->acceleration = 10.0f;
    112   this->airFriction = 2.0f;
    113 
    114 
    115   this->setHealthMax(100);
    116   this->setHealth(100);
     136  this->acceleration = 20.0f;
     137  this->airFriction = 0.0f;
     138
     139
     140  this->setHealthMax(1000);
     141  this->setHealth(1000);
     142  this->setDamage(100.0f);
     143
    117144
    118145
     
    122149  this->travelNode = new PNode();
    123150
     151  this->loadModel("models/ships/mantawing.obj", 5.0f);
    124152
    125153  // camera - issue
     
    166194  this->getWeaponManager().setSlotCount(5);
    167195
    168   this->getWeaponManager().setSlotPosition(0, Vector(-0.28, 1.186, -2.750));
     196  this->getWeaponManager().setSlotPosition(0, Vector(1.843, -0.335, 2.029) * 5.0);
    169197  this->getWeaponManager().setSlotCapability(0, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    170198
    171   this->getWeaponManager().setSlotPosition(1, Vector(-0.28, 1.186, 2.750));
     199  this->getWeaponManager().setSlotPosition(1, Vector(1.843, -0.335, -2.029) * 5.0);
    172200  this->getWeaponManager().setSlotCapability(1, WTYPE_ALLDIRS | WTYPE_DIRECTIONAL);
    173201
    174   this->getWeaponManager().setSlotPosition(2, Vector(-1.63, .809, -.003));
    175   this->getWeaponManager().setSlotCapability(2, WTYPE_HEAVY);
    176 
    177202  /// TODO: THESE ARE TOO MUCH
    178   this->getWeaponManager().setSlotPosition(3, Vector(-1.63, .678, -.652));
    179   this->getWeaponManager().setSlotDirection(3, Quaternion(-24/180 * M_PI, Vector(1,0,0)));
    180 
    181   this->getWeaponManager().setSlotPosition(4, Vector(-1.63, .678, .652));
    182   this->getWeaponManager().setSlotDirection(4, Quaternion(24/180 * M_PI, Vector(1,0,0)));
     203  this->getWeaponManager().setSlotPosition(2, Vector(-0.351, -.238, 1.406) * 5.0);
     204  this->getWeaponManager().setSlotDirection(2, Quaternion(-1.7, Vector(0,1,0)));
     205
     206  this->getWeaponManager().setSlotPosition(3, Vector(-0.351, -.238, -1.406) * 5.0);
     207  this->getWeaponManager().setSlotDirection(3, Quaternion(1.7, Vector(0,1,0)));
    183208
    184209  this->cameraNode.setRelCoor(1,5,0);
     
    193218  registerVar( new SynchronizeableFloat( &cameraLook, &cameraLook, "cameraLook", PERMISSION_OWNER ) );
    194219  registerVar( new SynchronizeableFloat( &rotation, &rotation, "rotation", PERMISSION_OWNER ) );
     220
     221
     222
    195223}
    196224
     
    285313
    286314        State::getCameraNode()->setParentSoft(this->travelNode);
    287         State::getCameraNode()->setRelCoorSoft(-3, 50,0);
     315        State::getCameraNode()->setRelCoorSoft(-3, 100,0);
    288316        State::getCameraTargetNode()->setParentSoft(this->travelNode);
    289         State::getCameraTargetNode()->setRelCoorSoft(0,0,0);
     317        State::getCameraTargetNode()->setRelCoorSoft(5,0,1);
    290318
    291319
     
    406434        if (this->toTravelHeight != NULL)
    407435        {
    408           this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt, 0));
     436          this->travelNode->shiftCoor(Vector(0, (*toTravelHeight - this->travelNode->getAbsCoor().y) * dt * 10.0, 0));
    409437          if (fabsf(this->travelNode->getAbsCoor().y - *this->toTravelHeight) < .1)
    410438          {
     
    416444
    417445        accel.y = 0.0;
     446
    418447        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
    419448        accelerationDir.y = 0.0;
     
    424453
    425454        this->velocity += (accelerationDir - damping)* dt;
     455
     456        if (this->getRelCoor().z > this->travelDistance.y && velocity.z > 0.0)
     457          this->velocity.z = 0.0f;
     458        if (this->getRelCoor().z < -this->travelDistance.y && velocity.z < 0.0)
     459          this->velocity.z = 0.0f;
     460
     461        if (this->getRelCoor().x > this->travelDistance.x && velocity.x > 0.0)
     462          this->velocity.x = 0.0f;
     463        if (this->getRelCoor().x < -this->travelDistance.x && velocity.x < 0.0)
     464          this->velocity.x = 0.0f;
     465
     466
    426467        this->shiftCoor (this->velocity * dt);
    427         this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 1.0f);
     468        if (accel.z == 0)
     469          this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 5.0f);
     470        else
     471          this->setRelDirSoft(Quaternion(this->velocity.z * .004, Vector(1,0,0)), 4.5f);
    428472      }
    429473      break;
     
    475519      else if (cameraLook < -M_PI_4)
    476520        cameraLook = -M_PI_4;
    477       //this->cameraNode.setRelDirSoft(this->direction,10);
    478521    }
    479522  }
Note: See TracChangeset for help on using the changeset viewer.