Skip to content

Commit

Permalink
Fix sparks
Browse files Browse the repository at this point in the history
  • Loading branch information
Matqyou committed Dec 13, 2024
1 parent 552faa8 commit 590c418
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
Binary file added bin/assets/sounds/glitch/9.wav
Binary file not shown.
2 changes: 1 addition & 1 deletion src/game/GameWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ void GameWorld::Draw()
Render->RenderTextureCamera(m_Background->SDLTexture(), nullptr, DestinationRect);

SDL_Rect DrawRect = {0, 0, int(m_Width), int(m_Height)};
Render->SetColor(255, 0, 0, 255);
Render->SetColor(100, 100, 100, 255);
Render->DrawRectCamera(DrawRect);

m_Particles->Draw();
Expand Down
27 changes: 22 additions & 5 deletions src/game/entities/Projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,29 @@ void Projectile::TickWallCollision() {
m_Core.Pos.y < 0 || m_Core.Pos.y > m_World->GetHeight()) {
sMetalImpactSounds[rand() % 2].GetSound()->PlaySound();

if (m_Core.Pos.x < 0 || m_Core.Pos.x > m_World->GetWidth()) { m_Core.Vel.x *= -1; }
if (m_Core.Pos.y < 0 || m_Core.Pos.y > m_World->GetHeight()) { m_Core.Vel.y *= -1; }
if (m_Core.Pos.x < 0) {
m_Core.Pos.x = 0;
m_Core.Vel.x *= -1;
}
if (m_Core.Pos.x > m_World->GetWidth()) {
m_Core.Pos.x = m_World->GetWidth();
m_Core.Vel.x *= -1;
}
if (m_Core.Pos.y < 0) {
m_Core.Pos.y = 0;
m_Core.Vel.y *= -1;
}
if (m_Core.Pos.y > m_World->GetHeight()) {
m_Core.Pos.y = m_World->GetHeight();
m_Core.Vel.y *= -1;
}
for (int i = 0; i < 6; i++) {
auto vel = Vec2d(m_Core.Vel.x * (0.15 + 0.1 * (double)(rand()) / RAND_MAX) + 0.05 * (double)(rand()) / RAND_MAX,
m_Core.Vel.y * (0.15 + 0.1 * (double)(rand()) / RAND_MAX) + 0.05 * (double)(rand()) / RAND_MAX);
m_World->GetParticles()->PlayParticle(Particle(sTextureSpark.GetTexture(), m_Core.Pos, Vec2d(3.0, 5.0), vel, 0.98, 0.0, 0.0, 1.0, 20));
auto vel = Vec2d(m_Core.Vel.x * (0.1 + 0.17 * (double)(rand()) / RAND_MAX) + 0.05 * (double)(rand()) / RAND_MAX,
m_Core.Vel.y * (0.1 + 0.17 * (double)(rand()) / RAND_MAX) + 0.05 * (double)(rand()) / RAND_MAX);
auto orientation = vel.Atan2() / M_PI * 180.0;
auto lifetime = (unsigned long long)(6 + rand() % 25);
auto size = Vec2d(m_Core.Vel.Length() * 0.25 + ((double)(rand() % 100) / 100.0), 3.0);
m_World->GetParticles()->PlayParticle(Particle(sTextureSpark.GetTexture(), m_Core.Pos, size, vel, 0.98, orientation, 0.0, 1.0, lifetime));
}

m_Alive = false;
Expand Down

0 comments on commit 590c418

Please sign in to comment.