Skip to content

Commit

Permalink
Add special globals module.
Browse files Browse the repository at this point in the history
Disallow untyped definitions.

Organize imports from VS Code.

Enable all runtime warnings.
  • Loading branch information
HexDecimal committed Mar 6, 2021
1 parent b9be189 commit 4e0f803
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ warn_unused_configs = True
disallow_any_generics = True
disallow_subclassing_any = True
disallow_untyped_calls = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
check_untyped_defs = True
disallow_untyped_decorators = True
Expand Down
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
"python.linting.mypyEnabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyArgs": [
"--strict",
"--ignore-missing-imports",
"--follow-imports=silent",
"--show-column-numbers"
],
"editor.rulers": [
120
],
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
}
7 changes: 7 additions & 0 deletions g.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Shorthand globals module. For sharing mutable objects across modules.
This is for organization and has no special effects.
"""
import tcod

context: tcod.context.Context # Global context
25 changes: 22 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
#!/usr/bin/env python3
"""Main module.
Run this module from Python to start this program.
"""
import sys
import warnings

import tcod

import g

SCREEN_WIDTH = 1280
SCREEN_HEIGHT = 720

CONSOLE_WIDTH = SCREEN_WIDTH // 12
CONSOLE_HEIGHT = SCREEN_HEIGHT // 12


def main() -> None:
"""Main entrypoint."""
tileset = tcod.tileset.load_tilesheet("Alloy_curses_12x12.png", 16, 16, tcod.tileset.CHARMAP_CP437)
console = tcod.console.Console(1280 // 12, 720 // 12, order="C")
with tcod.context.new(width=1280, height=720, tileset=tileset) as context:
with tcod.context.new(width=SCREEN_WIDTH, height=SCREEN_HEIGHT, tileset=tileset) as g.context:
while True:
# Rendering.
console = tcod.console.Console(CONSOLE_WIDTH, CONSOLE_HEIGHT, order="C")
console.print(0, 0, "Hello World")
context.present(console, integer_scaling=True)
g.context.present(console, integer_scaling=True)
# Handle input.
for event in tcod.event.wait():
if isinstance(event, tcod.event.Quit):
raise SystemExit()


if __name__ == "__main__":
if not sys.warnoptions:
warnings.simplefilter("default") # Enable all runtime warnings.
main()

0 comments on commit 4e0f803

Please sign in to comment.