5334 ly := 0; |
5334 ly := 0; |
5335 if CalcSlopeTangent(Gear, gx, gy, lx, ly, 255) then |
5335 if CalcSlopeTangent(Gear, gx, gy, lx, ly, 255) then |
5336 begin |
5336 begin |
5337 la:= vector2Angle(int2hwFloat(lx), int2hwFloat(ly)); |
5337 la:= vector2Angle(int2hwFloat(lx), int2hwFloat(ly)); |
5338 ga:= vector2Angle(dX, dY); |
5338 ga:= vector2Angle(dX, dY); |
|
5339 AddFileLog('la: '+inttostr(la)+' ga: '+inttostr(ga)+' Angle: '+inttostr(Angle)); |
5339 // change to 0 to 4096 forced by LongWord in Gear |
5340 // change to 0 to 4096 forced by LongWord in Gear |
5340 if la < 0 then la:= 4096+la; |
5341 if la < 0 then la:= 4096+la; |
5341 if ga < 0 then ga:= 4096+ga; |
5342 if ga < 0 then ga:= 4096+ga; |
5342 if ((Angle < ga) and (Angle < la)) or ((Angle > ga) and (Angle > la)) then |
5343 if ((Angle > ga) and (Angle < la)) or ((Angle < ga) and (Angle > la)) then |
5343 begin |
5344 begin |
5344 if Angle >= 2048 then dec(Angle, 2048) |
5345 if Angle >= 2048 then dec(Angle, 2048) |
5345 else if Angle < 2048 then inc(Angle, 2048) |
5346 else if Angle < 2048 then inc(Angle, 2048) |
5346 end |
5347 end; |
|
5348 AddFileLog('la: '+inttostr(la)+' ga: '+inttostr(ga)+' Angle: '+inttostr(Angle)) |
5347 end; |
5349 end; |
5348 case Angle div 1024 of |
5350 case Angle div 1024 of |
5349 0: begin |
5351 0: begin |
5350 flipSurface(surf, true); |
5352 flipSurface(surf, true); |
5351 flipSurface(surf, true); |
5353 flipSurface(surf, true); |
5352 BlitImageAndGenerateCollisionInfo(hwRound(X)-(w-tx), hwRound(Y)+(w-ty), w, surf) |
5354 BlitImageAndGenerateCollisionInfo(gx-(w-tx), gy+(w-ty), w, surf) |
5353 end; |
5355 end; |
5354 1: begin |
5356 1: begin |
5355 flipSurface(surf, false); |
5357 flipSurface(surf, false); |
5356 BlitImageAndGenerateCollisionInfo(hwRound(X)-(w-tx), hwRound(Y)-ty, w, surf) |
5358 BlitImageAndGenerateCollisionInfo(gx-(w-tx), gy-ty, w, surf) |
5357 end; |
5359 end; |
5358 2: begin // knife was actually drawn facing this way... |
5360 2: begin // knife was actually drawn facing this way... |
5359 BlitImageAndGenerateCollisionInfo(hwRound(X)-tx, hwRound(Y)-ty, w, surf) |
5361 BlitImageAndGenerateCollisionInfo(gx-tx, gy-ty, w, surf) |
5360 end; |
5362 end; |
5361 3: begin |
5363 3: begin |
5362 flipSurface(surf, true); |
5364 flipSurface(surf, true); |
5363 BlitImageAndGenerateCollisionInfo(hwRound(X)-tx, hwRound(Y)+(w-ty), w, surf) |
5365 BlitImageAndGenerateCollisionInfo(gx-tx, gy+(w-ty), w, surf) |
5364 end |
5366 end |
5365 end; |
5367 end; |
5366 SDL_FreeSurface(surf); |
5368 SDL_FreeSurface(surf); |
5367 // this needs to calculate actual width/height + land clipping since update texture doesn't. |
5369 // this needs to calculate actual width/height + land clipping since update texture doesn't. |
5368 // i.e. this will crash if you fire near sides of map, but until I get the blit right, not going to put real values |
5370 // i.e. this will crash if you fire near sides of map, but until I get the blit right, not going to put real values |