hedgewars/uWorld.pas
changeset 57 e1a77ae57065
parent 56 a29135563e94
child 69 d8a526934b9f
equal deleted inserted replaced
56:a29135563e94 57:e1a77ae57065
    40 
    40 
    41 procedure InitWorld;
    41 procedure InitWorld;
    42 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    42 procedure DrawWorld(Lag: integer; Surface: PSDL_Surface);
    43 procedure AddCaption(s: shortstring; Color, Group: LongWord);
    43 procedure AddCaption(s: shortstring; Color, Group: LongWord);
    44 procedure MoveWorld;
    44 procedure MoveWorld;
    45 procedure AdjustMPoint;
       
    46 
    45 
    47 {$IFDEF COUNTTICKS}
    46 {$IFDEF COUNTTICKS}
    48 var cntTicks: LongWord;
    47 var cntTicks: LongWord;
    49 {$ENDIF}
    48 {$ENDIF}
    50 var FollowGear: PGear = nil;
    49 var FollowGear: PGear = nil;
   310 procedure MoveWorld;
   309 procedure MoveWorld;
   311 const PrevSentPointTime: LongWord = 0;
   310 const PrevSentPointTime: LongWord = 0;
   312 var s: string[9];
   311 var s: string[9];
   313 begin
   312 begin
   314 if not (CurrentTeam.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   313 if not (CurrentTeam.ExtDriven and isCursorVisible) then SDL_GetMouseState(@CursorPoint.X, @CursorPoint.Y);
   315 
       
   316 if (FollowGear <> nil) then
   314 if (FollowGear <> nil) then
   317    if abs(CursorPoint.X - prevPoint.X + CursorPoint.Y - prevpoint.Y) > 4 then
   315    if abs(CursorPoint.X - prevPoint.X) + abs(CursorPoint.Y - prevpoint.Y) > 4 then
   318       begin
   316       begin
   319       FollowGear:= nil;
   317       FollowGear:= nil;
   320       AdjustMPoint;
       
   321       exit
   318       exit
   322       end
   319       end
   323       else begin
   320       else begin
   324       CursorPoint.x:= (CursorPoint.x + (round(FollowGear.X + Sign(FollowGear.dX) * 100) + WorldDx)) div 2;
   321       CursorPoint.x:= (CursorPoint.x + (round(FollowGear.X + Sign(FollowGear.dX) * 100) + WorldDx)) div 2;
   325       CursorPoint.y:= (CursorPoint.y + (round(FollowGear.Y) + WorldDy)) div 2
   322       CursorPoint.y:= (CursorPoint.y + (round(FollowGear.Y) + WorldDy)) div 2
   374 if WorldDy >  2048 then WorldDy:=  2048;
   371 if WorldDy >  2048 then WorldDy:=  2048;
   375 if WorldDx < -2048 then WorldDx:= -2048;
   372 if WorldDx < -2048 then WorldDx:= -2048;
   376 if WorldDx > cScreenWidth then WorldDx:=  cScreenWidth;
   373 if WorldDx > cScreenWidth then WorldDx:=  cScreenWidth;
   377 end;
   374 end;
   378 
   375 
   379 procedure AdjustMPoint;
       
   380 begin
       
   381 prevPoint.x:= cScreenWidth div 2;
       
   382 prevPoint.y:= cScreenHeight div 2;
       
   383 SDL_WarpMouse(prevPoint.X, prevPoint.Y);
       
   384 end;
       
   385 
       
   386 initialization
   376 initialization
   387 FillChar(Captions, sizeof(Captions), 0)
   377 FillChar(Captions, sizeof(Captions), 0)
   388 
   378 
   389 end.
   379 end.