3 * Daniel Nelson - 11/10/0
5 * Copyright (C) 2000 Daniel Nelson
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
25 * Handles all the random number tables.
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.
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
);