228 if Land[i, x] <> 0 then |
228 if Land[i, x] <> 0 then |
229 inc(lRes); |
229 inc(lRes); |
230 CountNonZeroz:= lRes; |
230 CountNonZeroz:= lRes; |
231 end; |
231 end; |
232 |
232 |
233 function AddGirder(gX: LongInt): boolean; |
233 function AddGirder(gX: LongInt; var girSurf: PSDL_Surface): boolean; |
234 var tmpsurf: PSDL_Surface; |
234 var x1, x2, y, k, i: LongInt; |
235 x1, x2, y, k, i: LongInt; |
|
236 rr: TSDL_Rect; |
235 rr: TSDL_Rect; |
237 bRes: boolean; |
236 bRes: boolean; |
238 begin |
237 begin |
239 y:= topY+150; |
238 y:= topY+150; |
240 repeat |
239 repeat |
270 until y > (LAND_HEIGHT-125); |
269 until y > (LAND_HEIGHT-125); |
271 |
270 |
272 if x1 > 0 then |
271 if x1 > 0 then |
273 begin |
272 begin |
274 bRes:= true; |
273 bRes:= true; |
275 tmpsurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps); |
274 if girSurf = nil then |
|
275 girSurf:= LoadDataImageAltPath(ptCurrTheme, ptGraphics, 'Girder', ifCritical or ifTransparent or ifIgnoreCaps); |
276 |
276 |
277 rr.x:= x1; |
277 rr.x:= x1; |
278 while rr.x < x2 do |
278 while rr.x < x2 do |
279 begin |
279 begin |
280 if cIce then |
280 if cIce then |
281 BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf, lfIce) |
281 BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, girSurf^.w), girSurf, lfIce) |
282 else |
282 else |
283 BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, tmpsurf^.w), tmpsurf); |
283 BlitImageAndGenerateCollisionInfo(rr.x, y, min(x2 - rr.x, girSurf^.w), girSurf); |
284 inc(rr.x, tmpsurf^.w); |
284 inc(rr.x, girSurf^.w); |
285 end; |
285 end; |
286 SDL_FreeSurface(tmpsurf); |
|
287 |
286 |
288 AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80); |
287 AddRect(x1 - 8, y - 32, x2 - x1 + 16, 80); |
289 end |
288 end |
290 else bRes:= false; |
289 else bRes:= false; |
291 |
290 |
855 end; |
854 end; |
856 until not b; |
855 until not b; |
857 end; |
856 end; |
858 |
857 |
859 procedure AddObjects(); |
858 procedure AddObjects(); |
860 var i, g: Longword; |
859 var girSurf: PSDL_Surface; |
|
860 i, g: Longword; |
861 begin |
861 begin |
862 InitRects; |
862 InitRects; |
863 if hasGirders then |
863 if hasGirders then |
864 begin |
864 begin |
865 g:= max(playWidth div 8, 256); |
865 g:= max(playWidth div 8, 256); |
866 i:= leftX + g; |
866 i:= leftX + g; |
|
867 girSurf:= nil; |
867 repeat |
868 repeat |
868 AddGirder(i); |
869 AddGirder(i, girSurf); |
869 i:=i + g; |
870 i:=i + g; |
870 until (i > rightX - g); |
871 until (i > rightX - g); |
|
872 // free girder surface |
|
873 if girSurf <> nil then |
|
874 begin |
|
875 SDL_FreeSurface(girSurf); |
|
876 girSurf:= nil; |
|
877 end; |
871 end; |
878 end; |
872 if (GameFlags and gfDisableLandObjects) = 0 then |
879 if (GameFlags and gfDisableLandObjects) = 0 then |
873 AddThemeObjects(ThemeObjects); |
880 AddThemeObjects(ThemeObjects); |
874 AddProgress(); |
881 AddProgress(); |
875 FreeRects(); |
882 FreeRects(); |