Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 133 for code/branches


Ignore:
Timestamp:
Oct 31, 2007, 11:16:00 AM (16 years ago)
Author:
rgrieder
Message:
 
Location:
code/branches/main_reto
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/main_reto/include/OrxonoxShip.h

    r130 r133  
    33
    44#include "Ogre.h"
     5#include "Bullet.h"
    56
    67using namespace Ogre;
     
    1112        Vector3 speed;
    1213        float thrust, sideThrust, baseThrust;
     14        Vector3 bulletSpeed;
    1315
    1416        OrxonoxShip(SceneManager*, SceneNode*);
     
    2527        Real getThrust();
    2628
     29        Bullet* fire();
     30
    2731        bool tick(unsigned long, float);
    2832
     
    3236        Entity *mShip;
    3337
     38        int n;
     39
    3440};
    3541
  • code/branches/main_reto/include/RunManager.h

    r130 r133  
    6060        OIS::JoyStick* mJoy;
    6161
     62        bool leftButtonDown;
     63        Bullet **mBullets;
     64        int mBulletsSize;
     65        int mBulletsPosition;
     66
    6267        // previously elapsed render time
    6368        unsigned long mTime;
  • code/branches/main_reto/src/OrxonoxShip.cpp

    r130 r133  
    33
    44OrxonoxShip::OrxonoxShip(SceneManager *mSceneMgr, SceneNode *mNode)
    5         : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(100), thrust(0), sideThrust(0)
     5        : mSceneMgr(mSceneMgr), mRootNode(mNode), speed(Vector3(0, 0, 0)), baseThrust(100), thrust(0), sideThrust(0), n(0),
     6        bulletSpeed(400)
    67{
    78}
     
    1920
    2021        // create the "space ship" (currently a fish..)
     22        // TODO: names must be unique!
    2123        mShip = mSceneMgr->createEntity("Ship", "fish.mesh");
    2224        SceneNode *fishNode = mRootNode->createChildSceneNode("fishNode");
     
    5961}
    6062
     63Bullet* OrxonoxShip::fire()
     64{
     65        // TODO: Names must be unique!
     66        SceneNode *temp = mRootNode->getParentSceneNode()->createChildSceneNode("BulletNode" + StringConverter::toString(n));
     67        temp->setOrientation(mRootNode->getOrientation());
     68        temp->setPosition(mRootNode->getPosition());
     69        temp->setScale(Vector3(1, 1, 1) * 10);
     70        temp->yaw(Degree(-90));
     71        return new Bullet(temp,
     72                mSceneMgr->createEntity("bullet" + StringConverter::toString(n++), "Barrel.mesh"),
     73                speed + (mRootNode->getLocalAxes() * Vector3(0, 0, -1)).normalisedCopy() * bulletSpeed);
     74}
    6175
    6276bool OrxonoxShip::tick(unsigned long time, float deltaTime)
  • code/branches/main_reto/src/RunManager.cpp

    r130 r133  
    55RunManager::RunManager(OgreControl * mOgre, bool bufferedKeys, bool bufferedMouse,
    66                                           bool bufferedJoy ) :
    7 mOgre(mOgre), mWindow(mOgre->getRenderWindow()),
     7mOgre(mOgre), mWindow(mOgre->getRenderWindow()), leftButtonDown(false),
    88mStatsOn(true), mNumScreenShots(0),
    99mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR),
     
    3535        // Set default mipmap level (NB some APIs ignore this)
    3636        TextureManager::getSingleton().setDefaultNumMipmaps(5);
     37
     38        // initialise bullets list
     39        mBullets = new Bullet*[10];
     40        mBulletsPosition = 0;
     41        mBulletsSize = 10;
    3742
    3843        using namespace OIS;
     
    7984        if (mScene)
    8085                delete mScene;
     86
     87        for (int i = 0; i < mBulletsPosition; i++)
     88                delete mBullets[i];
     89        delete mBullets;
    8190}
    8291
     
    91100        mScene->tick(time, deltaTime);
    92101        mShip->tick(time, deltaTime);
     102
     103        // update the bullet positions
     104        for (int i = 0; i < mBulletsPosition; i++)
     105        {
     106                mBullets[i]->mNode->translate(mBullets[i]->mSpeed*deltaTime);
     107                mBullets[i]->mNode->yaw(Degree(deltaTime*100));
     108                mBullets[i]->mNode->roll(Degree(deltaTime*300));
     109        }
    93110
    94111        using namespace OIS;
     
    257274        const MouseState &ms = mMouse->getMouseState();
    258275
     276        if (ms.buttonDown(MB_Left) && !leftButtonDown)
     277        {
     278                leftButtonDown = true;
     279                // fire
     280                Bullet *mTempBullet = mShip->fire();
     281                if (mBulletsPosition >= mBulletsSize)
     282                {
     283                        // redimension the array
     284                        Bullet **mTempArray = new Bullet*[2*mBulletsSize];
     285                        for (int i = 0; i < mBulletsSize; i++)
     286                                mTempArray[i] = mBullets[i];
     287                        mBulletsSize *= 2;
     288                        delete mBullets;
     289                        mBullets = mTempArray;
     290                }
     291                mBullets[mBulletsPosition++] = mTempBullet;
     292
     293        }
     294        else if (!ms.buttons)
     295                leftButtonDown = false;
     296
    259297        mShip->setYaw(Degree(-ms.X.rel * 0.13));
    260298        mShip->setPitch(Degree(-ms.Y.rel * 0.13));
  • code/branches/main_reto/weapon_framework/weapon_framework.vcproj

    r128 r133  
    184184                        >
    185185                        <File
     186                                RelativePath="..\src\Bullet.cpp"
     187                                >
     188                        </File>
     189                        <File
    186190                                RelativePath="..\src\CameraManager.cpp"
    187191                                >
     
    218222                        >
    219223                        <File
     224                                RelativePath="..\include\Bullet.h"
     225                                >
     226                        </File>
     227                        <File
    220228                                RelativePath="..\include\CameraManager.h"
    221229                                >
Note: See TracChangeset for help on using the changeset viewer.