GameEntity::GameEntity(): walk_velocity_(10.0), jump_velocity_(160.0), // TODO send to constructor
                          direction_(1.0),
                          position_(0.0, 0.0), velocity_(0.0, 0.0),
                          state_(&AState::standing_state), // TODO should not be static
                          animations_(),
                          frame_data_component_(),
                          inputs_component_(),
                          physics_component_(),
                          graphics_component_() {
  animations_[0] = Animation();
  animations_[1] = Animation();
  animations_[2] = Animation();
}
Esempio n. 2
0
Animation AnimationList::operator[](unsigned int index){
    try{
        if(index > anims.size() - 1)
            throw 0;
        else{
            return Animation(anims[index]);
        }
    }
    catch(int){
        std::cerr << "Can't access AnimationList[" << index << "], returning AnimationList[0]." << std::endl;
        return Animation(anims[0]);
    }
}
void BoardActor::initAnimations(){
	animations.clear();
	animations.push_back(Animation());
	animations.push_back(Animation());

	animations[0].addFrame(Frame(Coordinate2D<double>(.25,0), Coordinate2D<double>(.5,1), .04)); //idle
	animations[0].addFrame(Frame(Coordinate2D<double>(.75,0), Coordinate2D<double>(1,1), .04)); //idle
	animations[1].addFrame(Frame(Coordinate2D<double>(0,0), Coordinate2D<double>(.25,1), .04)); //moving
	animations[1].addFrame(Frame(Coordinate2D<double>(.5,0), Coordinate2D<double>(.75,1), .04)); //moving

	spriteSheet = BlitHelper::loadImageGL("C:\\Users\\banan\\workspace\\SpaghettiWestern\\Resources\\adude.bmp");

	active_animation = 0;
}
Esempio n. 4
0
	Obj::Obj(nl::node src)
	{
		animation = Animation(nl::nx::map["Obj"][src["oS"] + ".img"][src["l0"]][src["l1"]][src["l2"]]);
		pos = Point<int16_t>(src["x"], src["y"]);
		flip = src["f"].get_bool();
		z = src["z"];
	}
Esempio n. 5
0
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
//	Name        : 更新
//	Description : いろんな更新
//	Arguments   : ないよ
//	Returns     : ないよ
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
void CFlower::Update()
{	

	switch(m_nPhase)
	{
	case FLOWER_PHASE_INIT:
		m_lastTime = CTimer::GetTime();
		m_nPhase++;
		break;
	case FLOWER_PHASE_START:
		RotationZ((float)(m_nowTime - m_lastTime) * m_rotSpd);
		m_nowTime = CTimer::GetTime();
		if(m_nowTime - m_lastTime > abs(m_rotSpd)){
			m_nPhase = FLOWER_PHASE_FLOWER;
		}
		break;
	case FLOWER_PHASE_FLOWER:
		RotationZ(m_rotSpd * abs(m_rotSpd));
		break;
	case FLOWER_PHASE_WAIT:
		RotationZ(m_rotSpd);
		break;
	case FLOWER_PHASE_UNINIT:
		break;
	}

	Translate(m_pos);

	Animation();

}
Esempio n. 6
0
void Bear::Update(float _Time, int** _Terrain,float _MaxWidth,float _MaxHeight)
{
	if(getLife() == false)
	{
		int random ;
		random = rand() % 4 ;
		switch(random)
		{
		case  0 :
			Item *_item = new Item(m_X,m_Y);
			ManagerObject::Instance()->getListItem()->push_back(_item);
			break ;

		}
		EffectDieBear *_EffectDie = new EffectDieBear(this,m_X,m_Y);
		ManagerObject ::Instance()->getListEffect()->push_back(_EffectDie);
	}
	if(m_skillManager->getSkill(0)->getSTT()==ACTIVE)
	{
		m_skillManager->Update(_Time,_Terrain,_MaxWidth,_MaxHeight);
	}
	else if(m_skillManager->getSkill(0)->getSTT() !=ACTIVE)
	{
		if(getFrenzy() ==false)
		{
			Move(_Time,_Terrain,_MaxWidth,_MaxHeight);	
		}
		Animation(_Time);
		UpdateStatus(_Time);
		m_skillManager->Update(_Time,_Terrain,_MaxWidth,_MaxHeight); //??
	}
}
Esempio n. 7
0
	//-----------------------------------------------------------------------
	Animation* Animation::clone(const String& newName) const
	{
		Animation* newAnim = OGRE_NEW Animation(newName, mLength);
        newAnim->mInterpolationMode = mInterpolationMode;
        newAnim->mRotationInterpolationMode = mRotationInterpolationMode;
		
		// Clone all tracks
		for (NodeTrackList::const_iterator i = mNodeTrackList.begin();
			i != mNodeTrackList.end(); ++i)
		{
			i->second->_clone(newAnim);
		}
		for (NumericTrackList::const_iterator i = mNumericTrackList.begin();
			i != mNumericTrackList.end(); ++i)
		{
			i->second->_clone(newAnim);
		}
		for (VertexTrackList::const_iterator i = mVertexTrackList.begin();
			i != mVertexTrackList.end(); ++i)
		{
			i->second->_clone(newAnim);
		}

        newAnim->_keyFrameListChanged();
		return newAnim;

	}
Esempio n. 8
0
//-----------------------------------------------------------------------------
// Exports mstudioanimdesc_t.
//-----------------------------------------------------------------------------
void export_animation(scope _studio)
{
    class_<mstudioanimdesc_t, mstudioanimdesc_t *, boost::noncopyable> Animation("Animation");

    // Properties...
    Animation.add_property("model_header", make_function(&mstudioanimdesc_t::pStudiohdr, reference_existing_object_policy()));
    Animation.add_property("name", &AnimationExt::get_name);

    Animation.def_readwrite("flags", &mstudioanimdesc_t::flags);
    Animation.def_readwrite("frames_count", &mstudioanimdesc_t::numframes);
    Animation.def_readwrite("movements_count", &mstudioanimdesc_t::nummovements);
    Animation.def_readwrite("movements_offset", &mstudioanimdesc_t::movementindex);
    Animation.def_readwrite("anim_block", &mstudioanimdesc_t::animblock);
    Animation.def_readwrite("anim_offset", &mstudioanimdesc_t::animindex);
    Animation.def_readwrite("local_hierarchy_count", &mstudioanimdesc_t::numlocalhierarchy);
    Animation.def_readwrite("local_hierarchy_offset", &mstudioanimdesc_t::localhierarchyindex);
    Animation.def_readwrite("section_offset", &mstudioanimdesc_t::sectionindex);
    Animation.def_readwrite("section_frames", &mstudioanimdesc_t::sectionframes);
    Animation.def_readwrite("zero_frame_span", &mstudioanimdesc_t::zeroframespan);
    Animation.def_readwrite("zero_frame_count", &mstudioanimdesc_t::zeroframecount);
    Animation.def_readwrite("zero_frame_index", &mstudioanimdesc_t::zeroframeindex);
    Animation.def_readwrite("zero_frame_stall_time", &mstudioanimdesc_t::zeroframestalltime);

    // Methods...
    Animation.def("get_movement", &AnimationExt::get_movement, reference_existing_object_policy());
    // Animation.def("get_hierarchy", &mstudioanimdesc_t::pHierarchy, reference_existing_object_policy());

    // Add memory tools...
    Animation ADD_MEM_TOOLS(mstudioanimdesc_t);
}
Esempio n. 9
0
void myCam::queueAnimation(QVector3D ziel, QVector3D zielLookat, int duration)
{
    Animation aniNew = Animation(ziel,zielLookat,duration);
    this->animations.push_back(aniNew);
	if (!this->isMoving)
		this->nextAnimation();
		
}
Esempio n. 10
0
bool CSprite::DrawFinalize( )
{
	// アニメーション行うときは、こいつを実行
	Animation( );

//	m_DispObj->SetBlendColor(0);
	return TRUE;
}
Esempio n. 11
0
void Game::loadTiles()
{
	Animation staticAnim(0, 0, 1.0f);
	this->tileAtlas["grass"] =
		Tile(this->tileSize, 1, texmgr.getRef("grass"),
		{ staticAnim },
		TileType::GRASS, 50, 0, 1);

	this->tileAtlas["forest"] =
		Tile(this->tileSize, 1, texmgr.getRef("forest"),
		{ staticAnim },
		TileType::FOREST, 100, 0, 1);

	this->tileAtlas["water"] =
		Tile(this->tileSize, 1, texmgr.getRef("water"),
		{ Animation(0, 3, 0.5f),
		Animation(0, 3, 0.5f), 
		Animation(0, 3, 0.5f) },
		TileType::WATER, 0, 0, 1);

	this->tileAtlas["residental"] =
		Tile(this->tileSize, 2, texmgr.getRef("residental"),
		{ staticAnim, staticAnim, staticAnim,
		staticAnim, staticAnim, staticAnim },
		TileType::RESIDENTIAL, 300, 50, 6);

	this->tileAtlas["commercial"] =
		Tile(this->tileSize, 2, texmgr.getRef("commercial"),
		{ staticAnim, staticAnim, staticAnim, staticAnim },
		TileType::COMMERCIAL, 300, 50, 4);

	this->tileAtlas["industrial"] =
		Tile(this->tileSize, 2, texmgr.getRef("industrial"),
		{ staticAnim, staticAnim, staticAnim, staticAnim },
		TileType::INDUSTRIAL, 300, 50, 4);

	this->tileAtlas["road"] =
		Tile(this->tileSize, 1, texmgr.getRef("road"),
		{ staticAnim, staticAnim, staticAnim, staticAnim,
		staticAnim, staticAnim, staticAnim, staticAnim, 
		staticAnim, staticAnim, staticAnim },
		TileType::ROAD, 100, 0, 1);

	return;
}
Esempio n. 12
0
VillagerC::VillagerC()
{
	Texture* tex = textureLoader::getTexture("friendly_npcs");
	AnimatedSprite sprite = AnimatedSprite(&tex->texture, 0, 0, tex->cellWidth, tex->cellHeight, 0 * tex->uSize, 5 * tex->vSize, 1 * tex->uSize, 1 * tex->vSize);
	*this = VillagerC((VillagerC&)sprite);
	type = 1;
	name = "villagerC";
	isAnimated = false;

	//Setup Collider
	int xOffset = 18;
	int yOffset = 15;
	int width = 28;
	int height = 45;
	float uSize = 1;
	float vSize = 1;
	colliderXOffset = xOffset;
	colliderYOffset = yOffset;
	setCollider(&AABB(x + xOffset, y + yOffset, width, height));
	maxSpeed = 50;
	isColliderDrawn = false;
	
	// Walking Animation
	int numFrames = 1;
	int timeToNextFrame = 300;
	std::vector<AnimationFrame> frames;
	frames.assign(numFrames, AnimationFrame());

	frames[0] = AnimationFrame(0, 5, uSize, vSize);
	//frames[1] = AnimationFrame(1, 0, uSize, vSize);
	Animation animation_walking = Animation("Walking", frames, numFrames);
	animations[animation_walking.name] = AnimationData(animation_walking, timeToNextFrame, true);

	// Idle Animation
	numFrames = 1;
	frames.clear();
	frames.assign(numFrames, AnimationFrame());

	frames[0] = AnimationFrame(0, 5, uSize, vSize);
	Animation animation_idle = Animation("Idle", frames, numFrames);
	animations[animation_idle.name] = AnimationData(animation_idle, timeToNextFrame, true);

	//setAnimation("Walking");
}
Esempio n. 13
0
AnimationList::AnimationList(bool){
    //std::vector<Frame*> f;
    //f.push_back(frameList[0]);
    //f.push_back(frameList[1]);
    anims.push_back(Animation());
    anims.back().AddFrame(*frameList[0]);
    anims.back().AddFrame(*frameList[1]);
    //anims.back().AddFrame(frameList[0]);
    //anims.back().AddFrame(frameList[1]);
}
Esempio n. 14
0
void Character::onInit()
{
	Game::Object::onInit();

	model.deserialize("model_shiveil.txt");
	initAllModels();


	addCollider(CircleCollider(Vector2D(), 50.f));

	idAnimAtU = addResource(Resource<float>());
	getResource_f(idAnimAtU).resetVelocity = 0.75;
	getResource_f(idAnimAtU).inverseMass = 0.5;

	idAnimAtH = addResource(Resource<float>());
	getResource_f(idAnimAtH).resetVelocity = 0.75;
	getResource_f(idAnimAtH).inverseMass = 0.5;

	setInput("up", Control::Input(sf::Keyboard::W));
	setInput("down", Control::Input(sf::Keyboard::S));
	setInput("left", Control::Input(sf::Keyboard::A));
	setInput("right", Control::Input(sf::Keyboard::D));

	setInput("s1", Control::Input(sf::Mouse::Left));
	setInput("s2", Control::Input(sf::Mouse::Right));


	addAnimation("block", Animation("animBlockShield.txt"));
	addAnimation("atackH", Animation("swordAnim.txt"));
	addAnimation("atackU", Animation("swordAnimPush.txt"));

	// realms
	// position
	getPos().inverseMass = 0.9f;
	getPos().resetVelocity = 0.8f;

	// rotation
	getRot().inverseMass = 0.5;
	getRot().resetVelocity = 0.75f;
	gen.addParticle("particleTest.txt", 250, 1);
	//genSword.addParticle("swordParticle.txt", 50, 0.5);
}
Esempio n. 15
0
void Peacemaker::firesecondary(Gamestate *state)
{
    double spread = (2*(rand()/(RAND_MAX+1.0)) - 1)*25*3.1415/180.0;
    double cosa = std::cos(aimdirection+spread), sina = std::sin(aimdirection+spread);
    double collisionptx, collisionpty;
    EntityPtr target = state->collidelinedamageable(x, y, x+cosa*FALLOFF_END, y+sina*FALLOFF_END, team, &collisionptx, &collisionpty);
    if (target.id != 0)
    {
        double distance = std::hypot(collisionptx-x, collisionpty-y);
        double falloff = 1.0;
        if (distance > FALLOFF_BEGIN)
        {
            falloff = std::max(0.0, (distance-FALLOFF_BEGIN) / (FALLOFF_END-FALLOFF_BEGIN));
        }
        MovingEntity *m = state->get<MovingEntity>(target);
        if (m->entitytype == CHARACTER)
        {
            Character *c = reinterpret_cast<Character*>(m);
            c->damage(state, MAX_FTH_DAMAGE*falloff);
        }
    }

    state->make_entity<Trail>(state, al_premul_rgba(133, 238, 238, 150), x+cosa*24, y+sina*24, collisionptx, collisionpty, 0.1);
    Explosion *e = state->get<Explosion>(state->make_entity<Explosion>(state, "heroes/mccree/projectiletrail/", aimdirection+spread));
    e->x = x+cosa*24;
    e->y = y+sina*24;

    --clip;

    if (clip > 0 and state->engine->isserver)
    {
        if (isfthing)
        {
            fthanim = Animation("heroes/mccree/fanthehammerloop/", std::bind(&Peacemaker::wantfiresecondary, this, state));
        }
        else
        {
            fthanim = Animation("heroes/mccree/fanthehammerstart/", std::bind(&Peacemaker::wantfiresecondary, this, state));
            isfthing = true;
        }
    }
}
Esempio n. 16
0
Chicken::Chicken()
{
   Texture* tex = textureLoader::getTexture("cucco");
   AnimatedSprite sprite = AnimatedSprite(&tex->texture, 0, 0, tex->width, tex->height, 0, 0, 0.5, 1);
   *this = Chicken((Chicken&)sprite);
   type = 1;
   name = "cucco";

   //Setup Collider
   int xOffset = 20;
   int yOffset = 25;
   int width = 20;
   int height = 20;
   float uSize = 0.5;
   float vSize = 1;
   colliderXOffset = xOffset;
   colliderYOffset = yOffset;
   setCollider(&AABB(x + xOffset, y + yOffset, width, height));
   maxSpeed = 50;

   // Walking Animation
   int numFrames = 2;
   int timeToNextFrame = 300;
   std::vector<AnimationFrame> frames;
   frames.assign(numFrames, AnimationFrame());

   frames[0] = AnimationFrame(0, 0, uSize, vSize);
   frames[1] = AnimationFrame(0.5, 0, uSize, vSize);
   Animation animation_walking = Animation("Walking", frames, numFrames);
   animations[animation_walking.name] = AnimationData(animation_walking, timeToNextFrame, true);

   // Idle Animation
   numFrames = 1;
   frames.clear();
   frames.assign(numFrames, AnimationFrame());
   
   frames[0] = AnimationFrame(0, 0, uSize, vSize);
   Animation animation_idle = Animation("Idle", frames, numFrames);
   animations[animation_idle.name] = AnimationData(animation_idle, timeToNextFrame, true);
   
   setAnimation("Walking");
}
Esempio n. 17
0
void Animator::addSeq(int frames)
{
	Seq seq;
	seq.frames = frames;
	_seqs.push_back(seq);
	for (int k = 0; k < _objs.size(); ++k) {
		Object* obj = _objs[k];
		_anims[k].keys.push_back(obj->getAnimation());
		obj->setAnimation(Animation());
	}
}
Esempio n. 18
0
void Animator::extractSeq(int first, int last, int seq)
{
	Seq sq;
	sq.frames = last - first;
	_seqs.push_back(sq);

	for (int k = 0; k < _objs.size(); ++k) {
		Animation& keys = _anims[k].keys[seq];
		_anims[k].keys.push_back(Animation(keys, first, last));
	}
}
Esempio n. 19
0
void SwampMonster::kill()
{
	Monster::kill();

	mHealth = 0;

	ResourceManager *resources = game->getResourceManager();

	if(!mIsDying)
	{
		if(mVoice)
			mVoice->stop();

		makeMonsterNoise(true);

		Player *player = game->getPlayer();

		switch(rand() % 3)
		{
			case 0:
				player->speak(player->getQuipKillSwampMonster());
				break;
			case 2:
				if(mAttachments.size() > 0)
					player->speak(player->getQuipBurn());
				break;
			case 1:
				player->speak(player->getQuipKill());
				break;
		}

		if(mIsFrozen)
			//Made this a bit quieter since it was pretty overpowering.
			game->getSoundEngine()->play2DSound(game->getResourceManager()->get("shatter" + std::to_string(rand() % 10 + 1)), 0.25f);

		//Remove all attachments left.
		for(auto it = mAttachments.begin(); it != mAttachments.end();  ++it)
		{
			it->second->setShouldDelete(true);
		}

		mAttachments.clear();

		mIsDying = true;
		mDeathTimer.start();

		delete mpAnim;

		mpAnim = New Animation(*game->getAnimationManager()->get("vaporize"));

		//if(rand() % 5 == 0)
				game->getEntityManager()->add(New HealthPotion(mPosition));
	}
}
Esempio n. 20
0
void EfectWeaponShield::onInit()
{
	EfectWeapon::onInit();
	idColiderMin = getOwner()->colliders.size();
	getResX().inverseMass = 0.5;

	//getOwner()->getPos().inverseMass *= 0.9;

	// weapon model;
	{
		static bool model_loaded = false;
		static string constructionScript;

		loadScript("model_shl.txt", constructionScript, model_loaded);
		static stringstream stream;
		stream.str(constructionScript);
		getOwner()->addEfect(efModel = new EfectModel(stream, handSprite, false, false));
	}
	getOwner()->allModels.push_back(&efModel->model);

	// Animations
	getOwner()->addAnimation(animCodeX, Animation("animation_shl_cross.txt"));
	getOwner()->addAnimation(animCodeY, Animation("animation_shl_push.txt"));

	//shield Colliders
	auto efShield = new Game::MultiEfect;
	addEfect(efShield);

	efShield->addEfect(new EfectMaterial(pos, EfectMaterial::v2, getOwner(), 0.9));
	//efShield->addEfect(new EfectMaterial(hp, EfectMaterial::f, getOwner(), 0.075));
	efShield->addEfect(new EfectRotateOnCollision(0.65, handSprite, 90));
	efShield->addEfect(new EfectSwordMaterial(idResX, idResY, 5.75, 3.5, &efModel->model,-90));

	efShield->addEfect(new EfectCollisionResponse( 30, 12.5, 100));


	getOwner()->addCollider(ColliderInfo(CircleCollider(Vector2D(0, 25), 45), efShield, &efModel->model));
	getOwner()->addCollider(ColliderInfo(CircleCollider(Vector2D(0, -10), 55), efShield, &efModel->model));

	idColiderMax = getOwner()->colliders.size();
}
Esempio n. 21
0
  bool AnimationGroup::initialize(const DataProxy& dict, Ogre::SceneManager* sceneManager)
  {
    for(auto& pair : dict)
    {
      std::string fullId = pair.second.as<std::string>();

      std::vector<std::string> id = split(fullId, '.');

      std::string entityID;
      mAnimations[pair.first] = Animation();
      if(id.size() < 2) {
        LOG(TRACE) << "Added empty animation to group " << pair.first;
        continue;
      }

      SceneNodeWrapper* containerNode = mRenderComponent->getRoot();
      int i;
      for(i = 0; i < id.size() - 2; i++) {
        containerNode = containerNode->getChildOfType<SceneNodeWrapper>(id[i]);
        if(containerNode == 0) {
          break;
        }
      }

      if(containerNode == 0) {
        LOG(TRACE) << "Failed to find node with name " << id[i];
        continue;
      }

      EntityWrapper* w = containerNode->getChildOfType<EntityWrapper>(id[i]);

      OgreV1::Entity* e = w->getEntity();

      // no entity was found with such id
      if(e == 0)
      {
        LOG(ERROR) << "Failed to add animation: entity with id \"" << id[0] << "\" not found in scene manager";
        return false;
      }

      // no such state
      if(!e->hasAnimationState(id[1]))
      {
        LOG(ERROR) << "Failed to add animation: animation state with id \"" << id[1] << "\" not found in entity";
        return false;
      }

      LOG(TRACE) << "Adding animation " << fullId << " to group " << pair.first;
      mAnimations[pair.first].initialize(e->getAnimationState(id[1]));
    }
    return true;
  }
Animation AnimationLoader::loadFromResources(const Resources::ResourcePack& resourcePack)
	{
	auto atlasResource = resourcePack.resource("atlas");
	Texture atlas(atlasResource);
	auto configResource = resourcePack.resource("config");
	ConfigReader reader(configResource.asString());
	unsigned frames = reader.getInt("Frames");
	if (frames == 1)
		return Animation(atlas);

	int frameDuration = reader.getInt("FrameDuration");
	std::vector<Rectangle> frameRects;
	frameRects.reserve(frames);
	for (unsigned i = 0; i < frames; ++i)
		{
		String rectName = String("Rect") + String::fromInt(i + 1);
		std::vector<String> rectCoords = reader.getArray(rectName);
		int x = rectCoords[0].toInt(), y = rectCoords[1].toInt();
		unsigned w = rectCoords[2].toInt(), h = rectCoords[3].toInt();
		frameRects.emplace_back(x, y, w, h);
		}
	return Animation(atlas, frameRects, std::chrono::milliseconds(frameDuration));
	}
Esempio n. 23
0
SwampMonster::SwampMonster(Vec3d pos) : Monster(pos)
{
	mPosition = pos;
	playerPos = mPosition;
	mRotation = 0.0f;
	mIsStunned = false;
	mIsAlerted = false;
	mIsDying = false;

	mType = ENTITY_ENEMY;
	mMonsterType = MINOTAUR_MONSTER;
	
	mpAnim = New Animation(*game->getAnimationManager()->get("swampmonsterWalk"));
}
Simulation::Simulation(int object_count) : random_dev_() {
    MeshPicker mesh;
    ColorPicker color(random_dev_());

    objects_.reserve(object_count);
    for (int i = 0; i < object_count; i++) {
        Meshes::Type type = mesh.pick();
        float scale = mesh.scale(type);

        objects_.emplace_back(Object{
            type, glm::vec3(0.5f + 0.5f * (float)i / object_count), color.pick(), Animation(random_dev_(), scale),
            Path(random_dev_()),
        });
    }
}
//----------------------------------------------------------------------------//
Animation* AnimationManager::createAnimation(const String& name)
{
    if (isAnimationPresent(name))
    {
        CEGUI_THROW(UnknownObjectException("Animation with name '"
            + name + "' already exists."));
    }

    String finalName(name.empty() ? generateUniqueAnimationName() : name);

    Animation* ret = CEGUI_NEW_AO Animation(finalName);
    d_animations.insert(std::make_pair(finalName, ret));

    return ret;
}
Esempio n. 26
0
void Player::Update(D3DXVECTOR3 look, const float dt,bool oldSchoolView,LPCSTR dir )
{
	if(!mHit)
	{
		Move(dt);

		if(!oldSchoolView)
			ChangeDirection(look);
		else
			OldSchoolControl(dir);
	}

	Animation(dt);
	
}
Esempio n. 27
0
void GodLike_Beast ::Update(float _Time, int** _Terrain,float _MaxWidth,float _MaxHeight)
{
	if(getLife() == false)
	{
		EffectLeonDie *_EffectDie = new EffectLeonDie (m_X,m_Y);
		ManagerObject::Instance()->getListEffect()->push_back(_EffectDie);
		return ;
	}

	int random ;
	random = rand() % 4;	
	m_TimeUpdate+=_Time ;

	if(m_TimeUpdate > 2)
	{
		switch (random)
		{
		case 0:
			if(	m_skillManager->getSkill(1)->getSTT()!=ACTIVE  && m_skillManager->getSkill(2)->getSTT()!=ACTIVE && m_skillManager->getSkill(3)->getSTT()!=ACTIVE&& m_skillManager->getSkill(4)->getSTT()!=ACTIVE )
				ActiveSkill(0);
			m_TimeUpdate= 0 ;
			break;
		case 1:
			if(	m_skillManager->getSkill(0)->getSTT()!=ACTIVE  && m_skillManager->getSkill(2)->getSTT()!=ACTIVE && m_skillManager->getSkill(3)->getSTT()!=ACTIVE && m_skillManager->getSkill(4)->getSTT()!=ACTIVE  )
				ActiveSkill(1);
			m_TimeUpdate = 0 ;
			break ;
		case 2:
			if(	m_skillManager->getSkill(0)->getSTT()!=ACTIVE  && m_skillManager->getSkill(1)->getSTT()!=ACTIVE && m_skillManager->getSkill(3)->getSTT()!=ACTIVE && m_skillManager->getSkill(4)->getSTT()!=ACTIVE )
				ActiveSkill(2);
			m_TimeUpdate = 0 ;
			break ;
		case 3:
			if(	m_skillManager->getSkill(0)->getSTT()!=ACTIVE  && m_skillManager->getSkill(1)->getSTT()!=ACTIVE && m_skillManager->getSkill(2)->getSTT()!=ACTIVE && m_skillManager->getSkill(4)->getSTT()!=ACTIVE  )
				ActiveSkill(3) ;
			m_TimeUpdate = 0 ;
			break ;

		}
	}
	if(	m_skillManager->getSkill(0)->getSTT()!=ACTIVE  && m_skillManager->getSkill(1)->getSTT()!=ACTIVE && m_skillManager->getSkill(2)->getSTT()!=ACTIVE && m_skillManager->getSkill(3)->getSTT()!=ACTIVE && m_skillManager->getSkill(4)->getSTT()!=ACTIVE   )
	{
		Animation(_Time);
		Move(_Time,_Terrain,_MaxWidth,_MaxHeight);
	}
	m_skillManager->Update(_Time,_Terrain,_MaxWidth,_MaxHeight) ;
	UpdateStatus(_Time);
}
Esempio n. 28
0
gun::Animation gun::AnimationFactory::CreateAnimation(int sheet_width, 
	int sprite_width, int sprite_height, int frames)
{
	std::vector<sf::IntRect> source_rects = std::vector<sf::IntRect>();

	for(int i = 0; i < frames; i++)
	{
		int sheet_x = i % sheet_width;
		int sheet_y = i / sheet_width;

		source_rects.push_back(sf::IntRect(sheet_x * sprite_width, sheet_y * sprite_height, 
			sprite_width, sprite_height));
	}

	return Animation(source_rects);
}
Esempio n. 29
0
	void update(float time)
	{
		Keyboard();

        Animation(time);

		if (STATE==climb) if (!onLadder) STATE=stay;
        if (STATE!=climb) dy+=0.0005*time;
        onLadder=false;

		x+=dx*time;
		Collision(0);

		y+=dy*time;
		Collision(1);
	}
Esempio n. 30
0
MapController::MapController(CommandStack& cs, TextureResource& tr, ShaderResource& sr)
    : m_commandStack    (cs),
    m_itemTime          (spawnGapTime),
    m_itemActive        (false),
    m_textureResource   (tr),
    m_shaderResource    (sr),
    m_itemSprite        ("res/textures/map/item.cra", tr),
    m_hatSprite         (tr.get("res/textures/map/hat_diffuse.png")),
    m_batSprite         ("res/textures/characters/bat.cra", tr),
    m_birdSprite        ("res/textures/characters/bird.cra", tr),
    m_hatCount          (0u),
    m_detailTime        (static_cast<float>(Util::Random::value(10, 23))),
    m_solidDrawable     (tr, sr.get(Shader::Type::NormalMap)),
    m_rearDrawable      (tr, sr.get(Shader::Type::NormalMap)),
    m_frontDrawable     (tr, sr.get(Shader::Type::NormalMapSpecular))
{
    //scale sprite to match node size
    blockTextureSize = sf::Vector2f(tr.get("res/textures/map/steel_crate_diffuse.png").getSize() / 2u); //KLUUUDDGGE!!!

    for (auto i = 0u; i < blockTextureCount; ++i)
    {
        m_blockSprites.emplace_back(tr.get("res/textures/map/steel_crate_diffuse.png"));
        auto& blockSprite = m_blockSprites.back();
        blockSprite.setFrameCount(1u);
        blockSprite.setNormalMap(tr.get("res/textures/map/steel_crate_normal.tga"));
        blockSprite.setShader(sr.get(Shader::Type::NormalMap));
        blockSprite.setFrameCount(blockTextureCount);
        blockSprite.setFrameSize(sf::Vector2i(blockTextureSize));
        blockSprite.play(Animation("", i, i));
    }

    m_itemSprite.setLooped(true);
    m_itemSprite.setShader(sr.get(Shader::Type::NormalMapSpecular));
    m_itemSprite.play();

    m_hatSprite.setFrameSize(sf::Vector2i(m_hatSprite.getTexture()->getSize()));
    m_hatSprite.setNormalMap(tr.get("res/textures/map/hat_normal.png"));
    m_hatSprite.setShader(sr.get(Shader::Type::Metal));

    m_batSprite.setShader(sr.get(Shader::Type::FlatShaded));
    m_batSprite.setLooped(true);
    m_batSprite.play();

    m_birdSprite.setShader(sr.get(Shader::Type::FlatShaded));
    m_birdSprite.setLooped(true);
    m_birdSprite.play();
}