equal
deleted
inserted
replaced
6 procedure AddObjects(Surface: PSDL_Surface); |
6 procedure AddObjects(Surface: PSDL_Surface); |
7 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface); |
7 procedure BlitImageAndGenerateCollisionInfo(cpX, cpY: Longword; Image, Surface: PSDL_Surface); |
8 |
8 |
9 implementation |
9 implementation |
10 uses uLand, uStore, uConsts, uMisc, uConsole, uRandom; |
10 uses uLand, uStore, uConsts, uMisc, uConsole, uRandom; |
11 const MaxRects = 1024; |
11 const MaxRects = 256; |
12 MAXOBJECTRECTS = 32; |
12 MAXOBJECTRECTS = 16; |
13 type PRectArray = ^TRectsArray; |
13 type PRectArray = ^TRectsArray; |
14 TRectsArray = array[0..MaxRects] of TSDL_rect; |
14 TRectsArray = array[0..MaxRects] of TSDL_rect; |
15 |
15 |
16 type TThemeObject = record |
16 type TThemeObject = record |
17 Surf: PSDL_Surface; |
17 Surf: PSDL_Surface; |
108 (y < y1 + h1) and (y1 < y + h); |
108 (y < y1 + h1) and (y1 < y + h); |
109 inc(i) |
109 inc(i) |
110 until (i = RectCount) or (Result) |
110 until (i = RectCount) or (Result) |
111 end; |
111 end; |
112 |
112 |
113 procedure AddGirders(Surface: PSDL_Surface); |
113 function AddGirder(gX: integer; Surface: PSDL_Surface): boolean; |
114 var tmpsurf: PSDL_Surface; |
114 var tmpsurf: PSDL_Surface; |
115 x1, x2, y, k, i: integer; |
115 x1, x2, y, k, i: integer; |
116 r, rr: TSDL_Rect; |
116 r, rr: TSDL_Rect; |
117 |
117 |
118 function CountNonZeroz(x, y: integer): Longword; |
118 function CountNonZeroz(x, y: integer): Longword; |
122 for i:= y to y + 15 do |
122 for i:= y to y + 15 do |
123 if Land[i, x] <> 0 then inc(Result) |
123 if Land[i, x] <> 0 then inc(Result) |
124 end; |
124 end; |
125 |
125 |
126 begin |
126 begin |
127 y:= 256; |
127 y:= 150; |
128 repeat |
128 repeat |
129 inc(y, 24); |
129 inc(y, 24); |
130 x1:= 1024; |
130 x1:= gX; |
131 x2:= 1024; |
131 x2:= gX; |
132 while (x1 > 100) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); |
132 while (x1 > 100) and (CountNonZeroz(x1, y) = 0) do dec(x1, 2); |
133 i:= x1 - 12; |
133 i:= x1 - 12; |
134 repeat |
134 repeat |
135 k:= CountNonZeroz(x1, y); |
135 k:= CountNonZeroz(x1, y); |
136 dec(x1, 2) |
136 dec(x1, 2) |
149 end; |
149 end; |
150 x1:= 0; |
150 x1:= 0; |
151 until y > 900; |
151 until y > 900; |
152 if x1 > 0 then |
152 if x1 > 0 then |
153 begin |
153 begin |
|
154 Result:= true; |
154 tmpsurf:= LoadImage(Pathz[ptGraphics] + 'Girder.png'); |
155 tmpsurf:= LoadImage(Pathz[ptGraphics] + 'Girder.png'); |
155 rr.x:= x1; |
156 rr.x:= x1; |
156 rr.y:= y; |
157 rr.y:= y; |
157 while rr.x + 100 < x2 do |
158 while rr.x + 100 < x2 do |
158 begin |
159 begin |
163 r.y:= 0; |
164 r.y:= 0; |
164 r.w:= x2 - rr.x; |
165 r.w:= x2 - rr.x; |
165 r.h:= 16; |
166 r.h:= 16; |
166 SDL_UpperBlit(tmpsurf, @r, Surface, @rr); |
167 SDL_UpperBlit(tmpsurf, @r, Surface, @rr); |
167 SDL_FreeSurface(tmpsurf); |
168 SDL_FreeSurface(tmpsurf); |
168 AddRect(x1 - 8, y - 8, x2 - x1 + 8, 32); |
169 AddRect(x1 - 8, y - 8, x2 - x1 + 16, 72); |
169 for k:= y to y + 15 do |
170 for k:= y to y + 15 do |
170 for i:= x1 to x2 do Land[k, i]:= $FFFFFF |
171 for i:= x1 to x2 do Land[k, i]:= $FFFFFF |
171 end |
172 end else Result:= false |
172 end; |
173 end; |
173 |
174 |
174 function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean; |
175 function CheckLand(rect: TSDL_Rect; dX, dY, Color: Longword): boolean; |
175 var i: Longword; |
176 var i: Longword; |
176 begin |
177 begin |
185 inc(i) |
186 inc(i) |
186 end; |
187 end; |
187 i:= 0; |
188 i:= 0; |
188 while (i <= rect.h) and Result do |
189 while (i <= rect.h) and Result do |
189 begin |
190 begin |
190 Result:= (Land[rect.y + i, rect.x] = Color) or (Land[rect.y + i, rect.x + rect.w] = Color); |
191 Result:= (Land[rect.y + i, rect.x] = Color) and (Land[rect.y + i, rect.x + rect.w] = Color); |
191 inc(i) |
192 inc(i) |
192 end; |
193 end; |
193 {$WARNINGS ON} |
194 {$WARNINGS ON} |
194 end; |
195 end; |
195 |
196 |
234 begin |
235 begin |
235 y:= 5000; |
236 y:= 5000; |
236 x:= 5000; |
237 x:= 5000; |
237 end |
238 end |
238 end; |
239 end; |
239 inc(y, 2); |
240 inc(y, 3); |
240 until y > 1023 - Height; |
241 until y > 1023 - Height; |
241 inc(x, getrandom(8) + 2) |
242 inc(x, getrandom(6) + 3) |
242 until x > 2047 - Width; |
243 until x > 2047 - Width; |
243 Result:= cnt <> 0; |
244 Result:= cnt <> 0; |
244 if Result then |
245 if Result then |
245 begin |
246 begin |
246 i:= getrandom(cnt); |
247 i:= getrandom(cnt); |
249 end |
250 end |
250 end |
251 end |
251 end; |
252 end; |
252 |
253 |
253 procedure AddThemeObjects(Surface: PSDL_Surface; MaxCount: Longword); |
254 procedure AddThemeObjects(Surface: PSDL_Surface; MaxCount: Longword); |
254 const MAXTHEMEOBJECTS = 16; |
255 const MAXTHEMEOBJECTS = 32; |
255 var f: textfile; |
256 var f: textfile; |
256 s: string; |
257 s: string; |
257 ThemeObjects: array[1..MAXTHEMEOBJECTS] of TThemeObject; |
258 ThemeObjects: array[1..MAXTHEMEOBJECTS] of TThemeObject; |
258 i, ii, t, n: Longword; |
259 i, ii, t, n: Longword; |
259 b: boolean; |
260 b: boolean; |
299 end; |
300 end; |
300 |
301 |
301 procedure AddObjects(Surface: PSDL_Surface); |
302 procedure AddObjects(Surface: PSDL_Surface); |
302 begin |
303 begin |
303 InitRects; |
304 InitRects; |
304 AddGirders(Surface); |
305 AddGirder(512, Surface); |
305 AddThemeObjects(Surface, 5); |
306 AddGirder(1024, Surface); |
|
307 AddGirder(1300, Surface); |
|
308 AddGirder(1536, Surface); |
|
309 AddThemeObjects(Surface, 8); |
306 FreeRects |
310 FreeRects |
307 end; |
311 end; |
308 |
312 |
309 end. |
313 end. |