Really low graphics patch thanks to Stephan Beyer
[crack-attack.git] / src / Random.cxx
blobf7e0f0f40efaa6f0a53e1e45c9047c59b513ed6a
1 /*
2 * Random.cxx
3 * Daniel Nelson - 11/10/0
5 * Copyright (C) 2000 Daniel Nelson
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Daniel Nelson - aluminumangel.org
22 * 174 W. 18th Ave.
23 * Columbus, OH 43210
25 * Handles all the random number tables.
28 #include <ctime>
30 using namespace std;
32 #include "Game.h"
33 #include "Random.h"
35 Angle Random::angle_table[GC_SIZE_RANDOM_ANGLE_TABLE];
36 Angle Random::angle_death_spark_table[GC_SIZE_RANDOM_ANGLE_TABLE];
37 Angle Random::angle_celebration_spark_1_table[GC_SIZE_RANDOM_ANGLE_TABLE];
38 Angle Random::angle_celebration_spark_2_table[GC_SIZE_RANDOM_ANGLE_TABLE];
40 void Random::seed ( unsigned int seed )
42 * Called by Communicator to seed the random numbers.
45 srand(seed);
48 unsigned int Random::generateSeed ( )
50 * Called by Communicator if we're the server. The result is used to seed our
51 * random numbers as well as sent to the client for theirs.
54 return (unsigned int) time(null);
57 void Random::initialize ( )
59 * Attack calls seed() before this.
62 for (int n = GC_SIZE_RANDOM_ANGLE_TABLE; n--; ) {
63 float angle = (2.0f * PI) * Random::number();
64 angle_table[n].x = cos(angle);
65 angle_table[n].y = sin(angle);
68 for (int n = GC_SIZE_RANDOM_ANGLE_TABLE; n--; ) {
69 float angle = (PI / 4.0f) + (PI / 2.0f) * Random::number();
70 angle_death_spark_table[n].x = cos(angle);
71 angle_death_spark_table[n].y = sin(angle);
74 for (int n = GC_SIZE_RANDOM_ANGLE_TABLE; n--; ) {
75 float angle = (3.0f * PI / 16.0f) + (PI / 8.0f) * Random::number();
76 angle_celebration_spark_1_table[n].x = cos(angle);
77 angle_celebration_spark_1_table[n].y = sin(angle);
80 for (int n = GC_SIZE_RANDOM_ANGLE_TABLE; n--; ) {
81 float angle = (7.0f * PI / 16.0f) + (PI / 8.0f) * Random::number();
82 angle_celebration_spark_2_table[n].x = cos(angle);
83 angle_celebration_spark_2_table[n].y = sin(angle);