-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type hints, Clean up repository (#5)
Changes: - Add type hints in `.pyi` file - Make workflow run on MacOS, Windows, and Linux, for Python 3.9 and 3.13 - Specify demo dependencies in `pyproject.toml` - Move demos to `demo` directory - Remove `init` function - Add correct compilation flags for MacOS
- Loading branch information
1 parent
735b4e4
commit 5045c36
Showing
16 changed files
with
435 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
*.DS_Store | ||
*.WAD | ||
*.egg-info/ | ||
*.o | ||
*.obj | ||
*.DS_Store | ||
*.so | ||
build/ | ||
.savegame/ | ||
*.WAD | ||
*.so.map | ||
./cydoomgeneric/cydoomgeneric.c | ||
.ropeproject/ | ||
.savegame/ | ||
__pycache__/ | ||
build/ | ||
cydoomgeneric/cydoomgeneric.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
""" | ||
Copyright(C) 2024 Wojciech Graj | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
""" | ||
|
||
from enum import IntEnum | ||
from typing import Callable, Optional, Sequence | ||
|
||
import numpy as np | ||
|
||
def init(resx: int, | ||
resy: int, | ||
draw_frame: Callable[[np.ndarray], None], | ||
get_key: Callable[[], Optional[tuple[int, int]]], | ||
sleep_ms: Optional[Callable[[int], None]] = None, | ||
get_ticks_ms: Optional[Callable[[], int]] = None, | ||
set_window_title: Optional[Callable[[str], None]] = None) -> None: | ||
""" | ||
Initializes the doom context. | ||
:param resx: | ||
:param resy: | ||
:param draw_frame: Called every frame. Takes framebuffer as np.ndarray in | ||
shape [resy, resx, 4]. Pixels are BGR. | ||
:param get_key: Called multiple times every frame until input is exhausted. | ||
Return None when input is exhausted. Otherwise, return | ||
(is pressed ~0/1~, key). | ||
:param sleep_ms: | ||
:param get_ticks_ms: | ||
:param set_window_title: | ||
""" | ||
|
||
|
||
def main(argv: Optional[Sequence[str]] = None) -> int: | ||
""" | ||
main(argv) -> int | ||
Run doom. Must be called after init. | ||
:param Optional[Sequence[str]] argv: | ||
""" | ||
|
||
|
||
class Keys(IntEnum): | ||
RIGHTARROW: int | ||
LEFTARROW: int | ||
UPARROW: int | ||
DOWNARROW: int | ||
STRAFE_L: int | ||
STRAFE_R: int | ||
USE: int | ||
FIRE: int | ||
ESCAPE: int | ||
ENTER: int | ||
TAB: int | ||
F1: int | ||
F2: int | ||
F3: int | ||
F4: int | ||
F5: int | ||
F6: int | ||
F7: int | ||
F8: int | ||
F9: int | ||
F10: int | ||
F11: int | ||
F12: int | ||
|
||
BACKSPACE: int | ||
PAUSE: int | ||
|
||
EQUALS: int | ||
MINUS: int | ||
|
||
RSHIFT: int | ||
RCTRL: int | ||
RALT: int | ||
|
||
LALT: int | ||
|
||
CAPSLOCK: int | ||
NUMLOCK: int | ||
SCRLCK: int | ||
PRTSCR: int | ||
|
||
HOME: int | ||
END: int | ||
PGUP: int | ||
PGDN: int | ||
INS: int | ||
DEL: int | ||
|
||
P_0: int | ||
P_1: int | ||
P_2: int | ||
P_3: int | ||
P_4: int | ||
P_5: int | ||
P_6: int | ||
P_7: int | ||
P_8: int | ||
P_9: int | ||
|
||
P_DIVIDE: int | ||
P_PLUS: int | ||
P_MINUS: int | ||
P_MULTIPLY: int | ||
P_PERIOD: int | ||
P_EQUALS: int | ||
P_ENTER: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.