Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 11908


Ignore:
Timestamp:
Apr 26, 2018, 3:22:59 PM (6 years ago)
Author:
jacobsr
Message:

changed controlls

Location:
code/branches/OrxyRoad_FS18/src/modules/orxyroad
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.cc

    r11899 r11908  
    5151        lastTimeLeft = 0;
    5252        lastTime = 0;
     53        steeredLeft = false;
     54        steeredRight = false;
     55        forward = false;
     56        backward = false;
    5357    }
    5458
    5559    void OrxyRoadShip::tick(float dt)
    5660    {
    57         orxout(user_info) << "This is some cool output!" << endl;
     61        //orxout(user_info) << "This is some cool output!" << endl;
    5862
    5963        Vector3 pos = getPosition();
     64        Vector3 pos1 = getPosition();
    6065
    6166        //Movement calculation
     
    6469        lastTime += dt;
    6570
    66         velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
    67         velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
     71       
     72        //velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
     73        //velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
    6874
    6975        //Execute movement
     76       
    7077        if (this->hasLocalController())
    7178        {
    7279            float dist_y = velocity.y * dt;
     80            //forward backwards movement
     81            if(forward){
     82                if(velocity.y < 200){// Limit for max velocity
     83                    velocity.y += 10;
     84                }
     85               
     86
     87            }else if(backward){
     88                if(velocity.y > 10){
     89                     velocity.y -= 10;
     90                }else {
     91                    velocity.y = 0; // Prevent players from going backwards
     92                }
     93                         
     94            }else {
     95                velocity.y = 0.9 * velocity.y;//reduce speed
     96            }
     97
     98
     99
     100
    73101            //float dist_x = velocity.x * dt;
    74             if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
    75                 posforeward += dist_y;
    76             else
    77             {
    78                 velocity.y = 0;
     102            //if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
     103              //  posforeward += dist_y;
     104            //else
     105            //{
     106                //velocity.y = 0;
    79107                // restart if game ended
    80108/*
     
    85113                        return;
    86114                    }*/
     115            //}
     116
     117            //Left right steering
     118
     119
     120            if(steeredLeft){
     121                velocity.x += 100;
     122                steeredLeft = false;
     123
     124            }else if(steeredRight) {
     125                velocity.x += -100;
     126                steeredRight = false;
     127            }else {
     128                if(velocity.x < -2 || velocity.x > 2 ){
     129                    velocity.x  = velocity.x *0.9;
     130                }else{
     131                    velocity.x += 0;
     132                }
     133               
    87134            }
    88135
    89             pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
    90         }
     136            pos += Vector3(velocity.y, 0, velocity.x) * dt;
     137           
     138        }
     139
    91140
    92141
     
    95144        if (camera != nullptr)
    96145        {
    97             // camera->setPosition(Vector3(-pos.z, -posforeward, 0));
    98             camera->setOrientation(Vector3::UNIT_Z, Degree(0));
     146            //camera->setPosition(Vector3(pos1.x - 10 ,50,0));
     147            //camera->setOrientation(Vector3(-1,-1,0), Degree(45));
     148            //camera->setOrientation(Vector3(-1,-1,-1), Degree(0));
     149           camera->setOrientation(Vector3::UNIT_Z, Degree(0));
    99150        }
    100151
     
    129180    void OrxyRoadShip::moveFrontBack(const Vector2& value)
    130181    {
     182        this->steering_.z -= value.x ;
     183        if(value.x > 0){
     184            forward  = true;
     185            backward = false;
     186        }else if(value.x < 0){
     187            forward = false;
     188            backward = true;
     189        }
     190       
    131191        //lastTimeFront = 0;
    132192        //desiredVelocity.y = value.y * speed * 42;
     
    136196    void OrxyRoadShip::moveRightLeft(const Vector2& value)
    137197    {
    138         lastTimeLeft = 0;
    139         desiredVelocity.x = value.x * speed;
     198        this->steering_.x += value.x;
     199        if(value.x==-1){
     200            steeredLeft = false;
     201            steeredRight = true;       
     202            orxout(user_info) << "Steering RIGHT "<<steering_.x << endl;
     203        }else {
     204            steeredRight = false;
     205            steeredLeft = true;
     206             orxout(user_info) << "Steering LEFT "<<steering_.x << endl;
     207
     208        }
     209       
     210
     211        //lastTimeLeft = 0;
     212        //desiredVelocity.x = value.x * speed;
    140213    }
    141214    void OrxyRoadShip::boost(bool bBoost)
    142215    {
    143         //getGame()->bEndGame = bBoost;
     216        //bool boosting = bBoost;
    144217    }
    145218
  • code/branches/OrxyRoad_FS18/src/modules/orxyroad/OrxyRoadShip.h

    r11891 r11908  
    7474            float speed, damping, posforeward;
    7575            bool isFireing;
     76            bool steeredLeft, steeredRight, forward, backward;
    7677
    7778        protected:
Note: See TracChangeset for help on using the changeset viewer.