Changeset 133 for code/branches/main_reto/src
- Timestamp:
- Oct 31, 2007, 11:16:00 AM (17 years ago)
- Location:
- code/branches/main_reto/src
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto/src/OrxonoxShip.cpp
r130 r133 3 3 4 4 OrxonoxShip::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) 6 7 { 7 8 } … … 19 20 20 21 // create the "space ship" (currently a fish..) 22 // TODO: names must be unique! 21 23 mShip = mSceneMgr->createEntity("Ship", "fish.mesh"); 22 24 SceneNode *fishNode = mRootNode->createChildSceneNode("fishNode"); … … 59 61 } 60 62 63 Bullet* 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 } 61 75 62 76 bool OrxonoxShip::tick(unsigned long time, float deltaTime) -
code/branches/main_reto/src/RunManager.cpp
r130 r133 5 5 RunManager::RunManager(OgreControl * mOgre, bool bufferedKeys, bool bufferedMouse, 6 6 bool bufferedJoy ) : 7 mOgre(mOgre), mWindow(mOgre->getRenderWindow()), 7 mOgre(mOgre), mWindow(mOgre->getRenderWindow()), leftButtonDown(false), 8 8 mStatsOn(true), mNumScreenShots(0), 9 9 mTimeUntilNextToggle(0), mFiltering(TFO_BILINEAR), … … 35 35 // Set default mipmap level (NB some APIs ignore this) 36 36 TextureManager::getSingleton().setDefaultNumMipmaps(5); 37 38 // initialise bullets list 39 mBullets = new Bullet*[10]; 40 mBulletsPosition = 0; 41 mBulletsSize = 10; 37 42 38 43 using namespace OIS; … … 79 84 if (mScene) 80 85 delete mScene; 86 87 for (int i = 0; i < mBulletsPosition; i++) 88 delete mBullets[i]; 89 delete mBullets; 81 90 } 82 91 … … 91 100 mScene->tick(time, deltaTime); 92 101 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 } 93 110 94 111 using namespace OIS; … … 257 274 const MouseState &ms = mMouse->getMouseState(); 258 275 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 259 297 mShip->setYaw(Degree(-ms.X.rel * 0.13)); 260 298 mShip->setPitch(Degree(-ms.Y.rel * 0.13));
Note: See TracChangeset
for help on using the changeset viewer.