hedgewars/uCursor.pas
author nemo
Sun, 02 Oct 2011 10:36:43 -0400
changeset 6081 537bbd5c1a62
parent 5199 5eae5da831e1
child 6580 6155187bf599
permissions -rw-r--r--
Basic test implementation of an ice flag. Allows for slick parts of terrain. Intended for ice gun, or "ice" mask on portions of land objects. In this test variant it is triggered on girders/objects/bridges of the snow/christmas theme, or on a map that uses blue as a mask colour. Probably needs sheepluva's slope detection to make slopes more slippery to climb.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5191
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     1
unit uCursor;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     2
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     3
interface
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     4
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     5
procedure init;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     6
procedure updatePosition;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     7
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     8
implementation
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
     9
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    10
uses SDLh, uVariables;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    11
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    12
procedure init;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    13
begin
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    14
    SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    15
end;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    16
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    17
procedure updatePosition;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    18
var x, y: LongInt;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    19
begin
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    20
    SDL_GetMouseState(@x, @y);
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    21
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    22
    if(x <> cScreenWidth div 2) or (y <> cScreenHeight div 2) then
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    23
        begin
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    24
        CursorPoint.X:= CursorPoint.X + x - cScreenWidth div 2;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    25
        CursorPoint.Y:= CursorPoint.Y - y + cScreenHeight div 2;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    26
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    27
        if cHasFocus then SDL_WarpMouse(cScreenWidth div 2, cScreenHeight div 2);
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    28
        end
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    29
end;
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    30
c7000a6b397b - Implement a thin wrapper over real cursor, which eliminates need in SDL_WarpMouse outside game window
unc0rr
parents:
diff changeset
    31
end.