hedgewars/uGears.pas
changeset 3030 411146650700
parent 3028 d17cf923d7c3
child 3032 9c190d3c165b
equal deleted inserted replaced
3029:67483e87590c 3030:411146650700
    42             Pos: Longword;
    42             Pos: Longword;
    43             doStep: TGearStepProcedure;
    43             doStep: TGearStepProcedure;
    44             Radius: LongInt;
    44             Radius: LongInt;
    45             Angle, Power : Longword;
    45             Angle, Power : Longword;
    46             DirAngle: real;
    46             DirAngle: real;
    47             Timer, Timer2 : LongWord;
    47             Timer : LongWord;
    48             Elasticity: hwFloat;
    48             Elasticity: hwFloat;
    49             Friction  : hwFloat;
    49             Friction  : hwFloat;
    50             Message, MsgParam : Longword;
    50             Message, MsgParam : Longword;
    51             Hedgehog: pointer;
    51             Hedgehog: pointer;
    52             Health, Damage, Karma: LongInt;
    52             Health, Damage, Karma: LongInt;
   877     amt: TAmmoType;
   877     amt: TAmmoType;
   878     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   878     hx, hy, cx, cy, tx, ty, sx, sy, m: LongInt;  // hedgehog, crosshair, temp, sprite, direction
   879     lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   879     lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
   880     defaultPos, HatVisible: boolean;
   880     defaultPos, HatVisible: boolean;
   881     VertexBuffer: array [0..1] of TVertex2f;
   881     VertexBuffer: array [0..1] of TVertex2f;
   882 begin
   882     HH: PHedgehog;
   883 
   883 begin
   884 if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
   884 HH:= PHedgehog(Gear^.Hedgehog);
       
   885 if HH^.Unplaced then exit;
   885 m:= 1;
   886 m:= 1;
   886 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   887 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
   887 if (Gear^.State and gstHHDeath) <> 0 then
   888 if (Gear^.State and gstHHDeath) <> 0 then
   888     begin
   889     begin
   889     DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
   890     DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
   990                 end;
   991                 end;
   991             end;
   992             end;
   992         // draw crosshair
   993         // draw crosshair
   993         cx:= Round(hwRound(Gear^.X) + dx * 80);
   994         cx:= Round(hwRound(Gear^.X) + dx * 80);
   994         cy:= Round(hwRound(Gear^.Y) + dy * 80);
   995         cy:= Round(hwRound(Gear^.Y) + dy * 80);
   995         DrawRotatedTex(PHedgehog(Gear^.Hedgehog)^.Team^.CrosshairTex,
   996         DrawRotatedTex(HH^.Team^.CrosshairTex,
   996                 12, 12, cx + WorldDx, cy + WorldDy, 0,
   997                 12, 12, cx + WorldDx, cy + WorldDy, 0,
   997                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
   998                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
   998         end;
   999         end;
   999     hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
  1000     hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
  1000     hy:= hwRound(Gear^.Y) - 2 + WorldDy;
  1001     hy:= hwRound(Gear^.Y) - 2 + WorldDy;
  1040                    DrawHedgehog(sx, sy,
  1041                    DrawHedgehog(sx, sy,
  1041                            i,
  1042                            i,
  1042                            1,
  1043                            1,
  1043                            0,
  1044                            0,
  1044                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
  1045                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
  1045                    with PHedgehog(Gear^.Hedgehog)^ do
  1046                    with HH^ do
  1046                        if (HatTex <> nil) then
  1047                        if (HatTex <> nil) then
  1047                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32,
  1048                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32,
  1048                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
  1049                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
  1049                    end;
  1050                    end;
  1050                 DrawAltWeapon(Gear, sx, sy);
  1051                 DrawAltWeapon(Gear, sx, sy);
  1053             gtBlowTorch: begin
  1054             gtBlowTorch: begin
  1054                 DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
  1055                 DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
  1055                 DrawHedgehog(sx, sy,
  1056                 DrawHedgehog(sx, sy,
  1056                         hwSign(Gear^.dX),
  1057                         hwSign(Gear^.dX),
  1057                         3,
  1058                         3,
  1058                         PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
  1059                         HH^.visStepPos div 2,
  1059                         0);
  1060                         0);
  1060                 with PHedgehog(Gear^.Hedgehog)^ do
  1061                 with HH^ do
  1061                     if (HatTex <> nil) then
  1062                     if (HatTex <> nil) then
  1062                        DrawTextureF(HatTex,
  1063                        DrawTextureF(HatTex,
  1063                            1,
  1064                            1,
  1064                            sx,
  1065                            sx,
  1065                            hwRound(Gear^.Y) - 8 + WorldDy,
  1066                            hwRound(Gear^.Y) - 8 + WorldDy,
  1159     if (Gear^.Message and (gm_Left or gm_Right) <> 0) and (not isCursorVisible) then
  1160     if (Gear^.Message and (gm_Left or gm_Right) <> 0) and (not isCursorVisible) then
  1160         begin
  1161         begin
  1161         DrawHedgehog(sx, sy,
  1162         DrawHedgehog(sx, sy,
  1162             hwSign(Gear^.dX),
  1163             hwSign(Gear^.dX),
  1163             0,
  1164             0,
  1164             PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
  1165             HH^.visStepPos div 2,
  1165             0);
  1166             0);
  1166         defaultPos:= false;
  1167         defaultPos:= false;
  1167         HatVisible:= true
  1168         HatVisible:= true
  1168         end
  1169         end
  1169     else
  1170     else
  1179         defaultPos:= false
  1180         defaultPos:= false
  1180         end
  1181         end
  1181     else
  1182     else
  1182     if ((Gear^.State and gstAttacked) = 0) then
  1183     if ((Gear^.State and gstAttacked) = 0) then
  1183         begin
  1184         begin
  1184         if Gear^.Timer2 > 0 then
  1185         if HH^.Timer > 0 then
  1185             begin
  1186             begin
  1186             // There must be a tidier way to do this. Anyone?
  1187             // There must be a tidier way to do this. Anyone?
  1187             if aangle <= 90 then aangle:= aangle+360;
  1188             if aangle <= 90 then aangle:= aangle+360;
  1188             if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*Gear^.Timer2/10)
  1189             if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10)
  1189             else aangle:= aangle+((240-aangle)*Gear^.Timer2/10);
  1190             else aangle:= aangle+((240-aangle)*HH^.Timer/10);
  1190             dec(Gear^.Timer2)
  1191             dec(HH^.Timer)
  1191             end;
  1192             end;
  1192         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
  1193         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
  1193         case amt of
  1194         case amt of
  1194             amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
  1195             amBazooka: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
  1195             amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
  1196             amMortar: DrawRotated(sprHandMortar, hx, hy, hwSign(Gear^.dX), aangle);
  1253                 0,
  1254                 0,
  1254                 4,
  1255                 4,
  1255                 0);
  1256                 0);
  1256 
  1257 
  1257             HatVisible:= true;
  1258             HatVisible:= true;
  1258             with PHedgehog(Gear^.Hedgehog)^ do
  1259             with HH^ do
  1259                 if (HatTex <> nil)
  1260                 if (HatTex <> nil)
  1260                 and (HatVisibility > 0) then
  1261                 and (HatVisibility > 0) then
  1261                     DrawTextureF(HatTex,
  1262                     DrawTextureF(HatTex,
  1262                         HatVisibility,
  1263                         HatVisibility,
  1263                         sx,
  1264                         sx,
  1299             0);
  1300             0);
  1300         defaultPos:= false
  1301         defaultPos:= false
  1301         end;
  1302         end;
  1302     end;
  1303     end;
  1303 
  1304 
  1304 with PHedgehog(Gear^.Hedgehog)^ do
  1305 with HH^ do
  1305     begin
  1306     begin
  1306     if defaultPos then
  1307     if defaultPos then
  1307         begin
  1308         begin
  1308         DrawRotatedF(sprHHIdle,
  1309         DrawRotatedF(sprHHIdle,
  1309             sx,
  1310             sx,
  1365                        end;
  1366                        end;
  1366             end;
  1367             end;
  1367         end
  1368         end
  1368     end;
  1369     end;
  1369 
  1370 
  1370 with PHedgehog(Gear^.Hedgehog)^ do
  1371 with HH^ do
  1371     begin
  1372     begin
  1372     if ((Gear^.State and not gstWinner) = 0)
  1373     if ((Gear^.State and not gstWinner) = 0)
  1373         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
  1374         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
  1374         begin
  1375         begin
  1375         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;
  1376         t:= hwRound(Gear^.Y) - cHHRadius - 12 + WorldDy;