Changeset 10032 in orxonox.OLD for branches/playability/src
- Timestamp:
- Dec 6, 2006, 7:07:24 PM (18 years ago)
- Location:
- branches/playability/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/story_entities/game_world.cc
r9869 r10032 346 346 this->dataTank->localPlayer->getPlayable()->setPlaymode(playmode)) 347 347 { 348 PRINTF( 4)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str());348 PRINTF(0)("Set Playmode to %d:%s\n", playmode, Playable::playmodeToString(playmode).c_str()); 349 349 } 350 350 else 351 351 { 352 PRINTF( 2)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str());352 PRINTF(0)("Unable to set Playmode %d:'%s'\n", playmode, Playable::playmodeToString(playmode).c_str()); 353 353 } 354 354 } -
branches/playability/src/world_entities/playable.cc
r9869 r10032 44 44 45 45 Playable::Playable() 46 : weaponMan(this) ,47 supportedPlaymodes(Playable::Full3D),46 : weaponMan(this) 47 ,supportedPlaymodes(Playable::Full3D), 48 48 playmode(Playable::Full3D) 49 49 { -
branches/playability/src/world_entities/playable.h
r9961 r10032 71 71 void setCameraMode(unsigned int cameraMode = 0); 72 72 bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; }; 73 bool setPlaymode(Playable::Playmode playmode);73 virtual bool setPlaymode(Playable::Playmode playmode); 74 74 Playable::Playmode getPlaymode() const { return this->playmode; }; 75 75 virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0; -
branches/playability/src/world_entities/space_ships/space_ship.cc
r10030 r10032 133 133 srand(time(0)); //initialize Random Nomber Generator 134 134 135 this->setSupportedPlaymodes(Playable::Vertical);136 137 135 // this->setRelDir(Quaternion(M_PI, Vector(1,0,0))); 138 136 this->registerObject(this, SpaceShip::_objectList); … … 386 384 387 385 this->travelNode->debugDraw(); 386 387 this->setSupportedPlaymodes(Playable::Horizontal | Playable::Vertical); 388 388 } 389 389 … … 396 396 { 397 397 Playable::loadParams(root); 398 } 398 399 LoadParam(root, "playmode", this, SpaceShip, setPlaymodeXML); 400 } 401 399 402 400 403 void SpaceShip::setPlayDirection(const Quaternion& rot, float speed) 401 404 { 402 this->direction = Quaternion (rot.getHeading(), Vector(0,1,0));405 //this->direction = Quaternion (rot.getHeading(), Vector(0,1,0)); 403 406 } 404 407 … … 446 449 this->secWeaponMan.showCrosshair(); 447 450 //dynamic_cast<Element2D*>(this->secWeaponMan.getFixedTarget())->setVisibility( true); 448 if (!this->setPlaymode(Playable::Vertical))449 std::cout << "playmode not supported";450 451 //this->attachCamera(); 452 // this->setPlaymode(Playable::Horizontal); 451 453 } 452 454 … … 791 793 //break; 792 794 793 794 case Playable:: Vertical:795 break; 796 case Playable::Horizontal: 795 797 if (State::getCameraNode != NULL) 796 798 { … … 805 807 806 808 State::getCameraNode()->setParentSoft(this->travelNode); 807 State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0);809 State::getCameraNode()->setRelCoorSoft(-0.01, 40, 0); 808 810 State::getCameraTargetNode()->setParentSoft(this->travelNode); 809 811 State::getCameraTargetNode()->setRelCoorSoft(0,0,0); … … 817 819 PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName()); 818 820 } 819 std::cout << Playable::playmodeToString(this->getPlaymode());820 821 } 821 822 … … 833 834 float pi = 3.14; 834 835 835 // these routines will change the travel movement into zero in a short amout of time, if the player 836 // doesn't press any buttons. 837 if (this->velocity.x >= 0) 838 { 839 if (this->velocity.x > airCoeff*this->acceleration * dt) 840 this->velocity.x -= airCoeff* this->acceleration * dt; 841 else 842 this->velocity.x = 0; 843 } 844 else 845 { 846 if (this->velocity.x < -airCoeff*this->acceleration * dt) 847 this->velocity.x += airCoeff* this->acceleration * dt; 848 else 849 this->velocity.x = 0; 850 } 851 if (this->velocity.z >= 0) 852 { 853 if (this->velocity.z > airCoeff*this->acceleration * dt) 854 this->velocity.z -= airCoeff* this->acceleration * dt; 855 else 856 this->velocity.z = 0; 857 } 858 else 859 { 860 if (this->velocity.z < -airCoeff*this->acceleration * dt) 861 this->velocity.z += airCoeff* this->acceleration * dt; 862 else 863 this->velocity.z = 0; 864 } 865 866 // this will evite, that the ship moves outside the travelDistance- borders,when the player releases all buttons 867 // and its continuing to slide a bit. 868 Vector oldCoor = this->getRelCoor(); 869 if (this->getRelCoor().x > this->travelDistancePlus.x) this->setRelCoor(this->travelDistancePlus.x, oldCoor.y, oldCoor.z); 870 if (this->getRelCoor().x < this->travelDistanceMinus.x) this->setRelCoor(this->travelDistanceMinus.x, oldCoor.y, oldCoor.z); 871 if (this->getRelCoor().z > this->travelDistancePlus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistancePlus.y); 872 if (this->getRelCoor().z < this->travelDistanceMinus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistanceMinus.y); 873 874 if( this->systemFailure() ) 875 bForward = bBackward = bLeft = bRight = false; 876 877 878 if( this->bForward ) 879 { 880 if(this->getRelCoor().x < this->travelDistancePlus.x) 836 837 838 switch(this->getPlaymode()) 839 { 840 case Playable::Horizontal: 881 841 { 882 if (this->velocity.x < this->travelSpeed) 883 { 884 this->velocity.x += (airCoeff + 1.0)*this->acceleration*dt; 842 // these routines will change the travel movement into zero in a short amout of time, if the player 843 // doesn't press any buttons. 844 if (this->velocity.x >= 0) 845 { 846 if (this->velocity.x > airCoeff*this->acceleration * dt) 847 this->velocity.x -= airCoeff* this->acceleration * dt; 848 else 849 this->velocity.x = 0; 885 850 } 886 851 else 887 852 { 888 this->velocity.x = this->travelSpeed; 889 } 853 if (this->velocity.x < -airCoeff*this->acceleration * dt) 854 this->velocity.x += airCoeff* this->acceleration * dt; 855 else 856 this->velocity.x = 0; 857 } 858 if (this->velocity.z >= 0) 859 { 860 if (this->velocity.z > airCoeff*this->acceleration * dt) 861 this->velocity.z -= airCoeff* this->acceleration * dt; 862 else 863 this->velocity.z = 0; 864 } 865 else 866 { 867 if (this->velocity.z < -airCoeff*this->acceleration * dt) 868 this->velocity.z += airCoeff* this->acceleration * dt; 869 else 870 this->velocity.z = 0; 871 } 872 873 // this will evite, that the ship moves outside the travelDistance- borders,when the player releases all buttons 874 // and its continuing to slide a bit. 875 Vector oldCoor = this->getRelCoor(); 876 if (this->getRelCoor().x > this->travelDistancePlus.x) this->setRelCoor(this->travelDistancePlus.x, oldCoor.y, oldCoor.z); 877 if (this->getRelCoor().x < this->travelDistanceMinus.x) this->setRelCoor(this->travelDistanceMinus.x, oldCoor.y, oldCoor.z); 878 if (this->getRelCoor().z > this->travelDistancePlus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistancePlus.y); 879 if (this->getRelCoor().z < this->travelDistanceMinus.y) this->setRelCoor(oldCoor.x, oldCoor.y, this->travelDistanceMinus.y); 880 881 if( this->systemFailure() ) 882 bForward = bBackward = bLeft = bRight = false; 883 884 885 if( this->bForward ) 886 { 887 if(this->getRelCoor().x < this->travelDistancePlus.x) 888 { 889 if (this->velocity.x < this->travelSpeed) 890 { 891 this->velocity.x += (airCoeff + 1.0)*this->acceleration*dt; 892 } 893 else 894 { 895 this->velocity.x = this->travelSpeed; 896 } 897 } 898 else 899 { 900 this->velocity.x = 0.0f; 901 } 902 } 903 904 if( this->bBackward ) 905 { 906 if(this->getRelCoor().x > this->travelDistanceMinus.x) 907 { 908 if (this->velocity.x > -this->travelSpeed) 909 { 910 this->velocity.x -= (airCoeff + 1.0)*this->acceleration*dt; 911 } 912 else 913 { 914 this->velocity.x = -this->travelSpeed; 915 } 916 } 917 else 918 { 919 this->velocity.x = 0.0f; 920 } 921 } 922 923 if( this->bLeft) 924 { 925 if(this->getRelCoor().z > this->travelDistanceMinus.y) 926 { 927 if (this->velocity.z > -this->travelSpeed) 928 { 929 this->velocity.z -= (airCoeff + 1.0)*this->acceleration*dt; 930 } 931 else 932 { 933 this->velocity.z = -this->travelSpeed; 934 } 935 } 936 else 937 { 938 this->velocity.z = 0.0f; 939 } 940 this->setRelDirSoft(Quaternion(-pi/6, Vector(1,0,0)), 3); 941 } 942 943 if( this->bRight) 944 { 945 if(this->getRelCoor().z < this->travelDistancePlus.y) 946 { 947 if (this->velocity.z < this->travelSpeed) 948 { 949 this->velocity.z += (airCoeff + 1.0)*this->acceleration*dt; 950 } 951 else 952 { 953 this->velocity.z = this->travelSpeed; 954 } 955 } 956 else 957 { 958 this->velocity.z = 0.0f; 959 } 960 this->setRelDirSoft(Quaternion(pi/6, Vector(1,0,0)), 3); 961 } 962 if (!this->bRight && !this->bLeft) 963 { 964 this->setRelDirSoft(Quaternion(0, Vector(1,0,0)), 3); 965 } 966 967 this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0)); 968 this->shiftCoor (this->velocity * dt); 969 970 971 break; 890 972 } 891 else973 case Playable::Vertical: 892 974 { 893 this->velocity.x = 0.0f;975 break; 894 976 } 895 }896 897 if( this->bBackward )898 {899 if(this->getRelCoor().x > this->travelDistanceMinus.x)900 {901 if (this->velocity.x > -this->travelSpeed)902 {903 this->velocity.x -= (airCoeff + 1.0)*this->acceleration*dt;904 }905 else906 {907 this->velocity.x = -this->travelSpeed;908 }909 }910 else911 {912 this->velocity.x = 0.0f;913 }914 }915 916 if( this->bLeft)917 {918 if(this->getRelCoor().z > this->travelDistanceMinus.y)919 {920 if (this->velocity.z > -this->travelSpeed)921 {922 this->velocity.z -= (airCoeff + 1.0)*this->acceleration*dt;923 }924 else925 {926 this->velocity.z = -this->travelSpeed;927 }928 }929 else930 {931 this->velocity.z = 0.0f;932 }933 }934 935 if( this->bRight)936 {937 if(this->getRelCoor().z < this->travelDistancePlus.y)938 {939 if (this->velocity.z < this->travelSpeed)940 {941 this->velocity.z += (airCoeff + 1.0)*this->acceleration*dt;942 }943 else944 {945 this->velocity.z = this->travelSpeed;946 }947 }948 else949 {950 this->velocity.z = 0.0f;951 }952 }953 954 this->travelNode->shiftCoor(Vector(this->cameraSpeed * dt, 0, 0));955 this->shiftCoor (this->velocity * dt);956 957 float angle = this->velocity.z / travelSpeed * pi / 3;958 if (angle > pi/3) angle = pi/3;959 if (angle < -pi/3) angle = -pi/3;960 this->setRelDirSoft(Quaternion(angle, Vector(1,0,0)), 5.0f);961 962 /*963 switch(this->getPlaymode())964 {965 case Playable::Vertical:966 break;967 977 default: 968 PRINTF(2)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName()); 969 } 970 */ 971 } 972 978 PRINTF(4)("Playmode %s Not Implemented in %s\n", Playable::playmodeToString(this->getPlaymode()).c_str(), this->getClassCName()); 979 } 980 } 981 982 void SpaceShip::setPlaymodeXML(const std::string& playmode) 983 { 984 this->setPlaymode(Playable::stringToPlaymode(playmode)); 985 } 986 -
branches/playability/src/world_entities/space_ships/space_ship.h
r10030 r10032 72 72 73 73 virtual void enterPlaymode(Playable::Playmode playmode); 74 void setPlaymodeXML(const std::string& playmode); 74 75 virtual void movement (float dt); 75 76 … … 77 78 void init(); 78 79 79 void calculateVelocity(float time);80 //void calculateVelocity(float time); 80 81 81 82 void regen(float time); //!< handler for shield and electronic regeneration … … 131 132 bool bAscend; //!< ascend button pressed. 132 133 bool bDescend; //!< descend button presses. 133 // bool bFire; //!< fire button pressed.(moved to playable)134 134 bool bRollL; //!< rolling button pressed (left) 135 135 bool bRollR; //!< rolling button pressed (right) … … 144 144 int controlVelocityY; 145 145 */ 146 // float cycle; //!< hovercycle147 146 148 149 Vector velocity; //!< the velocity of the player. 150 //Vector oldVelocity; //!< the velocity the player had last synced 151 152 147 Vector velocity; //!< the velocity of the player. 153 148 154 149 // 2D-traveling … … 173 168 */ 174 169 175 Quaternion direction; //!< the direction of the ship.170 //Quaternion direction; //!< the direction of the ship. 176 171 float acceleration; //!< the acceleration of the ship. 177 172 //float airFriction; //!< AirFriction.
Note: See TracChangeset
for help on using the changeset viewer.