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