Debian Codegraph @

src/target.cpp

raw symbols SCIP
1 ///////////////////////////////////////////////cxx . . $ `<file>/src/target.cpp`/
2 //
3 // Snipe2d ludum dare 48h compo entry
4 //
5 // Jari Komppa aka Sol
6 // http://iki.fi/sol
7 //
8 ///////////////////////////////////////////////
9 // License
10 ///////////////////////////////////////////////
11 //
12 // This software is provided 'as-is', without any express or implied
13 // warranty. In no event will the authors be held liable for any damages
14 // arising from the use of this software.
15 //
16 // Permission is granted to anyone to use this software for any purpose,
17 // including commercial applications, and to alter it and redistribute it
18 // freely, subject to the following restrictions:
19 //
20 // 1. The origin of this software must not be misrepresented; you must not
21 // claim that you wrote the original software. If you use this software
22 // in a product, an acknowledgment in the product documentation would be
23 // appreciated but is not required.
24 // 2. Altered source versions must be plainly marked as such, and must not be
25 // misrepresented as being the original software.
26 // 3. This notice may not be removed or altered from any source distribution.
27 //
28 // (eg. same as ZLIB license)
29 //
30 ///////////////////////////////////////////////
31 //
32 // Houses are taken from a satellite picture of glasgow.
33 //
34 // The sources are a mess, as I didn't even try to do anything
35 // really organized here.. and hey, it's a 48h compo =)
36 //
37 #include "snipe2d.h"cxx . . $ `<file>/src/snipe2d.h`/
38
39 void targetcxx . . $ target(49f6e7a06ebc5aa8).()
40 {
41 static int lastBadGuys = -1;
42 static int lastVIPs = -1;
43 static int badGuysChangeTick = 0;
44 static int VIPsChangeTick = 0;
45
46 int tick = SDL_GetTicks();
47
48 if (lastBadGuys != Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.)
49 {
50 lastBadGuys = Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.;
51 badGuysChangeTick = tick;
52 }
53 if (lastVIPs != Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.)
54 {
55 lastVIPs = Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.;
56 VIPsChangeTick = tick;
57 }
58
59 if ( SDL_LockSurface(Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.) < 0 )
60 return;
61
62 int i;
63 short *tgt = (short*)Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pixels;
64
65 if (Gamecxx . . $ Game..Reloadingcxx . . $ orbitalsniper_t#Reloading.)
66 {
67 float distance = Gamecxx . . $ Game..Reloadingcxx . . $ orbitalsniper_t#Reloading. / (float)Gamecxx . . $ Game..ReloadTimecxx . . $ orbitalsniper_t#ReloadTime.;
68 distance = distance * distance * distance;
69
70 int ofs = (Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2) * 240;
71 for (i = 0; i < 640; i++, ofs++)
72 tgt[ofs] = (short)0;
73
74 ofs = 320;
75 for (i = 0; i < 480; i++, ofs += Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2)
76 tgt[ofs] = (short)0;
77
78 ofs = (Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2) * (int)(240 + distance * 200);
79 for (i = 0; i < 640; i++, ofs++)
80 tgt[ofs] = (short)0xC000;
81
82 ofs = (Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2) * (int)(240 - distance * 200);
83 for (i = 0; i < 640; i++, ofs++)
84 tgt[ofs] = (short)0xC000;
85
86 ofs = (int)(320 + distance * 300);
87 for (i = 0; i < 480; i++, ofs += Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2)
88 tgt[ofs] = (short)0xC000;
89
90 ofs = (int)(320 - distance * 300);
91 for (i = 0; i < 480; i++, ofs += Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2)
92 tgt[ofs] = (short)0xC000;
93
94 SDL_UnlockSurface(Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.);
95
96 }
97 else // not reloading
98 {
99 int ofs = (Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2) * 240;
100 for (i = 0; i < 640; i++, ofs++)
101 tgt[ofs] = (short)0xff00;
102
103 ofs = 320;
104 for (i = 0; i < 480; i++, ofs += Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.->pitch / 2)
105 tgt[ofs] = (short)0xff00;
106
107 SDL_UnlockSurface(Gamecxx . . $ Game..Screencxx . . $ orbitalsniper_t#Screen.);
108 }
109
110 int row;
111 row = 196;
112 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 1) printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "time: %02d:%02d", ((SDL_GetTicks() -
113 Gamecxx . . $ Game..GameStartTickcxx . . $ orbitalsniper_t#GameStartTick.) / 60000), ((SDL_GetTicks() - Gamecxx . . $ Game..GameStartTickcxx . . $ orbitalsniper_t#GameStartTick.) / 1000)%60);
114 row += 7;
115 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 1) {
116 if ((tick - VIPsChangeTick) < 500)
117 printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_GREENcxx . . $ COLOR_GREEN., "VIPs %6d", Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.);
118 else
119 printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "VIPs %6d", Gamecxx . . $ Game..vipcxx . . $ orbitalsniper_t#vip..countcxx . . $ charcount_t#count.);
120 }
121 row += 7;
122 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 2) {
123 if ((tick - badGuysChangeTick) < 500)
124 printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_REDcxx . . $ COLOR_RED., "Threat %6d", Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.);
125 else
126 printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "Threat %6d", Gamecxx . . $ Game..baddycxx . . $ orbitalsniper_t#baddy..countcxx . . $ charcount_t#count.);
127 }
128 row += 7;
129 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 2) printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "Score%09.8d", Gamecxx . . $ Game..Scorecxx . . $ orbitalsniper_t#Score.);
130 row += 7;
131 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 2) printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "FPS %3.3f", (Gamecxx . . $ Game..FrameCountcxx . . $ orbitalsniper_t#FrameCount. * 1000.0f) / (tick - Gamecxx . . $ Game..StartTickcxx . . $ orbitalsniper_t#StartTick.));
132 row += 7;
133 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 1) printcxx . . $ print(e6b86272566182ce).(324, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "Zoom %7.0fx", (1.0f / Gamecxx . . $ Game..CoordScalecxx . . $ orbitalsniper_t#CoordScale.) * 100);
134 row = 244;
135 if(Gamecxx . . $ Game..verbositycxx . . $ orbitalsniper_t#verbosity. >= 2) {
136 if (Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) {
137 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (tick >> 4) * 700);
138 row += 7;
139 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (tick >> 3) * 1337);
140 row += 7;
141 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (tick >> 2) * 4);
142 row += 7;
143 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (tick >> 1) * 4935);
144 row += 7;
145 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (int)(Gamecxx . . $ Game..MouseXcxx . . $ orbitalsniper_t#MouseX. * 0xc0c4c01a) - (tick >> 3));
146 row += 7;
147 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (int)(Gamecxx . . $ Game..MouseYcxx . . $ orbitalsniper_t#MouseY. * 0xb4be2b3d) - (tick >> 4));
148 row += 7;
149 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (tick << 4) * 4095);
150 row += 7;
151 printcxx . . $ print(e6b86272566182ce).(278, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%10x", (int)(Gamecxx . . $ Game..MouseZcxx . . $ orbitalsniper_t#MouseZ. * 0xf00ba573) - (tick >> 5));
152 }
153 else {
154 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Citizen profile");
155 row += 7;
156 row += 7;
157 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Coordinates");
158 row += 7;
159 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., " %6.2f - %6.2f", Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mXcxx . . $ character_#mX., Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mYcxx . . $ character_#mY.);
160 row += 7;
161 row += 7;
162 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Classification");
163 row += 7;
164 switch (Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTypecxx . . $ character_#mType.)
165 {
166 case 0:
167 printcxx . . $ print(e6b86272566182ce).(239, row + 1, COLOR_BLACKcxx . . $ COLOR_BLACK., "%20s", "** THREAT **");
168 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_REDcxx . . $ COLOR_RED., "%20s", "** THREAT **");
169 row += 7;
170 row += 7;
171 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Destination");
172 row += 7;
173 if (Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget. != -1)
174 {
175 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., " %6.2f - %6.2f", Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY.);
176 row += 7;
177 row += 7;
178 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Distance");
179 row += 7;
180 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., " %15.2f", distancecxx . . $ distance(95d5df56d1097f86).(Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mXcxx . . $ character_#mX., Gamecxx . . $ Game..characterscxx . . $ orbitalsniper_t#characters.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mYcxx . . $ character_#mY., Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mXcxx . . $ character_#mX., Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mYcxx . . $ character_#mY.));
181 }
182 else
183 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Unknown");
184 row += 7;
185 row += 7;
186 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "VPB file ID");
187 row += 7;
188 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., " %03X-%07X/%02X",
189 ((((uintptr_tcxx . . $ uintptr_t#)Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.) * 7001337) & 0xfff),
190 (((uintptr_tcxx . . $ uintptr_t#)Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.) * 1337357) & 0xfffffff,
191 (((uintptr_tcxx . . $ uintptr_t#)Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.) * 70741) & 0xff);
192
193
194 break;
195 case 1:
196 printcxx . . $ print(e6b86272566182ce).(239, row + 1, COLOR_BLACKcxx . . $ COLOR_BLACK., "%20s", "- VIP -");
197 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_GREENcxx . . $ COLOR_GREEN., "%20s", "- VIP -");
198 row += 7;
199 row += 7;
200 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Destination");
201 row += 7;
202 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., " %6.2f - %6.2f", (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY.);
203 row += 7;
204 row += 7;
205 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Distance");
206 row += 7;
207 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., " %15.2f", distancecxx . . $ distance(95d5df56d1097f86).((float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mXcxx . . $ spawnpointstruc#mX., (float)Gamecxx . . $ Game..spawnpointscxx . . $ orbitalsniper_t#spawnpoints.[Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mTargetcxx . . $ character_#mTarget.].mYcxx . . $ spawnpointstruc#mY., Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mXcxx . . $ character_#mX., Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.->mYcxx . . $ character_#mY.));
208 row += 7;
209 row += 7;
210 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Net worth");
211 row += 7;
212 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Classified");
213 break;
214 case 2:
215 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Citizen");
216 row += 7;
217 row += 7;
218 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Net worth");
219 row += 7;
220 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%17u KC", (((uintptr_tcxx . . $ uintptr_t#)Gamecxx . . $ Game..SightedCharactercxx . . $ orbitalsniper_t#SightedCharacter.) * 1337357) % 71937);
221 break;
222 case 3:
223 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_YELLOWcxx . . $ COLOR_YELLOW., "%20s", "Splat.");
224 break;
225 case 4:
226 printcxx . . $ print(e6b86272566182ce).(238, row, COLOR_BLACKcxx . . $ COLOR_BLACK., "%20s", "Missed shot");
227 break;
228 }
229 row += 7;
230
231 }
232 }
233
234 if (Gamecxx . . $ Game..FrameCountcxx . . $ orbitalsniper_t#FrameCount. > 100)
235 {
236 Gamecxx . . $ Game..FrameCountcxx . . $ orbitalsniper_t#FrameCount. = 0;
237 Gamecxx . . $ Game..StartTickcxx . . $ orbitalsniper_t#StartTick. = tick;
238 }
239
240 }
241