72 //glDisable(GL_LINE_SMOOTH) |
72 //glDisable(GL_LINE_SMOOTH) |
73 end |
73 end |
74 end; |
74 end; |
75 |
75 |
76 |
76 |
77 procedure DrawRope(Gear: PGear); |
77 procedure DrawRopeLine(X1, Y1, X2, Y2, roplen: LongInt); |
78 var roplen: LongInt; |
78 var eX, eY, dX, dY: LongInt; |
79 i: Longword; |
79 i, sX, sY, x, y, d: LongInt; |
80 |
80 b: boolean; |
81 procedure DrawRopeLine(X1, Y1, X2, Y2: LongInt); |
81 begin |
82 var eX, eY, dX, dY: LongInt; |
|
83 i, sX, sY, x, y, d: LongInt; |
|
84 b: boolean; |
|
85 begin |
|
86 if (X1 = X2) and (Y1 = Y2) then |
82 if (X1 = X2) and (Y1 = Y2) then |
87 begin |
83 begin |
88 //OutError('WARNING: zero length rope line!', false); |
84 //OutError('WARNING: zero length rope line!', false); |
89 exit |
85 exit |
90 end; |
86 end; |
91 eX:= 0; |
87 eX:= 0; |
92 eY:= 0; |
88 eY:= 0; |
93 dX:= X2 - X1; |
89 dX:= X2 - X1; |
94 dY:= Y2 - Y1; |
90 dY:= Y2 - Y1; |
95 |
91 |
99 begin |
95 begin |
100 sX:= -1; |
96 sX:= -1; |
101 dX:= -dX |
97 dX:= -dX |
102 end else sX:= dX; |
98 end else sX:= dX; |
103 |
99 |
104 if (dY > 0) then sY:= 1 |
100 if (dY > 0) then |
|
101 sY:= 1 |
105 else |
102 else |
106 if (dY < 0) then |
103 if (dY < 0) then |
107 begin |
104 begin |
108 sY:= -1; |
105 sY:= -1; |
109 dY:= -dY |
106 dY:= -dY |
110 end else sY:= dY; |
107 end else |
111 |
108 sY:= dY; |
112 if (dX > dY) then d:= dX |
109 |
113 else d:= dY; |
110 if (dX > dY) then d:= dX |
114 |
111 else d:= dY; |
115 x:= X1; |
112 |
116 y:= Y1; |
113 x:= X1; |
117 |
114 y:= Y1; |
118 for i:= 0 to d do |
115 |
119 begin |
116 for i:= 0 to d do |
120 inc(eX, dX); |
117 begin |
121 inc(eY, dY); |
118 inc(eX, dX); |
122 b:= false; |
119 inc(eY, dY); |
123 if (eX > d) then |
120 b:= false; |
124 begin |
121 if (eX > d) then |
125 dec(eX, d); |
122 begin |
126 inc(x, sX); |
123 dec(eX, d); |
127 b:= true |
124 inc(x, sX); |
128 end; |
125 b:= true |
129 if (eY > d) then |
126 end; |
130 begin |
127 if (eY > d) then |
131 dec(eY, d); |
128 begin |
132 inc(y, sY); |
129 dec(eY, d); |
133 b:= true |
130 inc(y, sY); |
134 end; |
131 b:= true |
135 if b then |
132 end; |
136 begin |
133 if b then |
137 inc(roplen); |
134 begin |
138 if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
135 inc(roplen); |
139 end |
136 if (roplen mod 4) = 0 then DrawSprite(sprRopeNode, x - 2, y - 2, 0) |
140 end |
137 end |
141 end; |
138 end |
|
139 end; |
|
140 |
|
141 procedure DrawRope(Gear: PGear); |
|
142 var roplen: LongInt; |
|
143 i: Longword; |
142 begin |
144 begin |
143 if (cReducedQuality and rqSimpleRope) <> 0 then |
145 if (cReducedQuality and rqSimpleRope) <> 0 then |
144 DrawRopeLinesRQ(Gear) |
146 DrawRopeLinesRQ(Gear) |
145 else |
147 else |
146 begin |
148 begin |
149 begin |
151 begin |
150 i:= 0; |
152 i:= 0; |
151 while i < Pred(RopePoints.Count) do |
153 while i < Pred(RopePoints.Count) do |
152 begin |
154 begin |
153 DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
155 DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
154 hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy); |
156 hwRound(RopePoints.ar[Succ(i)].X) + WorldDx, hwRound(RopePoints.ar[Succ(i)].Y) + WorldDy, roplen); |
155 inc(i) |
157 inc(i) |
156 end; |
158 end; |
157 DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
159 DrawRopeLine(hwRound(RopePoints.ar[i].X) + WorldDx, hwRound(RopePoints.ar[i].Y) + WorldDy, |
158 hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy); |
160 hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, roplen); |
159 DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
161 DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
160 hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy); |
162 hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen); |
161 end else |
163 end else |
162 if Gear^.Elasticity.QWordValue > 0 then |
164 if Gear^.Elasticity.QWordValue > 0 then |
163 DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
165 DrawRopeLine(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, |
164 hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy); |
166 hwRound(Gear^.Hedgehog^.Gear^.X) + WorldDx, hwRound(Gear^.Hedgehog^.Gear^.Y) + WorldDy, roplen); |
165 end; |
167 end; |
166 |
168 |
167 |
169 |
168 if RopePoints.Count > 0 then |
170 if RopePoints.Count > 0 then |
169 DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |
171 DrawRotated(sprRopeHook, hwRound(RopePoints.ar[0].X) + WorldDx, hwRound(RopePoints.ar[0].Y) + WorldDy, 1, RopePoints.HookAngle) |