Starshatter_Open
Open source Starshatter engine
Main Page
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Asteroid.cpp
Go to the documentation of this file.
1
/* Project Starshatter 4.5
2
Destroyer Studios LLC
3
Copyright © 1997-2004. All Rights Reserved.
4
5
SUBSYSTEM: Stars.exe
6
FILE: Asteroid.cpp
7
AUTHOR: John DiCamillo
8
9
10
OVERVIEW
11
========
12
Asteroid Sprite animation class
13
*/
14
15
#include "
MemDebug.h
"
16
#include "
Asteroid.h
"
17
#include "
Shot.h
"
18
#include "
Explosion.h
"
19
#include "
Sim.h
"
20
21
#include "
Solid.h
"
22
#include "
Bitmap.h
"
23
#include "
DataLoader.h
"
24
#include "
Game.h
"
25
26
// +--------------------------------------------------------------------+
27
28
static
Point
asteroid_velocity =
Point
(0,0,0);
29
static
Model
* asteroid_model[32];
30
31
// +--------------------------------------------------------------------+
32
33
Asteroid::Asteroid
(
int
t,
const
Vec3
& pos,
double
m)
34
:
Debris
(asteroid_model[t%6], pos, asteroid_velocity, m)
35
{
36
life
= -1;
37
}
38
39
// +--------------------------------------------------------------------+
40
41
void
42
Asteroid::Initialize
()
43
{
44
ZeroMemory(asteroid_model,
sizeof
(asteroid_model));
45
46
DataLoader
* loader =
DataLoader::GetLoader
();
47
Text
old_path = loader->
GetDataPath
();
48
loader->
SetDataPath
(
"Galaxy/Asteroids/"
);
49
50
int
n = 0;
51
52
Model
* a =
new
(__FILE__,__LINE__)
Model
;
53
if
(a) {
54
a->
Load
(
"a1.mag"
, 100);
55
asteroid_model[n++] = a;
56
}
57
58
a =
new
(__FILE__,__LINE__)
Model
;
59
if
(a) {
60
a->
Load
(
"a2.mag"
, 50);
61
asteroid_model[n++] = a;
62
}
63
64
a =
new
(__FILE__,__LINE__)
Model
;
65
if
(a) {
66
a->
Load
(
"a1.mag"
, 8);
67
asteroid_model[n++] = a;
68
}
69
70
a =
new
(__FILE__,__LINE__)
Model
;
71
if
(a) {
72
a->
Load
(
"a2.mag"
, 10);
73
asteroid_model[n++] = a;
74
}
75
76
a =
new
(__FILE__,__LINE__)
Model
;
77
if
(a) {
78
a->
Load
(
"a3.mag"
, 30);
79
asteroid_model[n++] = a;
80
}
81
82
a =
new
(__FILE__,__LINE__)
Model
;
83
if
(a) {
84
a->
Load
(
"a4.mag"
, 20);
85
asteroid_model[n++] = a;
86
}
87
88
List<Text>
mod_asteroids;
89
loader->
SetDataPath
(
"Mods/Galaxy/Asteroids/"
);
90
loader->
ListFiles
(
"*.mag"
, mod_asteroids);
91
92
ListIter<Text>
iter = mod_asteroids;
93
while
(++iter && n < 32) {
94
a =
new
(__FILE__,__LINE__)
Model
;
95
if
(a) {
96
a->
Load
(*iter.
value
(), 50);
97
asteroid_model[n++] = a;
98
}
99
}
100
101
loader->
SetDataPath
(old_path);
102
}
103
104
void
105
Asteroid::Close
()
106
{
107
for
(
int
i = 0; i < 32; i++)
108
delete
asteroid_model[i];
109
110
ZeroMemory(asteroid_model,
sizeof
(asteroid_model));
111
}
112
113
// +--------------------------------------------------------------------+
114
115
116
Stars45
Asteroid.cpp
Generated on Tue Jun 5 2012 20:46:44 for Starshatter_Open by
1.8.1