summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7f678cc)
raw | patch | inline | side by side (parent: 7f678cc)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 27 Aug 2017 15:12:06 +0000 (18:12 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 27 Aug 2017 15:12:19 +0000 (18:12 +0300) |
src/engine/e_input.pas | patch | blob | history | |
src/game/g_holmes.pas | patch | blob | history | |
src/game/g_window.pas | patch | blob | history |
diff --git a/src/engine/e_input.pas b/src/engine/e_input.pas
index 021c3ddadf72452b8c4b11358877cf0da23662e5..6e208d7ecd1920bf6901feb5534897f8452bf3be 100644 (file)
--- a/src/engine/e_input.pas
+++ b/src/engine/e_input.pas
function e_JoyHatToKey(id: Word; hat: Byte; dir: Byte): Word;
procedure e_SetKeyState(key: Word; state: Integer);
+procedure e_UnpressAllKeys ();
+procedure e_KeyUpDown (key: Word; down: Boolean);
+
var
{e_MouseInfo: TMouseInfo;}
e_EnableInput: Boolean = False;
SetLength(Joysticks, 0);
end;
+
+procedure e_UnpressAllKeys ();
+var
+ i: Integer;
+begin
+ for i := 0 to High(KeyBuffer) do KeyBuffer[i] := False;
+end;
+
+
+procedure e_KeyUpDown (key: Word; down: Boolean);
+begin
+ if (key > 0) and (key < Length(KeyBuffer)) then KeyBuffer[key] := down;
+end;
+
+
function PollKeyboard(): Boolean;
var
Keys: PByte;
begin
Result := False;
Keys := SDL_GetKeyboardState(@NKeys);
- if (Keys = nil) or (NKeys < 1) then
- Exit;
+ if (Keys = nil) or (NKeys < 1) then Exit;
for i := 0 to NKeys do
- KeyBuffer[i] := ((PByte(NativeUInt(Keys) + i)^) <> 0);
- for i := NKeys to High(KeyBuffer) do
- KeyBuffer[i] := False;
+ begin
+ if ((PByte(NativeUInt(Keys) + i)^) <> 0) then KeyBuffer[i] := false;
+ end;
+ for i := NKeys to High(KeyBuffer) do KeyBuffer[i] := False;
end;
function PollJoysticks(): Boolean;
diff --git a/src/game/g_holmes.pas b/src/game/g_holmes.pas
index 98c458c7619d1e33d06c594789aa10ae4f25db73..3a50ffaba189b0355483ab7aa86d5eb26f4a009a 100644 (file)
--- a/src/game/g_holmes.pas
+++ b/src/game/g_holmes.pas
end;
+var
+ olEdgeL: array of Boolean = nil;
+ olEdgeR: array of Boolean = nil;
+ olEdgeU: array of Boolean = nil;
+ olEdgeD: array of Boolean = nil;
+
+procedure drawOutlines ();
+begin
+end;
+
+
procedure plrDebugDraw ();
procedure drawTileGrid ();
var
x, y: Integer;
begin
- {
- y := mapGrid.gridY0;
- while (y < mapGrid.gridY0+mapGrid.gridHeight) do
- begin
- x := mapGrid.gridX0;
- while (x < mapGrid.gridX0+mapGrid.gridWidth) do
- begin
- if (x+mapGrid.tileSize > vpx) and (y+mapGrid.tileSize > vpy) and
- (x < vpx+vpw) and (y < vpy+vph) then
- begin
- //e_DrawQuad(x, y, x+mapGrid.tileSize-1, y+mapGrid.tileSize-1, 96, 96, 96, 96);
- drawRect(x, y, mapGrid.tileSize, mapGrid.tileSize, 96, 96, 96, 255);
- end;
- Inc(x, mapGrid.tileSize);
- end;
- Inc(y, mapGrid.tileSize);
- end;
- }
for y := 0 to (mapGrid.gridHeight div mapGrid.tileSize) do
begin
drawLine(mapGrid.gridX0, mapGrid.gridY0+y*mapGrid.tileSize, mapGrid.gridX0+mapGrid.gridWidth, mapGrid.gridY0+y*mapGrid.tileSize, 96, 96, 96, 255);
glPushMatrix();
glTranslatef(-vpx, -vpy, 0);
+ drawOutlines();
+
if (showGrid) then drawTileGrid();
if (laserSet) then g_Mons_AlongLine(laserX0, laserY0, laserX1, laserY1, monsCollector, true);
diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index 40f74029241e05bdffc5aee7fc686c0d009fd98f..17aa0479563d2239f9a3db5305b5b44a07fad5f9 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
begin
curMsButState := 0;
curKbState := 0;
+ e_UnpressAllKeys();
if not wMinimized then
begin
e_ResizeWindow(0, 0);
curMsButState := 0;
curKbState := 0;
wDeactivate := True;
+ e_UnpressAllKeys();
//e_WriteLog('window lost focus!', MSG_NOTIFY);
g_Holmes_WindowBlured();
end;
kbev.sym := ev.key.keysym.sym;
kbev.bstate := curMsButState;
kbev.kstate := curKbState;
- if g_Holmes_keyEvent(kbev) then exit;
+ if g_Holmes_keyEvent(kbev) then
+ begin
+ if (ev.type_ <> SDL_KEYDOWN) then e_KeyUpDown(ev.key.keysym.scancode, false);
+ exit;
+ end;
end;
if (ev.type_ = SDL_KEYDOWN) then KeyPress(key);
+ e_KeyUpDown(ev.key.keysym.scancode, (ev.type_ = SDL_KEYDOWN));
end;
SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP: