Nemo's patch allowing different water sprites size
authorunc0rr
Mon, 23 Feb 2009 15:57:32 +0000
changeset 1825 c929f9111141
parent 1824 fbe1fa777d68
child 1826 85ba91b803ea
Nemo's patch allowing different water sprites size
hedgewars/hwengine.dpr
hedgewars/uConsts.pas
hedgewars/uWorld.pas
--- a/hedgewars/hwengine.dpr	Sat Feb 21 20:01:01 2009 +0000
+++ b/hedgewars/hwengine.dpr	Mon Feb 23 15:57:32 2009 +0000
@@ -82,6 +82,7 @@
 			AssignHHCoords;
 			AddMiscGears;
 			StoreLoad;
+            InitWorld;
 			ResetKbd;
 			SoundLoad;
 			if GameType = gmtSave then
@@ -257,7 +258,6 @@
 AssignStores;
 
 if isSoundEnabled then InitSound;
-InitWorld;
 
 StoreInit;
 
--- a/hedgewars/uConsts.pas	Sat Feb 21 20:01:01 2009 +0000
+++ b/hedgewars/uConsts.pas	Mon Feb 23 15:57:32 2009 +0000
@@ -299,7 +299,7 @@
 			saveSurf: boolean;
 			end = (
 			(FileName:  'BlueWater'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
-			Width: 125; Height: 32; saveSurf: false),// sprWater
+			Width: 0; Height: 0; saveSurf: false),// sprWater
 			(FileName:     'Clouds'; Path: ptCurrTheme;AltPath: ptGraphics; Texture: nil; Surface: nil;
 			Width: 256; Height:128; saveSurf: false),// sprCloud
 			(FileName:       'Bomb'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
--- a/hedgewars/uWorld.pas	Sat Feb 21 20:01:01 2009 +0000
+++ b/hedgewars/uWorld.pas	Mon Feb 23 15:57:32 2009 +0000
@@ -52,7 +52,7 @@
                    EndTime: LongWord;
                    end;
 
-var cWaterSprCount: LongInt;
+var cWaterSprCount, cWaveWidth, cWaveHeight: LongInt;
 	Captions: array[TCapGroup] of TCaptionStr;
 	AMxShift, SlotsNum: LongInt;
 	tmpSurface: PSDL_Surface;
@@ -60,7 +60,9 @@
 
 procedure InitWorld;
 begin
-cWaterSprCount:= 1 + cScreenWidth div (SpritesData[sprWater].Width);
+cWaveWidth:= SpritesData[sprWater].Width;
+cWaveHeight:= SpritesData[sprWater].Height;
+cWaterSprCount:= 1 + cScreenWidth div cWaveWidth;
 cGearScrEdgesDist:= Min(cScreenWidth div 2 - 100, cScreenHeight div 2 - 50);
 SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
 prevPoint.X:= cScreenWidth div 2;
@@ -176,6 +178,7 @@
     tdx, tdy: Double;
     grp: TCapGroup;
     s: string[15];
+    cWaveWidth, cWaveHeight: LongWord;
 
     procedure DrawRepeated(spr: TSprite; Shift: LongInt);
     var i, w: LongInt;
@@ -209,8 +212,8 @@
 
     // Waves
     {$WARNINGS OFF}
-    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx + (RealTicks shr 6)      ) mod 125), cWaterLine + WorldDy - 64, 0);
-    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx - (RealTicks shr 6) + 100) mod 125), cWaterLine + WorldDy - 48, 0);
+    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6)      ) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight*2), 0);
+    for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth + ((WorldDx - (RealTicks shr 6) + 100) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight + cWaveHeight div 2), 0);
     {$WARNINGS ON}
     end;
 
@@ -263,9 +266,9 @@
 
 // Waves
 {$WARNINGS OFF}
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx + (RealTicks shr 6) +  25) mod 125), cWaterLine + WorldDy - 32, 0);
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx - (RealTicks shr 6) +  50) mod 125), cWaterLine + WorldDy - 16, 0);
-for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * 125  + ((WorldDx + (RealTicks shr 6) +  75) mod 125), cWaterLine + WorldDy     , 0);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6) +  25) mod cWaveWidth), cWaterLine + WorldDy - cWaveHeight, 0);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx - (RealTicks shr 6) +  50) mod cWaveWidth), cWaterLine + WorldDy - (cWaveHeight div 2), 0);
+for i:= -1 to cWaterSprCount do DrawSprite(sprWater,  i * cWaveWidth  + ((WorldDx + (RealTicks shr 6) +  75) mod cWaveWidth), cWaterLine + WorldDy     , 0);
 {$WARNINGS ON}
 // Turn time
 if TurnTimeLeft <> 0 then