Player::Player(Graphics &graphics, float x, float y): AnimatedSprite(graphics, "content/sprites/MyChar.png",0,0,16,16, x,y,100){ graphics.loadImage("content/sprites/MyChar.png"); setupAnimations(); playAnimation("RunRight"); }
bool Scene::load(const ofBuffer& buffer, bool optimize, Handedness handness, const char* extension) { unload(); unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality; if (optimize) { flags |= aiProcess_ImproveCacheLocality | aiProcess_JoinIdenticalVertices | aiProcess_RemoveRedundantMaterials; } if (handness == LEFT_HANDED) { flags |= aiProcess_ConvertToLeftHanded; } scene = aiImportFileFromMemory(buffer.getBinaryBuffer(), buffer.size(), flags, extension); string err_str = aiGetErrorString(); if (!err_str.empty()) { ofLogError("ofxAssimp::Scene::load") << err_str; } assert(scene); setupResources(); setupNodes(); setupAnimations(); return true; }
Player::Player() { _currentAmmo = 2; _currentScore = 0; _kills = 0; _streaks = 0; initPlayerGUI(); setupAnimations(); }
Animation::Animation(string mon, int a, int startPlace, int nextPlace){ this->mon = mon; this->ani = a; this->drawn = 1; this->done = false; this->frame = 0; this->frameRate = 150; this->startp = Point(-1.25 + startPlace, -5.0); this->nextp = Point(-1.25 + nextPlace, -5.0); setupAnimations(); }
Player::Player( SceneManager* mSceneMgr, Camera * cam, PhysicsWorld* mPhysicsWorld ) { this->mSceneMgr = mSceneMgr; this->mPhysicsWorld = mPhysicsWorld; this->mCamera = cam; mPlayerShape = new PlayerPhysics( 300 ); mMoveSpeed = 90000.0f; mTranslateVector = Ogre::Vector3::ZERO; mPlayerNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("playerNode"); mYawNode = mPlayerNode->createChildSceneNode("YawNode"); mPitchNode = mYawNode->createChildSceneNode("PitchNode"); mRollNode = mPitchNode->createChildSceneNode("RollNode"); mCamera->setPosition(Vector3(-14, 4, 55)); mPlayerNode->setPosition(mCamera->getPosition()); mPlayerNode->setOrientation(mCamera->getOrientation()); makePlayer(); mHealth = 100; numOfBullet = 30; mMissileTimer.reset(); mJumpTimer.reset(); mAir = false; mFireFlash = new FireFlash(mSceneMgr); setupAnimations(); effectChannel[0] = INVALID_SOUND_CHANNEL; effectChannel[1] = INVALID_SOUND_CHANNEL; soundMgr = new SoundManager(); soundMgr->Initialize(); fireEffect = soundMgr->CreateSound(String("FIRE.wav")); reloadEffect = soundMgr->CreateSound(String("RELOAD.mp3")); channel[0] = soundMgr->GetSoundChannel(effectChannel[0]); channel[1] = soundMgr->GetSoundChannel(effectChannel[1]); mNegativeYRayhit = new Rayhit(); mNegativeYRayhit->node = mPlayerNode; mNegativeYRayhit->squaredDistance = 0.0; mNegativeZRayhit = new Rayhit(); mNegativeZRayhit->node = mPlayerNode; mNegativeZRayhit->squaredDistance = 0.0; }
PlayerCharacter::PlayerCharacter(Ogre::String name, Ogre::SceneManager *sceneMgr, GameContext* gameContext) { // Setup basic member references mName_ = name; mSceneMgr_ = sceneMgr; mGameContext = gameContext; // Setup basic node structure to handle 3rd person cameras mMainNode_ = mSceneMgr_->getRootSceneNode ()->createChildSceneNode (mName_, Ogre::Vector3 (0, 1000, 0)); mCharacterNode_ = mMainNode_->createChildSceneNode (mName_ + "_character", Ogre::Vector3 (0, 0, 0)); mSightNode_ = mMainNode_->createChildSceneNode (mName_ + "_sight", Ogre::Vector3 (0, 8, 0)); mCameraNode_ = mMainNode_->createChildSceneNode (mName_ + "_camera", Ogre::Vector3 (0, 0, 0)); //Set the orientation of the camera system mGameContext->getCameraControl()->updateOrientation(mMainNode_->getOrientation()); // Give this character a shape :) mEntity_ = mSceneMgr_->createEntity (mName_, "Stickman.mesh"); mCharacterNode_->attachObject (mEntity_); mCharacterNode_->scale(1.0f, 1.0f, 1.0f); mEntity_->setMaterialName("Examples/Robot"); mSword1 = sceneMgr->createEntity("SinbadSword1", "Sword.mesh"); mSword2 = sceneMgr->createEntity("SinbadSword2", "Sword.mesh"); mEntity_->attachObjectToBone("Sheat.L", mSword1); mEntity_->attachObjectToBone("Sheat.R", mSword2); mEntity_->setCastShadows(true); mVerticalVelocity = 0; isJumping_ = false; isRunning_ = false; mDropVelocityIncrement = 80.0f; mCurrentDropVelocity = 0.0f; mCharacterMoveSpeed = 30.0f; mRotationSpeedModificator = Ogre::Radian(1.0f); mTargetYaw = Ogre::Radian(0.0f); setupAnimations(); }