You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorial/part-01.rst
+68-19Lines changed: 68 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,9 @@ You should have ``main.py`` script from :ref:`part-0`:
17
17
18
18
.. code-block:: python
19
19
20
+
from__future__import annotations
21
+
22
+
20
23
defmain() -> None:
21
24
...
22
25
@@ -36,6 +39,7 @@ These kinds of tilesets are always loaded with :python:`columns=16, rows=16, cha
36
39
Use the string :python:`"data/Alloy_curses_12x12.png"` to refer to the path of the tileset. [#why_not_pathlib]_
37
40
38
41
Load the tileset with :any:`tcod.tileset.load_tilesheet`.
42
+
Pass the tileset to :any:`tcod.tileset.procedural_block_elements` which will fill in most `Block Elements <https://en.wikipedia.org/wiki/Block_Elements>`_ missing from `Code Page 437 <https://en.wikipedia.org/wiki/Code_page_437>`_.
39
43
Then pass the tileset to :any:`tcod.context.new`, you only need to provide the ``tileset`` parameter.
40
44
41
45
:any:`tcod.context.new` returns a :any:`Context` which will be used with Python's :python:`with` statement.
@@ -45,9 +49,10 @@ The new block can't be empty, so add :python:`pass` to the with statement body.
45
49
These functions are part of modules which have not been imported yet, so new imports for ``tcod.context`` and ``tcod.tileset`` must be added to the top of the script.
46
50
47
51
.. code-block:: python
48
-
:emphasize-lines: 2,3,8-12
52
+
:emphasize-lines: 3,4,8-14
53
+
54
+
from__future__import annotations
49
55
50
-
...
51
56
import tcod.context # Add these imports
52
57
import tcod.tileset
53
58
@@ -57,9 +62,13 @@ These functions are part of modules which have not been imported yet, so new imp
with tcod.context.new(tileset=tileset) as context:
61
67
pass# The window will stay open for the duration of this block
62
-
...
68
+
69
+
70
+
if__name__=="__main__":
71
+
main()
63
72
64
73
If an import fails that means you do not have ``tcod`` installed on the Python environment you just used to run the script.
65
74
If you use an IDE then make sure the Python environment it is using is correct and then run :shell:`pip install tcod` from the shell terminal within that IDE.
@@ -88,18 +97,22 @@ Then test if an event is for closing the window with :python:`if isinstance(even
88
97
If this is True then you should exit the function with :python:`raise SystemExit()`. [#why_raise]_
89
98
90
99
.. code-block:: python
91
-
:emphasize-lines: 2,3,11-19
100
+
:emphasize-lines: 3,5,15-23
101
+
102
+
from__future__import annotations
92
103
93
-
...
94
104
import tcod.console
105
+
import tcod.context
95
106
import tcod.event
107
+
import tcod.tileset
96
108
97
109
98
110
defmain() -> None:
99
111
"""Show "Hello World" until the window is closed."""
0 commit comments