void ofxSpriteAnimation::Update(const float delta_time)
{
	ofxSpriteQuad::Update(delta_time);
	if(m_Occlusion == SPRITE_OCCLUSION_OFF_SCREEN || m_Occlusion == SPRITE_OCCLUSION_UNKNOWN || m_Paused) return;
	m_AnimationTime += delta_time;
	bool frame_change = false;
	while(m_AnimationTime >= m_FrameTime[m_SequenceIndex])
	{
		m_AnimationTime -= m_FrameTime[m_SequenceIndex];
		if(m_FrameIndex == m_SequenceEnd[m_SequenceIndex])
		{
			m_FrameIndex = m_SequenceBegin[m_SequenceIndex];
		}
		else
		{
			m_FrameIndex++;
		}
		frame_change = true;
	}
	if(frame_change)
	{
		SetTextureRect(
			m_TextureRectTable[m_FrameIndex][0],
			m_TextureRectTable[m_FrameIndex][1],
			m_TextureRectTable[m_FrameIndex][2],
			m_TextureRectTable[m_FrameIndex][3]);
		SetSpriteRect(
			m_SpriteRectTable[m_FrameIndex][0],
			m_SpriteRectTable[m_FrameIndex][1],
			m_SpriteRectTable[m_FrameIndex][2],
			m_SpriteRectTable[m_FrameIndex][3]);
	}
}
Ejemplo n.º 2
0
void ofxSpriteQuad::SetTexture(string texture_path)
{
	ofxBaseSprite::SetTexture(texture_path);
	float width = m_Texture->GetWidth();
	float height = m_Texture->GetHeight();
	SetSpriteRect(width*-0.5, 0, width, height);
	SetTextureRect(0, 0, width, height);
}
Ejemplo n.º 3
0
void Sprite_Character::Update() {
	Sprite::Update();
	Rect r;
	if (tile_id != character->GetTileId() ||
		character_name != character->GetCharacterName() ||
		character_index != character->GetCharacterIndex()) {
		tile_id = character->GetTileId();
		character_name = character->GetCharacterName();
		character_index = character->GetCharacterIndex();
		if (tile_id > 0) {
			BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
			SetBitmap(tile);
			r.Set(0, 0, 16, 16);
			SetSrcRect(r);
			SetOx(8);
			SetOy(16);
		} else {
			if (character_name.empty()) {
				SetBitmap(BitmapRef());
			} else {
				SetBitmap(Cache::Charset(character_name));
				chara_width = GetBitmap()->GetWidth() / 4 / 3;
				chara_height = GetBitmap()->GetHeight() / 2 / 4;
				SetOx(chara_width / 2);
				SetOy(chara_height);
				int sx = (character_index % 4) * chara_width * 3;
				int sy = (character_index / 4) * chara_height * 4;
				r.Set(sx, sy, chara_width * 3, chara_height * 4);
				SetSpriteRect(r);
			}
		}
	}

	if (tile_id == 0) {
		int row = character->GetDirection();
		r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height);
		SetSrcRect(r);
	}

	if (character->IsFlashPending()) {
		Color col;
		int dur;
		character->GetFlashParameters(col, dur);
		Flash(col, dur);
	}

	SetVisible(character->GetVisible());
	if (GetVisible()) {
		SetOpacity(character->GetOpacity());
	}

	SetX(character->GetScreenX());
	SetY(character->GetScreenY());
	SetZ(character->GetScreenZ(chara_height));
	
	//SetBlendType(character->GetBlendType());
	//SetBushDepth(character->GetBushDepth());
}
Ejemplo n.º 4
0
void Sprite_Character::Update() {
	Sprite::Update();
	Rect r;
	if (tile_id != character->GetTileId() ||
		character_name != character->GetSpriteName() ||
		character_index != character->GetSpriteIndex()) {
		tile_id = character->GetTileId();
		character_name = character->GetSpriteName();
		character_index = character->GetSpriteIndex();
		if (tile_id > 0) {
			BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
			SetBitmap(tile);
			r.Set(0, 0, TILE_SIZE, TILE_SIZE);
			SetSrcRect(r);
			SetOx(8);
			SetOy(16);
		} else {
			if (character_name.empty()) {
				SetBitmap(BitmapRef());
			} else {
				SetBitmap(Cache::Charset(character_name));
				SetOx(chara_width / 2);
				SetOy(chara_height);
				int sx = (character_index % 4) * chara_width * 3;
				int sy = (character_index / 4) * chara_height * 4;
				r.Set(sx, sy, chara_width * 3, chara_height * 4);
				SetSpriteRect(r);
			}
		}
	}

	if (tile_id == 0) {
		int row = (character->IsSpinning() ? character->GetPrelockDirection() : character->GetDirection());
		r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height);
		SetSrcRect(r);
	}

	if (character->IsFlashPending()) {
		Color col = character->GetFlashColor();
		int dur = character->GetFlashTimeLeft();
		Flash(col, dur);
		// TODO: Gradual decrease of Flash Time Left
		character->SetFlashTimeLeft(0);
	}

	SetVisible(character->GetVisible());
	if (GetVisible()) {
		SetOpacity(character->GetOpacity());
	}

	SetX(character->GetScreenX());
	SetY(character->GetScreenY());
	SetZ(character->GetScreenZ(chara_height));
	
	//SetBlendType(character->GetBlendType());
	//SetBushDepth(character->GetBushDepth());
}
Ejemplo n.º 5
0
void Sprite_Character::OnCharSpriteReady(FileRequestResult*) {
	SetBitmap(Cache::Charset(character_name));

	SetOx(chara_width / 2);
	SetOy(chara_height);
	int sx = (character_index % 4) * chara_width * 3;
	int sy = (character_index / 4) * chara_height * 4;
	Rect r;
	r.Set(sx, sy, chara_width * 3, chara_height * 4);
	SetSpriteRect(r);

	Update();
}
Ejemplo n.º 6
0
void Sprite_Character::Update() {
	Sprite::Update();
	Rect r;
	if (tile_id != character->GetTileId() ||
		character_name != character->GetCharacterName() ||
		character_index != character->GetCharacterIndex()) {
		tile_id = character->GetTileId();
		character_name = character->GetCharacterName();
		character_index = character->GetCharacterIndex();
		if (tile_id > 0) {
			BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
			SetBitmap(tile);
			r.Set(0, 0, 16, 16);
			SetSrcRect(r);
			SetOx(8);
			SetOy(16);
		} else {
			if (character_name.empty()) {
				SetBitmap(BitmapRef());
			} else {
				SetBitmap(Cache::Charset(character_name));
				chara_width = GetBitmap()->GetWidth() / 4 / 3;
				chara_height = GetBitmap()->GetHeight() / 2 / 4;
				SetOx(chara_width / 2);
				SetOy(chara_height);
				int sx = (character_index % 4) * chara_width * 3;
				int sy = (character_index / 4) * chara_height * 4;
				r.Set(sx, sy, chara_width * 3, chara_height * 4);
				SetSpriteRect(r);
			}
		}
	}
	//SetVisible(character->GetVisible());
	if (tile_id == 0) {
		int row = character->GetDirection();
		r.Set(character->GetPattern() * chara_width, row * chara_height, chara_width, chara_height);
		SetSrcRect(r);
	}
	SetX(character->GetScreenX());
	SetY(character->GetScreenY());
	SetZ(character->GetScreenZ(chara_height));
	//SetOpacity(character->GetOpacity());
	//SetBlendType(character->GetBlendType());
	//SetBushDepth(character->GetBushDepth());
	/*if (character->GetAnimationId() != 0) {
		RPG::Animation animation = Data::animations[character->GetAnimationId()]
		this->Animation(animation, true);
		character->SetAnimationId(0);
	}*/
}
void ofxSpriteAnimation::SetSequence(unsigned short index)
{
	m_SequenceIndex = index;
	m_FrameIndex = m_SequenceBegin[m_SequenceIndex];
	SetTextureRect(
		m_TextureRectTable[m_FrameIndex][0],
		m_TextureRectTable[m_FrameIndex][1],
		m_TextureRectTable[m_FrameIndex][2],
		m_TextureRectTable[m_FrameIndex][3]);
	SetSpriteRect(
		m_SpriteRectTable[m_FrameIndex][0],
		m_SpriteRectTable[m_FrameIndex][1],
		m_SpriteRectTable[m_FrameIndex][2],
		m_SpriteRectTable[m_FrameIndex][3]);
}
Ejemplo n.º 8
0
CSprite_Note::CSprite_Note(eNote type, float Rotation, float Rotation_Rate, int Speed, int Speed_Rate) : CSprite("Note", 20, 20, 0, 0, 20, 20)
{
    NoteType = type;

    int NoteColor = rand() % 8;

    switch (type)
    {
    case note_Normal:
    case note_FourWayNormal:
        SpriteTexture = SDL_CreateTextureFromSurface(g_DrawManager->pRenderer, g_ResourceManager->NormalNoteSurface);
        SetSpriteCenter(39, 39);
        SpriteRect = { 0, 0, 39, 39 };
        break;
    case note_Spiral_Left:
    case note_Spiral_Right:
        SpriteTexture = SDL_CreateTextureFromSurface(g_DrawManager->pRenderer, g_ResourceManager->SpiralNoteSurface);
        SetSpriteCenter(44, 44);
        SpriteRect = { 0, 0, 44, 44 };
        break;
    case note_Random:
        SpriteTexture = SDL_CreateTextureFromSurface(g_DrawManager->pRenderer, g_ResourceManager->Note[NoteColor]);
        SetSpriteCenter(20, 20);
        SpriteRect = { 0, 0, 20, 20 };
        break;
    default:
        break;
    }

    SetSpriteRect((WINDOW_DEFAULT_W / 2 - center.x), (WINDOW_DEFAULT_H / 2 - center.y));

    SetSpriteRotation(Rotation);

    this->Speed = Speed;
    this->Speed_Rate = Speed_Rate;
    this->Rotation_Rate = Rotation_Rate;
    radian = rotation * (M_PI / 180);
}
Ejemplo n.º 9
0
void ofxSpriteQuad::SetSpriteRect(const float x, const float y, const float w, const float h)
{
	SetSpriteRect(ofRectangle(x, y, w, h));
}