Changeset 133
- Timestamp:
- Oct 31, 2007, 11:16:00 AM (17 years ago)
- Location:
- code/branches/main_reto
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/main_reto/include/OrxonoxShip.h
r130 r133 3 3 4 4 #include "Ogre.h" 5 #include "Bullet.h" 5 6 6 7 using namespace Ogre; … … 11 12 Vector3 speed; 12 13 float thrust, sideThrust, baseThrust; 14 Vector3 bulletSpeed; 13 15 14 16 OrxonoxShip(SceneManager*, SceneNode*); … … 25 27 Real getThrust(); 26 28 29 Bullet* fire(); 30 27 31 bool tick(unsigned long, float); 28 32 … … 32 36 Entity *mShip; 33 37 38 int n; 39 34 40 }; 35 41 -
code/branches/main_reto/include/RunManager.h
r130 r133 60 60 OIS::JoyStick* mJoy; 61 61 62 bool leftButtonDown; 63 Bullet **mBullets; 64 int mBulletsSize; 65 int mBulletsPosition; 66 62 67 // previously elapsed render time 63 68 unsigned long mTime; -
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)); -
code/branches/main_reto/weapon_framework/weapon_framework.vcproj
r128 r133 184 184 > 185 185 <File 186 RelativePath="..\src\Bullet.cpp" 187 > 188 </File> 189 <File 186 190 RelativePath="..\src\CameraManager.cpp" 187 191 > … … 218 222 > 219 223 <File 224 RelativePath="..\include\Bullet.h" 225 > 226 </File> 227 <File 220 228 RelativePath="..\include\CameraManager.h" 221 229 >
Note: See TracChangeset
for help on using the changeset viewer.