Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9124 in orxonox.OLD


Ignore:
Timestamp:
Jul 4, 2006, 2:17:17 PM (18 years ago)
Author:
bensch
Message:

limited controls

Location:
branches/presentation/src/world_entities/space_ships
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/space_ships/spacecraft_2d.cc

    r9120 r9124  
    3535#include "debug.h"
    3636
     37#include "script_class.h"
     38
     39
    3740CREATE_FACTORY(Spacecraft2D, CL_SPACECRAFT_2D);
     41
     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                       );
    3852
    3953/**
     
    110124  this->rotation = 0.0f;
    111125  this->acceleration = 10.0f;
    112   this->airFriction = 2.0f;
     126  this->airFriction = 0.0f;
    113127
    114128
     
    416430
    417431        accel.y = 0.0;
     432
     433
    418434        Vector accelerationDir = this->getAbsDir().apply(accel * this->acceleration);
    419435        accelerationDir.y = 0.0;
    420436
     437
     438        /*
     439                if (this->getRelCoor().z > this->travelDistance.y && accel.z > 0.0)
     440                accel.z = 0.0f;
     441                if (this->getRelCoor().z < -this->travelDistance.y && accel.z < 0.0)
     442                accel.z = 0.0f;
     443
     444                if (this->getRelCoor().x > this->travelDistance.x && accel.x > 0.0)
     445                accel.x = 0.0f;
     446                if (this->getRelCoor().x < -this->travelDistance.x && accel.x < 0.0)
     447                accel.x = 0.0f;*/
     448
     449
    421450        // this is the air friction (necessary for a smooth control)
    422451        Vector damping = (this->velocity * this->airFriction);
     
    424453
    425454        this->velocity += (accelerationDir - damping)* dt;
     455
     456        if (this->getRelCoor().z > this->travelDistance.y && accel.z > 0.0)
     457          this->velocity.z = 0.0f;
     458        if (this->getRelCoor().z < -this->travelDistance.y && accel.z < 0.0)
     459          this->velocity.z = 0.0f;
     460
     461        if (this->getRelCoor().x > this->travelDistance.x && accel.x > 0.0)
     462          this->velocity.x = 0.0f;
     463        if (this->getRelCoor().x < -this->travelDistance.x && accel.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)) * Quaternion(this->velocity.z * .01, Vector(1,0,0)), 2.0f);
     468        if (accel.z == 0)
     469          this->setRelDirSoft(Quaternion(0, Vector(0,0,0)), 3.0f);
     470        else
     471          this->setRelDirSoft(Quaternion(this->velocity.z * .01, Vector(1,0,0)), 2.0f);
    428472      }
    429473      break;
  • branches/presentation/src/world_entities/space_ships/spacecraft_2d.h

    r9110 r9124  
    2727    void setTravelDistance(const Vector2D& distance);
    2828    void setTravelDistance(float x, float y);
     29
     30    void setAirFriction(float friction) { this->airFriction = friction; };
    2931
    3032
Note: See TracChangeset for help on using the changeset viewer.