make rope styleable
authoralfadur
Tue, 14 May 2019 21:36:50 +0300
changeset 14944 8b53cb1c0ada
parent 14943 d01460ae866c
child 14945 00cf807b7faa
make rope styleable
hedgewars/uGearsRender.pas
hedgewars/uLandObjects.pas
hedgewars/uVariables.pas
share/hedgewars/Data/Graphics/RopeNode.png
--- a/hedgewars/uGearsRender.pas	Tue May 14 19:46:43 2019 +0200
+++ b/hedgewars/uGearsRender.pas	Tue May 14 21:36:50 2019 +0300
@@ -99,6 +99,7 @@
 var  eX, eY, dX, dY: LongInt;
     i, sX, sY, x, y, d: LongInt;
     b: boolean;
+    angle: real;
 begin
     if (X1 = X2) and (Y1 = Y2) then
         begin
@@ -110,6 +111,7 @@
     eY:= 0;
     dX:= X2 - X1;
     dY:= Y2 - Y1;
+    angle:= arctan2(dY, dX) * 180 / PI - 90;
 
     if (dX > 0) then
         sX:= 1
@@ -160,8 +162,8 @@
         if b then
             begin
             inc(roplen);
-            if (roplen mod 4) = 0 then
-                DrawSprite(sprRopeNode, x - 2, y - 2, 0)
+            if (roplen mod cRopeNodeStep) = 0 then
+                DrawSpriteRotatedF(sprRopeNode, x, y, roplen mod cRopeNodeStep, 1, angle);
             end
     end;
     DrawRopeLine:= roplen;
--- a/hedgewars/uLandObjects.pas	Tue May 14 19:46:43 2019 +0200
+++ b/hedgewars/uLandObjects.pas	Tue May 14 21:36:50 2019 +0300
@@ -1036,6 +1036,8 @@
         cIce:= true
     else if key = 'snow' then
         cSnow:= true
+    else if key = 'rope-step' then
+        cRopeNodeStep:= StrToInt(s)
     else if key = 'sd-water-top' then
         begin
         i:= Pos(',', s);
--- a/hedgewars/uVariables.pas	Tue May 14 19:46:43 2019 +0200
+++ b/hedgewars/uVariables.pas	Tue May 14 21:36:50 2019 +0300
@@ -116,6 +116,7 @@
     cFeatureSize    : LongInt;
     cMapGen         : TMapGen;
     cRopePercent    : LongWord;
+    cRopeNodeStep   : LongWord;
     cGetAwayTime    : LongWord;
 
     cAdvancedMapGenMode: boolean;
@@ -465,8 +466,8 @@
             Width:  48; Height: 48; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprParachute
             (FileName:     'Target'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpMedium; getDimensions: false; getImageDimensions: true),// sprTarget
-            (FileName:   'RopeNode'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
-            Width:   6; Height:  6; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprRopeNode
+            (FileName:   'RopeNode'; Path: ptCurrTheme; AltPath: ptGraphics; Texture: nil; Surface: nil;
+            Width:   16; Height:  16; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpHighest; getDimensions: false; getImageDimensions: true),// sprRopeNode
             (FileName:   'thinking'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
             Width:  32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false; critical: true; checkSum: false; priority: tpLowest; getDimensions: false; getImageDimensions: true),// sprQuestion
             (FileName:   'PowerBar'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil;
@@ -2848,6 +2849,7 @@
     cInitHealth         := 100;
     cDamagePercent      := 100;
     cRopePercent        := 100;
+    cRopeNodeStep       := 4;
     cGetAwayTime        := 100;
     cMineDudPercent     := 0;
     cTemplateFilter     := 0;
Binary file share/hedgewars/Data/Graphics/RopeNode.png has changed