184 collV:= -1; |
184 collV:= -1; |
185 Gear^.dX:= Gear^.dX * Gear^.Friction; |
185 Gear^.dX:= Gear^.dX * Gear^.Friction; |
186 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
186 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
187 Gear^.State:= Gear^.State or gstCollision |
187 Gear^.State:= Gear^.State or gstCollision |
188 end |
188 end |
189 end else |
189 end |
190 if TestCollisionYwithGear(Gear, 1) then |
190 else if TestCollisionYwithGear(Gear, 1) then |
191 begin |
191 begin |
192 collV:= 1; |
192 collV:= 1; |
193 isFalling:= false; |
193 isFalling:= false; |
194 Gear^.dX:= Gear^.dX * Gear^.Friction; |
194 Gear^.dX:= Gear^.dX * Gear^.Friction; |
195 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
195 Gear^.dY:= - Gear^.dY * Gear^.Elasticity; |
196 Gear^.State:= Gear^.State or gstCollision |
196 Gear^.State:= Gear^.State or gstCollision |
197 end else isFalling:= true; |
197 end |
|
198 else |
|
199 begin |
|
200 isFalling:= true; |
|
201 if Gear^.AdvBounce and Gear^.dY.isNegative and TestCollisionYwithGear(Gear, 1) then collV:= 1 |
|
202 else if Gear^.AdvBounce and not Gear^.dY.isNegative and TestCollisionYwithGear(Gear, -1) then collV:= -1; |
|
203 end; |
198 |
204 |
199 |
205 |
200 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
206 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then |
201 begin |
207 begin |
202 collH:= hwSign(Gear^.dX); |
208 collH:= hwSign(Gear^.dX); |
204 Gear^.dY:= Gear^.dY * Gear^.Elasticity; |
210 Gear^.dY:= Gear^.dY * Gear^.Elasticity; |
205 Gear^.State:= Gear^.State or gstCollision |
211 Gear^.State:= Gear^.State or gstCollision |
206 end |
212 end |
207 else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then collH:= -hwSign(Gear^.dX); |
213 else if Gear^.AdvBounce and TestCollisionXwithGear(Gear, -hwSign(Gear^.dX)) then collH:= -hwSign(Gear^.dX); |
208 |
214 |
209 if (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) and Gear^.AdvBounce then |
215 //if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and (hwSqr(tdX) + hwSqr(tdY) > _0_08) then |
|
216 if Gear^.AdvBounce and (collV <>0) and (collH <> 0) and ((tdX.QWordValue + tdY.QWordValue) > _0_2.QWordValue) then |
210 begin |
217 begin |
211 Gear^.dX:= tdY*Gear^.Elasticity*Gear^.Friction; |
218 Gear^.dX:= tdY*Gear^.Elasticity*Gear^.Friction; |
212 Gear^.dY:= tdX*Gear^.Elasticity;//*Gear^.Friction; |
219 Gear^.dY:= tdX*Gear^.Elasticity;//*Gear^.Friction; |
213 if ((collV > 0) and (collH > 0)) or ((collV < 0) and (collH < 0)) then Gear^.dX.isNegative:=not tdY.isNegative |
220 if ((collV > 0) and (collH > 0)) or ((collV < 0) and (collH < 0)) then Gear^.dX.isNegative:=not tdY.isNegative |
214 else if (collV < 0) and (collH > 0) then Gear^.dY.isNegative:= not tdX.isNegative; |
221 else if (collV < 0) and (collH > 0) then Gear^.dY.isNegative:= not tdX.isNegative; |
215 isFalling:= false; |
222 isFalling:= false; |
216 |
|
217 //tmp:= Gear^.dX.QWordValue; |
|
218 //Gear^.dX.QWordValue:= Gear^.dY.QWordValue; |
|
219 //Gear^.dY.QWordValue:= tmp; |
|
220 end; |
223 end; |
221 |
224 |
222 if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
225 if isFalling then Gear^.dY:= Gear^.dY + cGravity; |
223 |
226 |
224 Gear^.X:= Gear^.X + Gear^.dX; |
227 Gear^.X:= Gear^.X + Gear^.dX; |
225 Gear^.Y:= Gear^.Y + Gear^.dY; |
228 Gear^.Y:= Gear^.Y + Gear^.dY; |
226 CheckGearDrowning(Gear); |
229 CheckGearDrowning(Gear); |
227 if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
230 //if (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _0_0002) and |
|
231 if ((Gear^.dX.QWordValue + Gear^.dY.QWordValue) < _0_02.QWordValue) and |
228 (not isFalling) then |
232 (not isFalling) then |
229 Gear^.State:= Gear^.State and not gstMoving |
233 Gear^.State:= Gear^.State and not gstMoving |
230 else |
234 else |
231 Gear^.State:= Gear^.State or gstMoving |
235 Gear^.State:= Gear^.State or gstMoving |
232 end; |
236 end; |