Example #1
0
drape_ptr<SequenceAnimation> GetPrettyMoveAnimation(ScreenBase const & screen, double startScale, double endScale,
                                                    m2::PointD const & startPt, m2::PointD const & endPt)
{
  double const moveDuration = PositionInterpolator::GetMoveDuration(startPt, endPt, screen.PixelRectIn3d(), startScale);
  ASSERT_GREATER(moveDuration, 0.0, ());

  double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0;

  auto sequenceAnim = make_unique_dp<SequenceAnimation>();
  sequenceAnim->SetCustomType(kPrettyMoveAnim);

  auto zoomOutAnim = make_unique_dp<MapLinearAnimation>();
  zoomOutAnim->SetScale(startScale, startScale * scaleFactor);
  zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);

  //TODO (in future): Pass fixed duration instead of screen.
  auto moveAnim = make_unique_dp<MapLinearAnimation>();
  moveAnim->SetMove(startPt, endPt, screen);
  moveAnim->SetMaxDuration(kMaxAnimationTimeSec);

  auto zoomInAnim = make_unique_dp<MapLinearAnimation>();
  zoomInAnim->SetScale(startScale * scaleFactor, endScale);
  zoomInAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);

  sequenceAnim->AddAnimation(move(zoomOutAnim));
  sequenceAnim->AddAnimation(move(moveAnim));
  sequenceAnim->AddAnimation(move(zoomInAnim));
  return sequenceAnim;
}
Example #2
0
void AnimatorBar::AddAnimation()
{
	HTREEITEM Item = curHTreeItem;
	HTREEITEM Parent = 0;

	if (Item) 
	{
		if (Item == TVI_ROOT)
			Parent = 0;
		else
			Parent = animations.GetParentItem(Item);
	}

	CAnimation* pAnimation;
	
	if(Parent)
		pAnimation = AddAnimation((CAnimation*)animations.GetItemData(Parent));
	else
		pAnimation = AddAnimation(m_pAnimation);	

	UpdateAnimations(NULL, NULL, NULL, -2);

	// Select animation
	animations.SelectItem(pAnimation->m_Tree);
}
void Thief::SetPulse(IPoint dir)
{
	_queueAnim.clear();
	int dir_id = 0;
	if(dir.x == 1 && dir.y == 0)
	{
		dir_id = 0;
	}else if(dir.x == 0 && dir.y == 1)
	{
		dir_id = 1;
	}else if(dir.x == -1 && dir.y == 0)
	{
		dir_id = 2;
	}else if(dir.x == 0 && dir.y == -1)
	{
		dir_id = 3;
	}else{
		Assert(false);
	}
	if(_countNear == 0)
	{
		AddAnimation("thief_near_" + utils::lexical_cast(dir_id), true, math::random(0.2f, 0.4f));
	}else{
		AddAnimation("thief_near_" + utils::lexical_cast(dir_id), false, math::random(0.f, 5.f));
	}
	_countNear++;
}
Example #4
0
// Initialize animations for sprite
void Player::SetupAnimation( )
{
	AddAnimation( 3, 0, 0, "RunLeft", 16, 16, Vector2( 0,0 ) );
	AddAnimation( 3, 0, 16, "RunRight", 16, 16, Vector2( 0,0 ) );

	AddAnimation( 1, 0, 0, "IdleLeft", 16, 16, Vector2( 0,0 ) );
	AddAnimation( 1, 0, 16, "IdleRight", 16, 16, Vector2( 0,0 ) );
}
void Player::CreateAnimations(int rows) {
    sf::IntRect image = {0, 128, width, height};
    
    // Create animation ATTACK_SOUTH
    Animation *south = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        south->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_SOUTH, south);
    
    image.top += height;
    
    // Create animation ATTACK_WEST
    Animation *west = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        west->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_WEST, west);
    
    image.top += height;
    
    // Create animation ATTACK_EAST
    Animation *east = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        east->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_EAST, east);
    
    image.top += height;
    
    // Create animation ATTACK_NORTH
    Animation *north = new Animation;
    image.left = 0;
    
    for (int i = 0; i < rows; i++) {
        north->AddFrame(image, 150);
        image.left += width;
    }
    
    AddAnimation(ATTACK_NORTH, north);
}
void CAnimationEditorDlg::OnBnClickedAddanimation()
{
	HTREEITEM item = m_AnimationTree.GetSelectedItem();
	HTREEITEM parent = 0;
	if(item) 
		parent = m_AnimationTree.GetParentItem(item);
	if(parent)
		AddAnimation((CAnimation*)m_AnimationTree.GetItemData(parent));
	else
		AddAnimation(m_Animation);	
	
	UpdateAnimations();
}
Example #7
0
void MainWindow::OnCreation()
{
    // label with decoration in the third cell
    mMyLabel = new nuiLabel(_T("my label is spinning!"));
    mMyLabel->SetFont(nuiFont::GetFont(30));
    mMyLabel->SetPosition(nuiCenter);
    AddChild(mMyLabel);

    mMyLabel->EnableSurface(true);


    nuiRect r = mMyLabel->CalcIdealSize();
    float s = MAX(r.GetWidth(), r.GetHeight());
    float x = s / 2;
    float y = s / 2;
    mMyLabel->SetUserRect(nuiRect(s, s));
    nuiRotateMatrixAttributeAnimation* pAnim = new nuiRotateMatrixAttributeAnimation();
    pAnim->SetTargetObject(mMyLabel);
    pAnim->SetTargetAttribute(_T("SurfaceMatrix"));
    pAnim->SetStartValue(0, x, y);
    pAnim->SetEndValue(180, x, y);
    pAnim->SetDuration(2);
    pAnim->SetEasing(nuiEasingElasticIn<10>);
    AddAnimation(_T("RotateLabel"), pAnim);
    pAnim->Play(1000, eAnimLoopPingPong);
}
Example #8
0
void
GrannyTestSkeleton::AddAllAnimationsFrom( const char* Path )
{
	WIN32_FIND_DATA ffblk;
	HANDLE h;

	char fullPath[1024];

	strcpy( fullPath, Path ) ;
	strcat( fullPath, "/*.gr2" ) ;

	h = FindFirstFile( fullPath, &ffblk );
	if( h != INVALID_HANDLE_VALUE) 
	{
		do 
		{
			if ( !( ffblk.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) ) 
			{
				strcpy( fullPath, Path );
				strcat( fullPath, "/" ) ;
				strcat( fullPath, ffblk.cFileName );
				AddAnimation( fullPath );
			}
		}
		while( FindNextFile( h, &ffblk ) != 0 );

		FindClose( h );
	}
}
Example #9
0
nuiSpriteDef::nuiSpriteDef(const nglPath& rSpriteDefPath)
{
  Init();
  nglString name(rSpriteDefPath.GetNodeName());
  SetObjectName(name);
  std::map<nglString, nuiSpriteDef*>::const_iterator it = mSpriteMap.find(name);
  if (it != mSpriteMap.end())
    it->second->Release();

  mSpriteMap[name] = this;

  {
    std::list<nglPath> children;
    rSpriteDefPath.GetChildren(&children);
    std::list<nglPath>::const_iterator it = children.begin();
    std::list<nglPath>::const_iterator end = children.end();
    for (; it != end; it++)
    {
      nuiSpriteAnimation* pAnim = new nuiSpriteAnimation(*it);
      if (pAnim->GetFrameCount())
        AddAnimation(pAnim);
      else
        delete pAnim;
    }
  }
}
Example #10
0
static std::shared_ptr<asd::AnimationClip> CreateAnimation()
{
	auto factory = new asd::AnimationSystem_Imp();

	auto clip = factory->CreateAnimationClip();
	auto source = factory->CreateAnimationSource();
	auto key = factory->CreateKeyframeAnimation();

	asd::FCurveKeyframe k1;
	k1.KeyValue.X = 0.0;
	k1.KeyValue.Y = 20;
	k1.LeftHandle = k1.KeyValue;
	k1.RightHandle = k1.KeyValue;

	asd::FCurveKeyframe k2;
	k2.KeyValue.X = 10.0;
	k2.KeyValue.Y = -20;
	k2.LeftHandle = k2.KeyValue;
	k2.RightHandle = k2.KeyValue;

	key->SetName(asd::ToAString("no2.rot.z").c_str());
	key->AddKeyframe(k1);
	key->AddKeyframe(k2);

	source->AddAnimation(key);
	clip->SetSource(source);
	delete factory;

	return clip;
}
Example #11
0
void dModel::InitFromModel (const dModel& source)
{
	while (m_skeleton.GetCount()) {
		RemoveSkeleton(m_skeleton.GetFirst()->GetInfo());
	}
	while (m_meshList.GetCount()) {
		RemoveMesh(m_meshList.GetFirst()->GetInfo().m_mesh);
	}

	while (m_animations.GetCount()) {
		RemoveAnimation(m_animations.GetFirst()->GetInfo());
	}


	for (dList<dBone*>::dListNode* node = source.m_skeleton.GetFirst(); node; node = node->GetNext()) {
		int stack = 1;
		dBone* pool[64];
		dBone* parentBones[64];

		parentBones[0] = NULL;
		dBone* rootBone = NULL;
		pool[0] = node->GetInfo();
		
		while (stack) {
			stack --;
			dBone* parent = parentBones[stack];
			dBone* sourceBone = pool[stack];
			dBone* bone = new dBone (*sourceBone, parent);
			if (!rootBone) {
				rootBone = bone;
			}

			for (sourceBone = sourceBone->GetChild(); sourceBone; sourceBone = sourceBone->GetSibling()) {
				pool[stack] = sourceBone;
				parentBones[stack] = bone;
				stack ++;
			}
		}
	
		AddSkeleton(rootBone);
		rootBone->Release();
	}



	for (dList<dAnimationClip*>::dListNode* node = source.m_animations.GetFirst(); node; node = node->GetNext()) {
		AddAnimation(node->GetInfo());
	}


	for (dList<dMeshInstance>::dListNode* node = source.m_meshList.GetFirst(); node; node = node->GetNext()) { 
		AddMesh(node->GetInfo().m_mesh);
		dMeshInstance& instance = m_meshList.GetLast()->GetInfo();
		instance.m_boneID = node->GetInfo().m_boneID;
		if (node->GetInfo().GetModifier()) {
			instance.SetModifier(node->GetInfo().GetModifier()->CreateCopy (instance, *this));
		}
	}
}
Example #12
0
nuiHugeImage::nuiHugeImage(const nglPath& rImagePath)
{
  if (SetObjectClass(_T("nuiHugeImage")))
  {
    InitAttributes();
  }

  
  mClicked = false;
  mZoom = 1.0f;
  mMinZoom = 0.2f;
  mMaxZoom = 1.0f;
  mX = 0.0f;
  mY = 0.0f;

  mpZoom = new nuiAttributeAnimation();
  mpZoom->SetTargetObject(this);
  mpZoom->SetTargetAttribute(_T("Zoom"));
  mpZoom->SetCaptureStartOnPlay(true);
  mpZoom->SetEndValue(mMaxZoom);
  mpZoom->SetEasing(nuiEasingSinus);
  mpZoom->SetDuration(1.0f);
  AddAnimation(_T("Zoom"), mpZoom);
  
  mpPanX = new nuiAttributeAnimation();
  mpPanX->SetTargetObject(this);
  mpPanX->SetTargetAttribute(_T("CenterX"));
  mpPanX->SetCaptureStartOnPlay(true);
  mpPanX->SetEndValue(0);
  mpPanX->SetEasing(nuiEasingSinus);
  mpPanX->SetDuration(1.0f);
  AddAnimation(_T("PanX"), mpPanX);

  mpPanY = new nuiAttributeAnimation();
  mpPanY->SetTargetObject(this);
  mpPanY->SetTargetAttribute(_T("CenterY"));
  mpPanY->SetCaptureStartOnPlay(true);
  mpPanY->SetEndValue(0);
  mpPanY->SetEasing(nuiEasingSinus);
  mpPanY->SetDuration(1.0f);
  AddAnimation(_T("PanY"), mpPanY);
  
  InitImage();
  Load(rImagePath);
  //StartAnimation(_T("Zoom"));
}
Example #13
0
 void
 CreatureManager::CreateAnimation(CreatureLoadDataPacket& load_data,
                                  const std::string& name_in)
 {
     auto new_animation = std::shared_ptr<CreatureModule::CreatureAnimation>(new CreatureAnimation(load_data,
                                                                                                   name_in));
     AddAnimation(new_animation);
 }
Example #14
0
drape_ptr<SequenceAnimation> GetPrettyFollowAnimation(ScreenBase const & startScreen, m2::PointD const & userPos, double targetScale,
                                                      double targetAngle, m2::PointD const & endPixelPos)
{
  auto sequenceAnim = make_unique_dp<SequenceAnimation>();
  sequenceAnim->SetCustomType(kPrettyFollowAnim);

  m2::RectD const viewportRect = startScreen.PixelRectIn3d();

  ScreenBase tmp = startScreen;
  tmp.SetAngle(targetAngle);
  tmp.MatchGandP3d(userPos, viewportRect.Center());

  double const moveDuration = PositionInterpolator::GetMoveDuration(startScreen.GetOrg(), tmp.GetOrg(), startScreen);
  ASSERT_GREATER(moveDuration, 0.0, ());

  double const scaleFactor = moveDuration / kMaxAnimationTimeSec * 2.0;

  tmp = startScreen;

  if (moveDuration > 0.0)
  {
    tmp.SetScale(startScreen.GetScale() * scaleFactor);

    auto zoomOutAnim = make_unique_dp<MapLinearAnimation>();
    zoomOutAnim->SetScale(startScreen.GetScale(), tmp.GetScale());
    zoomOutAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
    sequenceAnim->AddAnimation(move(zoomOutAnim));

    tmp.MatchGandP3d(userPos, viewportRect.Center());

    auto moveAnim = make_unique_dp<MapLinearAnimation>();
    moveAnim->SetMove(startScreen.GetOrg(), tmp.GetOrg(), viewportRect, tmp.GetScale());
    moveAnim->SetMaxDuration(kMaxAnimationTimeSec);
    sequenceAnim->AddAnimation(move(moveAnim));
  }

  auto followAnim = make_unique_dp<MapFollowAnimation>(tmp, userPos, endPixelPos,
                                                       tmp.GetScale(), targetScale,
                                                       tmp.GetAngle(), targetAngle,
                                                       false /* isAutoZoom */);
  followAnim->SetMaxDuration(kMaxAnimationTimeSec * 0.5);
  sequenceAnim->AddAnimation(move(followAnim));
  return sequenceAnim;
}
Example #15
0
void AnimatorBar::AddSubAnimation()
{
	HTREEITEM Item = curHTreeItem;

	if(((CAnimation*)animations.GetItemData(Item))->IsAngle())
		Item = animations.GetParentItem(Item);

	CAnimation* pAnimation;

	if(Item) 
		pAnimation = AddAnimation((CAnimation*)animations.GetItemData(Item));
	else
		pAnimation = AddAnimation(m_pAnimation);

	UpdateAnimations(NULL, NULL,NULL, -2);

	// Select animation
	animations.SelectItem(pAnimation->m_Tree);
}
Example #16
0
Objet3D::Objet3D(Lumiere *lumiere, string modeleName,int frameNumber)
{
    position.x = 0;
    position.y = 0;
    position.z = 0;

    currentAnimation = 0;

    AddAnimation(modeleName, lumiere, frameNumber);
}
Example #17
0
Moose::Moose(SimianBase * theApp, char * theName) : Entity(theApp, theName)
{
	SetType(ET_MOOSE);
	SetState(ES_IDLE);
	SetFrames(6, 3);

	int WalkLeft[]		= {0,1,0,2};
	int WalkRight[]		= {5,3,5,4};
	int WalkUp[]		= {9,10,9,11};
	int WalkDown[]		= {6,7,6,8};
	int WalkLength[]	= {4,4,4,4};

	int StandLeft[]		= {0};
	int StandRight[]	= {5};
	int StandUp[]   	= {9};
	int StandDown[] 	= {6};
	int StandLength[]	= {1,1,1,1};

	int ChargeLeft[]	= {12, 13};
	int ChargeRight[]	= {15, 16};
	int ChargeUp[]		= {10, 11};
	int ChargeDown[]	= {7, 8};
	int ChargeLength[]  = {2,2,2,2};

	ANIMATION_RUNNING	= AddAnimation(WalkUp, WalkDown, WalkLeft, WalkRight, WalkLength);
	ANIMATION_STANDING	= AddAnimation(StandUp, StandDown, StandLeft, StandRight, StandLength);
	ANIMATION_WALKING	= AddAnimation(WalkUp, WalkDown, WalkLeft, WalkRight, WalkLength);
	ANIMATION_EATING	= AddAnimation(StandUp, StandDown, StandLeft, StandRight, StandLength);
	ANIMATION_CHARGING  = AddAnimation(ChargeUp, ChargeDown, ChargeLeft, ChargeRight, ChargeLength);

	SetAnimationSpeed(200);
	PlayAnimation(ANIMATION_WALKING);

	mWanderStep		= 50;
	mPauseTime		= 1000;
	mMoveSpeed		= 0.5;
	mSearchDistance = 200;
	mSearchAngle	= 60;
	mTargetType		= ET_GRASS;

	mHungerTimer = 1000;
}
Example #18
0
TreasureObject::TreasureObject(const std::string& treasure_name,
                               MapObjectDrawLayer layer,
                               const std::string& closed_animation_file,
                               const std::string& opening_animation_file,
                               const std::string& open_animation_file) :
    PhysicalObject(layer)
{
    _object_type = TREASURE_TYPE;
    _events_triggered = false;
    _is_opening = false;

    _treasure_name = treasure_name;
    if(treasure_name.empty())
        PRINT_WARNING << "Empty treasure name found. The treasure won't function normally." << std::endl;

    _treasure = new vt_map::private_map::MapTreasureContent();

    // Dissect the frames and create the closed, opening, and open animations
    vt_video::AnimatedImage closed_anim, opening_anim, open_anim;

    closed_anim.LoadFromAnimationScript(closed_animation_file);
    if(!opening_animation_file.empty())
        opening_anim.LoadFromAnimationScript(opening_animation_file);
    open_anim.LoadFromAnimationScript(open_animation_file);

    // Set the collision rectangle according to the dimensions of the first frame
    SetCollPixelHalfWidth(closed_anim.GetWidth() / 2.0f);
    SetCollPixelHeight(closed_anim.GetHeight());

    // Apply the zoom ratio on the animations.
    ScaleToMapZoomRatio(closed_anim);
    ScaleToMapZoomRatio(opening_anim);
    ScaleToMapZoomRatio(open_anim);

    AddAnimation(closed_anim);
    AddAnimation(opening_anim);
    AddAnimation(open_anim);

    _LoadState();
}
void CAnimationEditorDlg::OnBnClickedSubanimation()
{
	HTREEITEM item = m_AnimationTree.GetSelectedItem();

	if(((CAnimation*)m_AnimationTree.GetItemData(item))->IsAngle())
		item = m_AnimationTree.GetParentItem(item);
	if(item) 
		AddAnimation((CAnimation*)m_AnimationTree.GetItemData(item));
	else
		OnBnClickedAddanimation();
	
	UpdateAnimations();
}
//! Constructor.
SkinnedModel::SkinnedModel()
{
	SetFilename("#NOVALUE");
	mAnimator = nullptr;
	mElapsedTime = 0.0f;

	AddAnimation(0, 37, 662, 20);
	AddAnimation(38, 83, 662, 20);
	AddAnimation(84, 264, 662, 20);
	AddAnimation(265, 445, 662, 20);
	AddAnimation(446, 491, 662, 20);
	AddAnimation(492, 537, 662, 20);
	AddAnimation(538, 553, 662, 20);
	AddAnimation(554, 662, 662, 20);
}
Example #21
0
Objet3D::Objet3D(Lumiere *lumiere, string fcoFileName)
{
    position.x = 0;
    position.y = 0;
    position.z = 0;

    currentAnimation = 0;

    map<string, string> fcoAsMap = Tools::getFcoAsMap(fcoFileName);

    //animation "de base"
    AddAnimation(fcoAsMap["basicAnimation"], lumiere, Tools::StringToInt(fcoAsMap["basicAnimationFrameNumber"]));
    animations[0].SetName(fcoAsMap["basicAnimationName"]);

    for(int a=1; a<=Tools::StringToInt(fcoAsMap["animationNumber"]); a++)
    {
        AddAnimation(fcoAsMap["Animation"+Tools::IntToString(a)], lumiere, Tools::StringToInt(fcoAsMap["Animation"+Tools::IntToString(a)+"FrameNumber"]));
        animations[a].SetName(fcoAsMap["Animation"+Tools::IntToString(a)+"Name"]);
    }

    //on joue l'animation de base
    animations[0].Play(true);
}
Example #22
0
/*
* Add Weapon animation
*/
std::list<entanim_s>::iterator CPlayerAnimation::AddWeaponAnimation( PLAY_ANIM eAnim )
{	CBasePlayer *pOwner = GetOwnerPlr();
	if(!pOwner)
	{	return NULL;
	}
	if(eAnim == PLAY_MISC)
	{	return NULL;
	}

	char szAnim[64];
	BOOL fLoop = FALSE;
	sprintf(szAnim, "%s_", pOwner->m_szAnimExtention);

	switch(eAnim)
	{	
	case PLAY_DRAW:
		strcat(szAnim,"draw");
		break;
	case PLAY_ATTACK1:
		strcat(szAnim,"shoot1");
		break;
	case PLAY_ATTACK2:
		strcat(szAnim,"shoot2");
		break;
	case PLAY_CHARGE1:
		strcat(szAnim,"charge_idle1");
		fLoop = TRUE;
		break;
	case PLAY_CHARGE2:
		strcat(szAnim,"charge_idle2");
		fLoop = TRUE;
		break;
	case PLAY_CHARGE_SHOOT1:
		strcat(szAnim,"charge_shoot1");
		break;
	case PLAY_CHARGE_SHOOT2:
		strcat(szAnim,"charge_shoot2");
		break;
	}

	// Add animation
	std::list<entanim_s>::iterator iterAnim = AddAnimation(fLoop, ANIMTYPE_UPPERONLY, gpGlobals->time, 1, szAnim);
	// Set animation type
	if(iterAnim != NULL)
	{	iterAnim->ePlayAnim = eAnim;
	}
	return iterAnim;
}
Example #23
0
void AnimatedSprite::LoadSpritesheet(std::string textureName, 
	int framesizeX, int framesizeY, int framesX, int framesY)
{
	m_sSpriteSheetName = textureName;
	m_pTexture = Textures->m_Textures[textureName];

	m_frames.x = framesX;
	m_frames.y = framesY;
	m_frameSize.x = framesizeX;
	m_frameSize.y = framesizeY;

	AddAnimation("idle", Vector2i(), Vector2i());

	PlayAnimation("idle", true);
	m_bIsAnimated = true;
}
void SimpleAnimatedEntity::CreateDeserialize(RakNet::BitStream *stream) {
	SimpleObject::CreateDeserialize(stream);

	uint32_t animCount;
	stream->Read(animCount);

	for (int i = 0; i < animCount; ++i) {
		RakNet::RakString name, anim;
		stream->Read(name);
		stream->Read(anim);
		auto animation = SimpleEngine::Instance()->GetResourceManager()->GetSpriteAnimation(anim.C_String());
		SimpleAnimatedSpriteRenderer* animatedSpriteRenderer = new SimpleAnimatedSpriteRenderer();
		animatedSpriteRenderer->SetAnimation(animation);
		AddAnimation(name.C_String(), animatedSpriteRenderer);
	}
}
Thief::Thief(IPoint index)
	: _index(index)
	, _currentAnimation(0)
	, _bornTime(0.f)
	, _awake(false)
	, _pulse(false)
	, _isKilled(false)
	, _canUpdate(false)
	, _timer(0.f)
	, _mirror(false)
	, _localOffset(0.f, 0.f)
	, _moves(0)
	, _turned(false)
	, _countNear(0)
{
	AddAnimation("thief_stay");
}
Example #26
0
void CEnemySuperRetardZombie::InitAnimation()
{
    Animation* cAnim;

    cAnim = new Animation();
    cAnim->Set(1, 1, 0, 0.f);
    AddAnimation(cAnim, DIR_IDLE_DOWN);

    //Idle East
    cAnim = new Animation();
    cAnim->Set(4, 4, 0, 0.f);
    AddAnimation(cAnim, DIR_IDLE_LEFT);

    //Idle East
    cAnim = new Animation();
    cAnim->Set(7, 7, 0, 0.f);
    AddAnimation(cAnim, DIR_IDLE_RIGHT);

    //Idle North
    cAnim = new Animation();
    cAnim->Set(10, 10, 0, 0.f);
    AddAnimation(cAnim, DIR_IDLE_UP);

    //Walk South
    cAnim = new Animation();
    cAnim->Set(0, 2, 0, 0.8f);
    AddAnimation(cAnim, DIR_DOWN);

    //Walk East
    cAnim = new Animation();
    cAnim->Set(3, 5, 0, 0.4f);
    AddAnimation(cAnim, DIR_LEFT);

    //Walk East
    cAnim = new Animation();
    cAnim->Set(6, 8, 0, 0.4f);
    AddAnimation(cAnim, DIR_RIGHT);

    //Walk North
    cAnim = new Animation();
    cAnim->Set(9, 11, 0, 0.4f);
    AddAnimation(cAnim, DIR_UP);
}
Example #27
0
Player::Player()
	: ra::Actor()
{
	m_status = Q_DOWN;
	m_speed = sf::Vector2f(10, 10);

	setTexture(*ra::AssetManager::instance()->getTexture("sprite.png"));
	SetFramesByGrid(4, 4);

	AddAnimation("down", ra::Animation(1, 4, 8));
	AddAnimation("up", ra::Animation(13, 16, 8));
	AddAnimation("left", ra::Animation(5, 8, 8));
	AddAnimation("right", ra::Animation(9, 12, 8));
	AddAnimation("q_down", ra::Animation(1, 1, 1));
	AddAnimation("q_up", ra::Animation(13, 13, 1));
	AddAnimation("q_left", ra::Animation(5, 5, 1));
	AddAnimation("q_right", ra::Animation(9, 9, 1));
	SetActiveAnimation("up");
}
Example #28
0
	Sprite::Sprite(int nWidth,int nHeight,unsigned int nVertices){
		width=nWidth;
		height=nHeight;
		vertex= new GLfloat[nVertices*2];
	//	textureCords= new GLfloat[8];
		texture=0;
		vertices=4;
		ReferenceObject=NULL;
		setDepth(0);
		std::vector<AnimationFrame> A;
		AnimationFrame AF;
		AF.TexCoords=whole;
		AF.duration=INFINITY;
		A.push_back(AF);
		AddAnimation("default",A);
		SetAnimation("default");
		Left=false;
		SetColor(1,1,1,1);
	}
Example #29
0
void SpriteObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element)
{
    const gd::SerializerElement & animationsElement = element.GetChild("animations", 0, "Animations");
    animationsElement.ConsiderAsArrayOf("animation", "Animation");
    for (std::size_t i = 0; i < animationsElement.GetChildrenCount(); ++i)
    {
        const gd::SerializerElement & animationElement = animationsElement.GetChild(i);
        Animation newAnimation;

        newAnimation.useMultipleDirections = animationElement.GetBoolAttribute("useMultipleDirections", false, "typeNormal");

        //Compatibility with GD <= 3.3
        if (animationElement.HasChild("Direction"))
        {
            for (std::size_t j = 0; j < animationElement.GetChildrenCount("Direction"); ++j)
            {
                Direction direction;
                direction.UnserializeFrom(animationElement.GetChild("Direction", j));

                newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount()+1);
                newAnimation.SetDirection(direction, newAnimation.GetDirectionsCount()-1);
            }
        }
        //End of compatibility code
        else
        {
            const gd::SerializerElement & directionsElement = animationElement.GetChild("directions");
            directionsElement.ConsiderAsArrayOf("direction");
            for (std::size_t j = 0; j < directionsElement.GetChildrenCount(); ++j)
            {
                Direction direction;
                direction.UnserializeFrom(directionsElement.GetChild(j));

                newAnimation.SetDirectionsCount(newAnimation.GetDirectionsCount()+1);
                newAnimation.SetDirection(direction, newAnimation.GetDirectionsCount()-1);
            }
        }

        AddAnimation( newAnimation );
    }
}
Example #30
0
//------------------------------------------------------------------------------
void
Background2D::load( const size_t tile_index, const QGears::AnimationMap& animations )
{
    QGears::AnimationMap::const_iterator it( animations.begin() );
    QGears::AnimationMap::const_iterator it_end( animations.end() );

    while( it != it_end )
    {
        const QGears::String& name( it->first );
        const QGears::Animation& animation( it->second );
        Background2DAnimation* anim( new Background2DAnimation( name, this, tile_index ) );
        anim->SetLength( animation.length );
        QGears::KeyFrameList::const_iterator itk( animation.key_frames.begin() );
        QGears::KeyFrameList::const_iterator itk_end( animation.key_frames.end() );
        while( itk != itk_end )
        {
            anim->AddUVKeyFrame( *(itk++) );
        }
        AddAnimation( anim );
        ++it;
    }
}