From 8898ad9b25fca6afe2374d293a981db02a83d7e9 Mon Sep 17 00:00:00 2001 From: "FWoltermann@gmail.com" Date: Thu, 31 May 2012 14:46:27 +0000 Subject: Committing the documentation to svn to have it accessible online --- Doc/doxygen/html/_nav_light_8cpp_source.html | 305 +++++++++++++++++++++++++++ 1 file changed, 305 insertions(+) create mode 100644 Doc/doxygen/html/_nav_light_8cpp_source.html (limited to 'Doc/doxygen/html/_nav_light_8cpp_source.html') diff --git a/Doc/doxygen/html/_nav_light_8cpp_source.html b/Doc/doxygen/html/_nav_light_8cpp_source.html new file mode 100644 index 0000000..8f7c01f --- /dev/null +++ b/Doc/doxygen/html/_nav_light_8cpp_source.html @@ -0,0 +1,305 @@ + + + + + +Starshatter_Open: D:/SRC/StarshatterSVN/Stars45/NavLight.cpp Source File + + + + + + + + + + + + + +
+
+ + + + + + +
+
Starshatter_Open +
+
Open source Starshatter engine
+
+
+ + + + + +
+
+ +
+
+
+ +
+ + + + +
+ +
+ +
+
+
NavLight.cpp
+
+
+Go to the documentation of this file.
1 /* Project Starshatter 5.0
+
2  Destroyer Studios LLC
+
3  Copyright © 1997-2007. All Rights Reserved.
+
4 
+
5  SUBSYSTEM: Stars.exe
+
6  FILE: NavLight.cpp
+
7  AUTHOR: John DiCamillo
+
8 
+
9 
+
10  OVERVIEW
+
11  ========
+
12  Navigation Light System class
+
13 */
+
14 
+
15 #include "MemDebug.h"
+
16 #include "NavLight.h"
+
17 
+
18 #include "Game.h"
+
19 #include "Bitmap.h"
+
20 #include "DataLoader.h"
+
21 
+
22 // +----------------------------------------------------------------------+
+
23 
+
24 static Bitmap* images[4];
+
25 
+
26 // +----------------------------------------------------------------------+
+
27 
+
28 NavLight::NavLight(double p, double s)
+
29 : System(COMPUTER, 32, "Navigation Lights", 1, 0),
+
30 period(p), nlights(0), scale(s), enable(true)
+
31 {
+
32  name = Game::GetText("sys.nav-light");
+
33  abrv = Game::GetText("sys.nav-light.abrv");
+
34 
+
35  ZeroMemory(beacon, sizeof(beacon));
+
36  ZeroMemory(beacon_type, sizeof(beacon_type));
+
37  ZeroMemory(pattern, sizeof(pattern));
+
38 }
+
39 
+
40 // +----------------------------------------------------------------------+
+
41 
+ +
43 : System(c), period(c.period), scale(c.scale),
+
44 nlights(0), enable(true)
+
45 {
+
46  Mount(c);
+ +
48  ZeroMemory(beacon, sizeof(beacon));
+
49  ZeroMemory(beacon_type, sizeof(beacon_type));
+
50 
+
51  nlights = c.nlights;
+
52 
+
53  for (int i = 0; i < nlights; i++) {
+
54  loc[i] = c.loc[i];
+
55  pattern[i] = c.pattern[i];
+
56  beacon_type[i] = c.beacon_type[i];
+
57 
+
58  DriveSprite* rep = new(__FILE__,__LINE__) DriveSprite(images[beacon_type[i]]);
+
59  rep->Scale(c.scale);
+
60 
+
61  beacon[i] = rep;
+
62  }
+
63 
+
64  offset = rand();
+
65 }
+
66 
+
67 // +--------------------------------------------------------------------+
+
68 
+ +
70 {
+
71  for (int i = 0; i < nlights; i++)
+ +
73 }
+
74 
+
75 // +--------------------------------------------------------------------+
+
76 
+
77 void
+ +
79 {
+
80  static int initialized = 0;
+
81  if (initialized) return;
+
82 
+ +
84  loader->LoadTexture("beacon1.pcx", images[0], Bitmap::BMP_TRANSLUCENT);
+
85  loader->LoadTexture("beacon2.pcx", images[1], Bitmap::BMP_TRANSLUCENT);
+
86  loader->LoadTexture("beacon3.pcx", images[2], Bitmap::BMP_TRANSLUCENT);
+
87  loader->LoadTexture("beacon4.pcx", images[3], Bitmap::BMP_TRANSLUCENT);
+
88 
+
89  initialized = 1;
+
90 }
+
91 
+
92 void
+ +
94 {
+
95 }
+
96 
+
97 // +--------------------------------------------------------------------+
+
98 
+
99 void
+
100 NavLight::ExecFrame(double seconds)
+
101 {
+
102  if (enable && power_on) {
+
103  double t = (Game::GameTime()+offset) / 1000.0;
+
104  DWORD n = (int) (fmod(t, period) * 32 / period);
+
105  DWORD code = 1 << n;
+
106 
+
107  for (int i = 0; i < nlights; i++) {
+
108  if (beacon[i]) {
+
109  if (pattern[i] & code)
+
110  beacon[i]->SetShade(1);
+
111  else
+
112  beacon[i]->SetShade(0);
+
113  }
+
114  }
+
115  }
+
116  else {
+
117  for (int i = 0; i < nlights; i++) {
+
118  if (beacon[i]) {
+
119  beacon[i]->SetShade(0);
+
120  }
+
121  }
+
122  }
+
123 }
+
124 
+
125 void
+ +
127 {
+
128  enable = true;
+
129 }
+
130 
+
131 void
+ +
133 {
+
134  enable = false;
+
135 }
+
136 
+
137 void
+
138 NavLight::AddBeacon(Point l, DWORD ptn, int t)
+
139 {
+
140  if (nlights < MAX_LIGHTS) {
+
141  loc[nlights] = l;
+
142  pattern[nlights] = ptn;
+
143  beacon_type[nlights] = t;
+
144 
+
145  DriveSprite* rep = new(__FILE__,__LINE__) DriveSprite(images[t]);
+
146  rep->Scale(scale);
+
147 
+
148  beacon[nlights] = rep;
+
149  nlights++;
+
150  }
+
151 }
+
152 
+
153 void
+ +
155 {
+
156  period = p;
+
157 }
+
158 
+
159 void
+
160 NavLight::SetPattern(int index, DWORD ptn)
+
161 {
+
162  if (index >= 0 && index < nlights)
+
163  pattern[index] = ptn;
+
164 }
+
165 
+
166 void
+ +
168 {
+
169  offset = o;
+
170 }
+
171 
+
172 // +--------------------------------------------------------------------+
+
173 
+
174 void
+ +
176 {
+
177  System::Orient(rep);
+
178 
+
179  const Matrix& orientation = rep->Cam().Orientation();
+
180  Point ship_loc = rep->Location();
+
181 
+
182  for (int i = 0; i < nlights; i++) {
+
183  Point projector = (loc[i] * orientation) + ship_loc;
+
184  if (beacon[i]) beacon[i]->MoveTo(projector);
+
185  }
+
186 }
+
187 
+
188 
+
+
+ + + + -- cgit v1.1