hedgewars/uCursor.pas
author Wuzzy <Wuzzy2@mail.ru>
Sat, 06 Jun 2020 15:40:51 +0200
changeset 15597 6e72bd61002e
parent 14809 c2793ff4e887
permissions -rw-r--r--
Disable gfMoreWind for land objects on turn end only after a fixed-time delay 15s sounds much, but it's the average amount for gfMineStrike mines to settle naturally. And it would be very confusing to see falling mines suddenly not caring about gfMoreWind for no apparent reason. Note this whole thing is a giant hack anyway, to prevent a turn being blocked by infinitely bouncing mines. The better solution would be to help gfMoreWind-affected land objects settle naturally more reliably even under extreme wind. But this commit is "good enough" for now. If you don't like the delay, you can always tweak the constant.

{$INCLUDE "options.inc"}

unit uCursor;

interface

procedure init;
procedure resetPosition;
procedure resetPositionDelta();
procedure updatePositionDelta(xrel, yrel: LongInt);
procedure updatePosition();
procedure handlePositionUpdate(x, y: LongInt);

implementation

uses SDLh, uVariables, uTypes;

procedure init;
begin
    SDL_ShowCursor(SDL_DISABLE);
    resetPosition();
{$IFNDEF USE_TOUCH_INTERFACE}
    SDL_SetRelativeMouseMode(SDL_TRUE);
{$ENDIF}
end;

procedure resetPosition;
begin
    if GameType = gmtRecord then
        exit;
    SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
    resetPositionDelta();
end;

procedure resetPositionDelta();
begin
    CursorPointDelta.X:= 0;
    CursorPointDelta.Y:= 0;
end;

procedure updatePositionDelta(xrel, yrel: LongInt);
begin
    CursorPointDelta.X:= CursorPointDelta.X + xrel;
    CursorPointDelta.Y:= CursorPointDelta.Y + yrel;
end;

procedure updatePosition();
begin
    handlePositionUpdate(CursorPointDelta.X, CursorPointDelta.Y);
    resetPositionDelta();
end;

procedure handlePositionUpdate(x, y: LongInt);
begin
    CursorPoint.X:= CursorPoint.X + x;
    CursorPoint.Y:= CursorPoint.Y - y;
end;

end.