MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / OnBeforeUserUpdate

Method OnBeforeUserUpdate

extensions/olcPGEX_SplashScreen.h:175–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173 }
174
175 bool SplashScreen::OnBeforeUserUpdate(float& fElapsedTime)
176 {
177 if (bComplete) return false;
178
179 fParticleTime += fElapsedTime;
180
181 for (int y = 0; y < spr.Sprite()->height; y++)
182 for (int x = 0; x < spr.Sprite()->width; x++)
183 {
184
185
186 if (fParticleTime < 1.0f)
187 {
188
189 }
190 else if (fParticleTime < 2.0f)
191 {
192 vBoom[y * spr.Sprite()->width + x].first =
193 olc::vf2d(
194 (250 - spr.Sprite()->width) / 2.0f + float(x),
195 (250 - spr.Sprite()->height) / 2.0f / fAspect + float(y)
196 ) +
197 olc::vf2d(
198 (float(rand()) / float(RAND_MAX)) * 0.5f - 0.25f,
199 (float(rand()) / float(RAND_MAX)) * 0.5f - 0.25f);
200 }
201 else if(fParticleTime < 5.0f)
202 {
203 vBoom[y * spr.Sprite()->width + x].first += vBoom[y * spr.Sprite()->width + x].second * fElapsedTime * 20.0f;
204 }
205 else
206 {
207 bComplete = true;
208 }
209
210 pge->DrawPartialDecal(vScale * vBoom[y * spr.Sprite()->width + x].first * 2.0f, spr.Decal(), olc::vf2d(float(x), float(y)), { 1, 1 }, vScale * 2.0f, olc::PixelF(1.0f, 1.0f, 1.0f, std::min(1.0f, std::max(4.0f - fParticleTime, 0.0f))));
211 }
212
213 olc::vi2d vSize = pge->GetTextSizeProp("Copyright OneLoneCoder.com 2025");
214 pge->DrawStringPropDecal(olc::vf2d(float(pge->ScreenWidth()/2) - vSize.x/2, float(pge->ScreenHeight()) - vSize.y * 3.0f), "Copyright OneLoneCoder.com 2025", olc::PixelF(1.0f, 1.0f, 1.0f, 0.5f), olc::vf2d(1.0, 2.0f));
215 return true;
216 }
217
218}
219

Callers

nothing calls this directly

Calls 8

PixelFFunction · 0.85
DecalMethod · 0.80
GetTextSizePropMethod · 0.80
ScreenWidthMethod · 0.80
ScreenHeightMethod · 0.80
SpriteMethod · 0.45
DrawPartialDecalMethod · 0.45
DrawStringPropDecalMethod · 0.45

Tested by

no test coverage detected