hedgewars/uLandGraphics.pas
changeset 520 e83dfb7ffead
parent 511 2b5b9e00419d
child 698 43f3ef079f53
equal deleted inserted replaced
519:981df6f6e2a9 520:e83dfb7ffead
    30 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    30 procedure DrawHLinesExplosions(ar: PRangeArray; Radius: LongInt; y, dY: LongInt; Count: Byte);
    31 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    31 procedure DrawTunnel(X, Y, dX, dY: hwFloat; ticks, HalfWidth: LongInt);
    32 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    32 procedure FillRoundInLand(X, Y, Radius: LongInt; Value: Longword);
    33 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
    33 procedure ChangeRoundInLand(X, Y, Radius: LongInt; doSet: boolean);
    34 
    34 
    35 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): boolean;
    35 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
    36 
    36 
    37 implementation
    37 implementation
    38 uses SDLh, uMisc, uLand;
    38 uses SDLh, uMisc, uLand;
    39 
    39 
    40 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
    40 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
   318 
   318 
   319 if SDL_MustLock(LandSurface) then
   319 if SDL_MustLock(LandSurface) then
   320    SDL_UnlockSurface(LandSurface)
   320    SDL_UnlockSurface(LandSurface)
   321 end;
   321 end;
   322 
   322 
   323 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt): boolean;
   323 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
   324 var X, Y, bpp, h, w: LongInt;
   324 var X, Y, bpp, h, w: LongInt;
   325     p: PByteArray;
   325     p: PByteArray;
   326     r, rr: TSDL_Rect;
   326     r, rr: TSDL_Rect;
   327     Image: PSDL_Surface;
   327     Image: PSDL_Surface;
   328 begin
   328 begin
   382                       end;
   382                       end;
   383             p:= @(p^[Image^.pitch]);
   383             p:= @(p^[Image^.pitch]);
   384             end;
   384             end;
   385      end;
   385      end;
   386 
   386 
       
   387 TryPlaceOnLand:= true;
       
   388 if not doPlace then exit;
       
   389 
   387 // Checked, now place
   390 // Checked, now place
   388 p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]);
   391 p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]);
   389 case bpp of
   392 case bpp of
   390      2: for y:= 0 to Pred(h) do
   393      2: for y:= 0 to Pred(h) do
   391             begin
   394             begin
   416 r.y:= SpritesData[Obj].Height * Frame;
   419 r.y:= SpritesData[Obj].Height * Frame;
   417 r.w:= SpritesData[Obj].Width;
   420 r.w:= SpritesData[Obj].Width;
   418 r.h:= SpritesData[Obj].Height;
   421 r.h:= SpritesData[Obj].Height;
   419 rr.x:= cpX;
   422 rr.x:= cpX;
   420 rr.y:= cpY;
   423 rr.y:= cpY;
   421 SDL_UpperBlit(Image, @r, LandSurface, @rr);
   424 SDL_UpperBlit(Image, @r, LandSurface, @rr)
   422 
       
   423 TryPlaceOnLand:= true
       
   424 end;
   425 end;
   425 
   426 
   426 
   427 
   427 end.
   428 end.