From b35142b831f0f89522b1203964841eeb2729bf71 Mon Sep 17 00:00:00 2001 From: Raikem Date: Sat, 25 Feb 2017 20:49:12 +0100 Subject: [PATCH] Improve random spawn of asteroids --- Engine/Game.cpp | 5 +++-- Engine/Game.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Engine/Game.cpp b/Engine/Game.cpp index 5dd1de7..06a27c3 100644 --- a/Engine/Game.cpp +++ b/Engine/Game.cpp @@ -31,7 +31,8 @@ Game::Game( MainWindow& wnd ) explosionSound( L"explosion.wav"), gameoverSound( L"collision.wav"), coinSound( L"coin.wav"), - music( L"music.wav",0.0f, 6.0f) //6.857142f + music( L"music.wav",0.0f, 6.0f), //6.857142f is the end of the file, but it makes a weird loop + rng( rd() ) { } @@ -117,7 +118,7 @@ void Game::UpdateModel() { lasers[j].SetIsUsed(false); score++; - asteroids[i].Spawn( rng, gfx, ship); + asteroids[i].Spawn( rng , gfx, ship); explosionSound.Play(); coinSound.Play(1.0f,0.5f); } diff --git a/Engine/Game.h b/Engine/Game.h index 07b25f8..9009b4d 100644 --- a/Engine/Game.h +++ b/Engine/Game.h @@ -54,6 +54,7 @@ class Game FrameTimer spaceBarCooldown; Asteroid asteroids[nAsteroids]; Laser lasers[maxLaser]; + std::random_device rd; std::mt19937 rng; bool isShipAcc = false; bool gameOver = true;