Skip to content

Commit 9c29b1a

Browse files
committed
Update tutorial part 1
1 parent e597ceb commit 9c29b1a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

docs/tutorial/part-01.rst

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Part 1 - Moving a player around the screen
55

66
.. include:: notice.rst
77

8+
In part 1 you will become familiar with the initialization, rendering, and event system of tcod.
9+
This will be done as a series of small implementations.
10+
It is recommend to save your progress after each section is finished and tested.
11+
812
Initial script
913
==============================================================================
1014

@@ -29,10 +33,16 @@ From here it is time to setup a ``tcod`` program.
2933
Download `Alloy_curses_12x12.png <https://raw.githubusercontent.com/HexDecimal/python-tcod-tutorial-2023/6b69bf9b5531963a0e5f09f9d8fe72a4001d4881/data/Alloy_curses_12x12.png>`_ [#tileset]_ and place this file in your projects ``data/`` directory.
3034
This tileset is from the `Dwarf Fortress tileset repository <https://dwarffortresswiki.org/index.php/DF2014:Tileset_repository>`_.
3135
These kinds of tilesets are always loaded with :python:`columns=16, rows=16, charmap=tcod.tileset.CHARMAP_CP437`.
36+
Use the string :python:`"data/Alloy_curses_12x12.png"` to refer to the path of the tileset. [#why_not_pathlib]_
37+
38+
Load the tileset with :any:`tcod.tileset.load_tilesheet`.
39+
Then pass the tileset to :any:`tcod.context.new`, you only need to provide the ``tileset`` parameter.
3240

33-
Load the tileset with :any:`tcod.tileset.load_tilesheet` and then pass it to :any:`tcod.context.new`.
34-
These functions are part of modules which have not been imported yet, so new imports need to be added.
35-
:any:`tcod.context.new` returns a :any:`Context` which is used with the ``with`` statement.
41+
:any:`tcod.context.new` returns a :any:`Context` which will be used with Python's :python:`with` statement.
42+
We want to keep the name of the context, so use the syntax: :python:`with tcod.context.new(tileset=tileset) as context:`.
43+
The new block can't be empty, so add :python:`pass` to the with statement body.
44+
45+
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.
3646

3747
.. code-block:: python
3848
:emphasize-lines: 2,3,8-12
@@ -54,7 +64,7 @@ These functions are part of modules which have not been imported yet, so new imp
5464
If an import fails that means you do not have ``tcod`` installed on the Python environment you just used to run the script.
5565
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.
5666

57-
If you run this script now then a window will open and then immediately close.
67+
There is no game loop, so if you run this script now then a window will open and then immediately close.
5868
If that happens without seeing a traceback in your terminal then the script is correct.
5969

6070
Configuring an event loop
@@ -241,6 +251,11 @@ You can review the part-1 source code `here <https://github.com/HexDecimal/pytho
241251
.. [#tileset] The choice of tileset came down to what looked nice while also being square.
242252
Other options such as using a BDF font were considered, but in the end this tutorial won't go too much into Unicode.
243253
254+
.. [#why_not_pathlib]
255+
:any:`pathlib` is not used because this example is too simple for that.
256+
The working directory will be the project root folder for the entire tutorial, including distributions.
257+
:any:`pathlib` will be used later for saved games and configuration directories, and not for static data.
258+
244259
.. [#init_context] This tutorial follows the setup for a fixed-size console.
245260
The alternatives shown in :ref:`getting-started` are outside the scope of this tutorial.
246261

0 commit comments

Comments
 (0)