# HG changeset patch # User nemo # Date 1246931506 0 # Node ID 79c9542c105807bf1b7a97ce9c8f41f161ed6b45 # Parent 17f7a5882aca37559461cc86a50ff8c01afe407c multi-column support diff -r 17f7a5882aca -r 79c9542c1058 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Tue Jul 07 01:36:56 2009 +0000 +++ b/hedgewars/uLandGraphics.pas Tue Jul 07 01:51:46 2009 +0000 @@ -342,14 +342,18 @@ end; function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean; -var X, Y, bpp, h, w: LongInt; +var X, Y, bpp, h, w, row, col, numFramesFirstCol: LongInt; p: PByteArray; Image: PSDL_Surface; begin +numFramesFirstCol:= SpritesData[Obj].imageHeight div SpritesData[Obj].Height; + TryDo(SpritesData[Obj].Surface <> nil, 'Assert SpritesData[Obj].Surface failed', true); Image:= SpritesData[Obj].Surface; w:= SpritesData[Obj].Width; h:= SpritesData[Obj].Height; +row:= Frame mod numFramesFirstCol; +col:= Frame div numFramesFirstCol; if SDL_MustLock(Image) then SDLTry(SDL_LockSurface(Image) >= 0, true); @@ -357,7 +361,8 @@ bpp:= Image^.format^.BytesPerPixel; TryDo(bpp = 4, 'It should be 32 bpp sprite', true); // Check that sprite fits free space -p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]); +//p:= @(PByteArray(Image^.pixels)^[Image^.pitch * ( col * h + row * w )]); +p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 - 1 ]); case bpp of 4: for y:= 0 to Pred(h) do begin @@ -386,7 +391,7 @@ end; // Checked, now place -p:= @(PByteArray(Image^.pixels)^[Image^.pitch * Frame * h]); +p:= @(PByteArray(Image^.pixels)^[ Image^.pitch * row * h + col * w * 4 - 1 ]); case bpp of 4: for y:= 0 to Pred(h) do begin