1781 glColor4ub($FF, $FF, $FF, $FF); |
1781 glColor4ub($FF, $FF, $FF, $FF); |
1782 {$ENDIF} |
1782 {$ENDIF} |
1783 end; |
1783 end; |
1784 |
1784 |
1785 procedure DrawWaves(Dir, dX, dY, oX: LongInt; tnt: Byte); |
1785 procedure DrawWaves(Dir, dX, dY, oX: LongInt; tnt: Byte); |
1786 var first, count, topy, lx, rx, spriteHeight, spriteWidth: LongInt; |
1786 var first, count, topy, lx, rx, spriteHeight, spriteWidth, waterSpeed: LongInt; |
1787 lw, nWaves, shift: GLfloat; |
1787 waterFrames, waterFrameTicks, frame : LongWord; |
|
1788 lw, nWaves, shift, realHeight: GLfloat; |
1788 sprite: TSprite; |
1789 sprite: TSprite; |
1789 begin |
1790 begin |
1790 // note: spriteHeight is the Height of the wave sprite while |
1791 // note: spriteHeight is the Height of the wave sprite while |
1791 // cWaveHeight describes how many pixels of it will be above waterline |
1792 // cWaveHeight describes how many pixels of it will be above waterline |
1792 |
1793 |
1793 if SuddenDeathDmg then |
1794 if SuddenDeathDmg then |
1794 sprite:= sprSDWater |
1795 begin |
|
1796 sprite:= sprSDWater; |
|
1797 waterFrames:= watSDFrames; |
|
1798 waterFrameTicks:= watSDFrameTicks; |
|
1799 waterSpeed:= watSDMove; |
|
1800 end |
1795 else |
1801 else |
|
1802 begin |
1796 sprite:= sprWater; |
1803 sprite:= sprWater; |
1797 |
1804 waterFrames:= watFrames; |
|
1805 waterFrameTicks:= watFrameTicks; |
|
1806 waterSpeed:= watMove; |
|
1807 end; |
|
1808 |
1798 spriteHeight:= SpritesData[sprite].Height; |
1809 spriteHeight:= SpritesData[sprite].Height; |
|
1810 realHeight:= SpritesData[sprite].Texture^.ry / waterFrames; |
1799 |
1811 |
1800 // shift parameters by wave height |
1812 // shift parameters by wave height |
1801 // ( ox and dy are used to create different horizontal and vertical offsets |
1813 // ( ox and dy are used to create different horizontal and vertical offsets |
1802 // between wave layers ) |
1814 // between wave layers ) |
1803 dY:= -cWaveHeight + dy; |
1815 dY:= -cWaveHeight + dy; |
1854 |
1866 |
1855 spriteWidth:= SpritesData[sprite].Width; |
1867 spriteWidth:= SpritesData[sprite].Width; |
1856 nWaves:= lw / spriteWidth; |
1868 nWaves:= lw / spriteWidth; |
1857 shift:= - nWaves / 2; |
1869 shift:= - nWaves / 2; |
1858 |
1870 |
1859 TextureBuffer[3].X:= shift + ((LongInt(RealTicks shr 6) * Dir + dX) mod spriteWidth) / (spriteWidth - 1); |
1871 if waterFrames > 1 then |
1860 TextureBuffer[3].Y:= 0; |
1872 frame:= RealTicks div waterFrameTicks mod waterFrames |
|
1873 else |
|
1874 frame:= 0; |
|
1875 |
|
1876 TextureBuffer[3].X:= shift + ((LongInt(RealTicks shr (16 - waterSpeed)) * Dir + dX) mod spriteWidth) / (spriteWidth - 1); |
|
1877 TextureBuffer[3].Y:= frame * realHeight; |
1861 TextureBuffer[5].X:= TextureBuffer[3].X + nWaves; |
1878 TextureBuffer[5].X:= TextureBuffer[3].X + nWaves; |
1862 TextureBuffer[5].Y:= 0; |
1879 TextureBuffer[5].Y:= frame * realHeight; |
1863 TextureBuffer[4].X:= TextureBuffer[5].X; |
1880 TextureBuffer[4].X:= TextureBuffer[5].X; |
1864 TextureBuffer[4].Y:= SpritesData[sprite].Texture^.ry; |
1881 TextureBuffer[4].Y:= SpritesData[sprite].Texture^.ry / waterFrames + frame * realHeight; |
1865 TextureBuffer[2].X:= TextureBuffer[3].X; |
1882 TextureBuffer[2].X:= TextureBuffer[3].X; |
1866 TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry; |
1883 TextureBuffer[2].Y:= SpritesData[sprite].Texture^.ry / waterFrames + frame * realHeight; |
1867 |
1884 |
1868 if (WorldEdge = weSea) then |
1885 if (WorldEdge = weSea) then |
1869 begin |
1886 begin |
1870 nWaves:= (topy - ViewTopY) / spriteWidth; |
1887 nWaves:= (topy - ViewTopY) / spriteWidth; |
1871 |
1888 |