MCPcopy Create free account
hub / github.com/EasyRPG/Player / Draw

Method Draw

src/sprite_enemy.cpp:91–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91void Sprite_Enemy::Draw(Bitmap& dst) {
92
93 auto alpha = 255;
94 auto zoom = 1.0;
95
96 auto* enemy = static_cast<Game_Enemy*>(GetBattler());
97
98 const auto bt = enemy->GetBlinkTimer();
99 const auto dt = enemy->GetDeathTimer();
100 const auto et = enemy->GetExplodeTimer();
101
102 if (!enemy->Exists() && dt == 0 && et == 0) {
103 return;
104 }
105
106 if (bt % 10 >= 5) {
107 return;
108 }
109
110 if (dt > 0) {
111 alpha = 7 * dt;
112 } else if (et > 0) {
113 alpha = 12 * et;
114 zoom = static_cast<double>(20 - et) / 20.0 + 1.0;
115 }
116
117 if (enemy->IsTransparent()) {
118 alpha = 160 * alpha / 255;
119 }
120
121 SetOpacity(alpha);
122 SetZoomX(zoom);
123 SetZoomY(zoom);
124
125 SetTone(Main_Data::game_screen->GetTone());
126 SetX(enemy->GetDisplayX());
127 SetY(enemy->GetDisplayY());
128 SetFlashEffect(enemy->GetFlashColor());
129 if (fixed_facing != Disabled) {
130 SetFixedFlipX();
131 } else {
132 SetFlipX(enemy->IsDirectionFlipped());
133 }
134
135 Sprite_Battler::Draw(dst);
136}
137
138void Sprite_Enemy::Refresh() {
139 if (sprite_name != GetBattler()->GetSpriteName() || hue != GetBattler()->GetHue()) {

Callers

nothing calls this directly

Calls 10

GetBlinkTimerMethod · 0.80
GetDeathTimerMethod · 0.80
GetExplodeTimerMethod · 0.80
IsDirectionFlippedMethod · 0.80
ExistsMethod · 0.45
IsTransparentMethod · 0.45
GetToneMethod · 0.45
GetDisplayXMethod · 0.45
GetDisplayYMethod · 0.45
GetFlashColorMethod · 0.45

Tested by

no test coverage detected