void Sprite_Battler::CreateSprite() { sprite_name = battler->GetSpriteName(); hue = battler->GetHue(); SetX(battler->GetBattleX()); SetY(battler->GetBattleY()); SetZ(battler->GetBattleY()); // Not a typo // Not animated -> Monster if (battler->GetBattleAnimationId() == 0) { if (sprite_name.empty()) { graphic = Bitmap::Create(0, 0); SetOx(graphic->GetWidth() / 2); SetOy(graphic->GetHeight() / 2); SetBitmap(graphic); } else { FileRequestAsync* request = AsyncHandler::RequestFile("Monster", sprite_name); request_id = request->Bind(&Sprite_Battler::OnMonsterSpriteReady, this); request->Start(); } } else { // animated SetOx(24); SetOy(24); SetAnimationState(anim_state); idling = true; } SetVisible(!battler->IsHidden()); }
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()); }
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()); }
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); }*/ }
Sprite_AirshipShadow::Sprite_AirshipShadow() { SetBitmap(Bitmap::Create(16,16)); SetOx(TILE_SIZE/2); SetOy(TILE_SIZE); RecreateShadow(); }
void Sprite_Character::OnTileSpriteReady(FileRequestResult*) { BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id); SetBitmap(tile); Rect r; r.Set(0, 0, TILE_SIZE, TILE_SIZE); SetSrcRect(r); SetOx(8); SetOy(16); Update(); }
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(); }
void Sprite_Battler::OnMonsterSpriteReady(FileRequestResult* result) { graphic = Cache::Monster(result->file); SetOx(graphic->GetWidth() / 2); SetOy(graphic->GetHeight() / 2); bool hue_change = hue != 0; if (hue_change) { BitmapRef new_graphic = Bitmap::Create(graphic->GetWidth(), graphic->GetHeight()); new_graphic->HueChangeBlit(0, 0, *graphic, graphic->GetRect(), hue); graphic = new_graphic; } SetBitmap(graphic); }
void BattleAnimation::DrawAt(int x, int y) { if (IsDone()) { return; } if (!GetVisible()) { return; } const RPG::AnimationFrame& anim_frame = animation.frames[frame]; std::vector<RPG::AnimationCellData>::const_iterator it; for (it = anim_frame.cells.begin(); it != anim_frame.cells.end(); ++it) { const RPG::AnimationCellData& cell = *it; if (!cell.valid) { // Skip unused cells (they are created by deleting cells in the // animation editor, resulting in gaps) continue; } SetX(cell.x + x); SetY(cell.y + y); int sx = cell.cell_id % 5; int sy = cell.cell_id / 5; int size = large ? 128 : 96; SetSrcRect(Rect(sx * size, sy * size, size, size)); SetOx(size / 2); SetOy(size / 2); SetTone(Tone(cell.tone_red * 128 / 100, cell.tone_green * 128 / 100, cell.tone_blue * 128 / 100, cell.tone_gray * 128 / 100)); SetOpacity(255 * (100 - cell.transparency) / 100); SetZoomX(cell.zoom / 100.0); SetZoomY(cell.zoom / 100.0); Sprite::Draw(); } if (anim_frame.cells.empty()) { // Draw an empty sprite when no cell is available in the animation SetSrcRect(Rect(0, 0, 0, 0)); Sprite::Draw(); } }