Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 11, 2014, 12:07:05 PM (10 years ago)
Author:
fvultier
Message:

Neue Platformen werden zur Laufzeit hinzugefugt, wenn sich die Ansicht nach oben verschiebt. Eigene Modelle importieren funktioniert.

Location:
code/branches/pickupsFS14
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickupsFS14/data/levels/Jump.oxw

    r10017 r10032  
    5656    </Planet>
    5757
     58    <MovableEntity
     59      position="0, 0, 500"
     60      scale="5"
     61      collisionType="dynamic"
     62      mass="10000000"
     63    >
     64      <attached>
     65        <Model mesh="Platform01.mesh" />
     66      </attached>
     67    </MovableEntity>
     68
    5869
    5970
     
    6475
    6576    <SpawnPoint team=0 position="0,0,0" lookat="0,0,-1" spawnclass=JumpShip pawndesign=spaceshipjump />
    66 
    67    
    6877
    6978
  • code/branches/pickupsFS14/src/modules/jump/Jump.cc

    r10022 r10032  
    6060    {
    6161        RegisterObject(Jump);
     62        platformList.clear();
     63        yScreenPosition = 0;
     64        screenShiftSinceLastUpdate = 0;
     65
    6266        //this->numberOfBots_ = 0; //sets number of default bots temporarly to 0
    6367        //this->center_ = 0;
    64        // init();
    6568        //this->setHUDTemplate("JumpHUD");
    6669
    67     }
    68 
    69     void Jump::init()
    70     {
    71         /*bEndGame = false;
    72         lives = 3;
    73         level = 1;
    74         point = 0;
    75         bShowLevel = false;
    76         multiplier = 1;
    77         b_combo = false;*/
    78         // spawn enemy every 3.5 seconds
    79         //enemySpawnTimer.setTimer(3.5f, true, createExecutor(createFunctor(&Jump::spawnEnemy, this)));
    80         //comboTimer.setTimer(3.0f, true, createExecutor(createFunctor(&Jump::comboControll, this)));
    81     }
     70
     71    }
     72
    8273
    8374    /*void Jump::levelUp()
     
    10495        if (player == NULL)
    10596        {
    106                 ObjectList<JumpShip>::iterator it;
    107                 it = ObjectList<JumpShip>::begin();
    108                 /*for (ObjectList<JumpShip>::iterator it = ObjectList<JumpShip>::begin(); it != ObjectList<JumpShip>::end(); ++it)
     97                for (ObjectList<JumpShip>::iterator it = ObjectList<JumpShip>::begin(); it != ObjectList<JumpShip>::end(); ++it)
    10998                {
    11099                player = *it;
    111                 }*/
     100                }
    112101        }
    113102        return player;
    114103    }
     104
     105    void Jump::tick(float dt)
     106    {
     107
     108
     109        if (getPlayer() != NULL)
     110        {
     111            Vector3 shipPosition = getPlayer()->getPosition();
     112
     113                // Bildschirmposition kann nur nach oben verschoben werden
     114                if (shipPosition.y > yScreenPosition)
     115                {
     116                        screenShiftSinceLastUpdate += shipPosition.y - yScreenPosition;
     117
     118                        yScreenPosition = shipPosition.y;
     119                }
     120
     121                // Kameraposition nachfuehren
     122                if (camera == NULL)
     123                {
     124                        camera = getPlayer()->getCamera();
     125                }
     126            if (camera != NULL)
     127            {
     128                camera->setPosition(Vector3(-shipPosition.x, yScreenPosition-shipPosition.y, 100));
     129                //camera->setOrientation(Vector3::UNIT_Z, Degree(180));
     130            }
     131
     132            if (screenShiftSinceLastUpdate > 200.0)
     133            {
     134                screenShiftSinceLastUpdate -= 200.0;
     135                orxout() << "new section added" << endl;
     136                addPlatform(shipPosition.x, shipPosition.y + 300.0);
     137            }
     138
     139        }
     140
     141        SUPER(Jump, tick, dt);
     142    }
     143
    115144
    116145    /*void Jump::spawnEnemy()
     
    158187    }*/
    159188
    160     /*void Jump::start()
    161     {
    162         init();
     189
     190    void Jump::start()
     191    {
     192        // Call start for the parent class.
     193        Deathmatch::start();
     194
     195        /*
    163196        // Set variable to temporarily force the player to spawn.
    164197        this->bForceSpawn_ = true;
     
    170203            return;
    171204        }
    172         // Call start for the parent class.
    173         Deathmatch::start();
    174     }*/
     205        */
     206
     207        //addPlatform(0,0);
     208
     209    }
     210
    175211
    176212    /*void Jump::addPoints(int numPoints)
     
    191227        GSLevel::startMainMenu();
    192228    }*/
     229
     230    void Jump::addPlatform(float xPosition, float yPosition)
     231    {
     232                JumpPlatform* newPlatform = new JumpPlatform(center_->getContext());
     233                newPlatform->setPosition(Vector3(xPosition, yPosition, 0));
     234                platformList.push_front(newPlatform);
     235    }
     236
    193237}
  • code/branches/pickupsFS14/src/modules/jump/Jump.h

    r10022 r10032  
    4141#include "tools/Timer.h"
    4242#include "JumpPlatform.h"
     43#include <list>
     44
    4345
    4446namespace orxonox
     
    4951        public:
    5052            Jump(Context* context);
    51 
    52             //virtual void start();
     53            virtual void start();
    5354            //virtual void end();
    5455            //virtual void addBots(unsigned int amount){} //<! overwrite function in order to bypass the addbots command
     56
     57            virtual void tick(float dt);
    5558
    5659            //void spawnEnemy();
    5760
    5861            void setCenterpoint(JumpCenterPoint* center){ this->center_ = center; }
     62
     63            virtual void addPlatform(float x, float y);
    5964
    6065           /*int getLives(){return this->lives;}
     
    6873            // checks if multiplier should be reset.
    6974            void comboControll();*/
    70             void init();
    7175            //int lives;
    7276            //int multiplier;
     
    7882            WeakPtr<JumpCenterPoint> center_;
    7983            WeakPtr<JumpShip> player;
     84            WeakPtr<Camera> camera;
    8085
    8186            /*Timer enemySpawnTimer;
     
    8691            int point;
    8792            bool b_combo;*/
     93            std::list<JumpPlatform*> platformList;
     94            float yScreenPosition;
     95            float screenShiftSinceLastUpdate;
    8896    };
    8997}
  • code/branches/pickupsFS14/src/modules/jump/JumpPlatform.cc

    r10022 r10032  
    5151        model = new Model(getContext());
    5252        model->setSyncMode(0);
    53         model->setMeshSource("drone.mesh");
     53        model->setMeshSource("Platform01.mesh");
    5454
    55         movableEntity = new MovableEntity(getContext());
    56         movableEntity->attach(model);
    57 
    58         movableEntity->setScale(100);
    59         //movableEntity->setPosition(Vector3(0,0,0));
    60         //movableEntity->setVelocity(Vector3(0,0,1));
    61 
     55        attach(model);
     56        setScale(5);
     57        setPosition(Vector3(0,0,0));
     58        setVelocity(Vector3(0,0,0));
    6259
    6360    }
    6461
     62    void JumpPlatform::tick(float dt)
     63    {
     64        //setAngularVelocity(getAngularVelocity() + Vector3(0.05,0,0));
     65        /*Vector3 movement(0,0,0);
     66        Vector3 shipPosition = getPosition();*/
    6567
    6668
    6769
     70        SUPER(JumpPlatform, tick, dt);
     71    }
     72
     73
    6874}
  • code/branches/pickupsFS14/src/modules/jump/JumpPlatform.h

    r10022 r10032  
    4545        public:
    4646            JumpPlatform(Context* context);
    47 
     47            virtual void tick(float dt);
    4848
    4949        private:
    5050            Model* model;
    51             MovableEntity* movableEntity;
    52 
    5351    };
    5452}
  • code/branches/pickupsFS14/src/modules/jump/JumpPrereqs.h

    r10005 r10032  
    7171    class JumpCenterPoint;
    7272    class JumpShip;
     73    class JumpPlatform;
    7374    class JumpEnemy;
    7475    class JumpEnemyShooter;
  • code/branches/pickupsFS14/src/modules/jump/JumpShip.cc

    r10022 r10032  
    5353        upPressed = false;
    5454        downPressed = false;
    55 
    56         yScreenPosition = 0;
    5755        yVelocity = 0;
    5856    }
     
    6058    void JumpShip::tick(float dt)
    6159    {
     60
     61
    6262        Vector3 movement(0,0,0);
    6363        Vector3 shipPosition = getPosition();
    64 
    65         /*
    66         //Movement calculation
    67         lastTimeFront += dt * damping;
    68         lastTimeLeft += dt * damping;
    69         lastTime += dt;
    70 
    71         velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f);
    72         velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f);
    73 
    74         //Execute movement
    75         if (this->hasLocalController())
    76         {
    77             float dist_y = velocity.y * dt;
    78             float dist_x = velocity.x * dt;
    79             if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
    80                 posforeward += dist_y;
    81             else
    82             {
    83                 velocity.y = 0;
    84                 // restart if game ended
    85                 if (getGame())
    86                     if (getGame()->bEndGame)
    87                     {
    88                         getGame()->start();
    89                         return;
    90                     }
    91             }
    92             if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
    93                 velocity.x = 0;
    94             pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
    95 
    96         }
    97 
    98         // shoot!
    99         if (isFireing)
    100             ControllableEntity::fire(0);
    101                 */
    102         // Camera
    103 
    104 
    105 
    106 
    107             /*
    108         // bring back on track!
    109         if(pos.y != 0)
    110             pos.y = 0;
    111 
    112         setPosition(pos);
    113         setOrientation(Vector3::UNIT_Y, Degree(270));
    114 
    115         // Level up!
    116         if (pos.x > 42000)
    117         {
    118             updateLevel();
    119             setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
    120         }
    121         */
    12264
    12365        // Berechne Bewegung anhand der Eingabe
     
    14183        else if (downPressed == true)
    14284        {
    143                 platform = new JumpPlatform(getContext());
    144                 platform->setPosition(Vector3(0, 0, 0));
    145                 platform->setVelocity(Vector3(0, 0, 0));
    146                 platform->setScale(100);
    147 
    14885                movement -= Vector3(0, 0, 0);
    14986                downPressed = false;
     
    16299        setPosition(shipPosition);
    163100
    164         // Bildschirmposition kann nur nach oben verschoben werden
    165         if (shipPosition.y > yScreenPosition)
    166         {
    167                 yScreenPosition = shipPosition.y;
    168         }
    169 
    170         // Kameraposition nachfuehren
    171         if (camera == NULL)
    172         {
    173                 camera = getCamera();
    174         }
    175         if (camera != NULL)
    176         {
    177 
    178             camera->setPosition(Vector3(-shipPosition.x, yScreenPosition-shipPosition.y, 100));
    179             //camera->setOrientation(Vector3::UNIT_Z, Degree(180));
    180         }
    181 
    182         SUPER(JumpShip, tick, dt);
     101        SUPER(JumpShip, tick, dt);
    183102    }
    184103/*
  • code/branches/pickupsFS14/src/modules/jump/JumpShip.h

    r10022 r10032  
    7373            WeakPtr<Jump> getGame();
    7474            WeakPtr<Jump> game;
    75             WeakPtr<Camera> camera;
    7675            const float xVelocity = 150.0f;
    7776            const float xBoundary = 200.0f;
     
    10099            bool downPressed;
    101100
    102             float yScreenPosition;
    103101            float yVelocity;
    104102            const float yAcceleration = 10.0f;
    105103            const float ySpeedAfterJump = 300.0f;
    106 
    107             JumpPlatform* platform;
    108104    };
    109105}
Note: See TracChangeset for help on using the changeset viewer.