C++ Project 2016-2017: Arkanoid
src
arkanoid
logic
math
random.cpp
Go to the documentation of this file.
1
3
#include "
random.h
"
4
5
#include <iostream>
6
#include <time.h>
7
8
using namespace
std
;
9
10
namespace
arkanoid
{
11
12
// Initialise singleton with nullptr at start
13
Random* Random::singleton =
nullptr
;
14
15
Random::Random() {
16
// Set random seed
17
srand(time(NULL));
18
}
19
20
Random
* Random::getInstance() {
21
if
(!singleton) {
22
// Create instance
23
singleton =
new
Random
;
24
}
25
return
singleton;
26
}
27
28
double
Random::randomDouble(
int
from,
int
to) {
29
return
static_cast<
double
>
((rand() % (to - from + 1)) + from);
30
}
31
32
}
std
arkanoid::Random
Singleton: generates "random" numbers.
Definition:
random.h:14
random.h
arkanoid
All the game logic of the Arkanoid game.
Definition:
ball.cpp:15
Generated by
1.8.13