Skip to content

Commit

Permalink
Get rid of the include captions
Browse files Browse the repository at this point in the history
The ancient sphinx version on wheezy doesn't support it when building
the packages
  • Loading branch information
waveform80 committed Dec 12, 2016
1 parent 23b01df commit 2ee1129
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions docs/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ they walk through the world. If the script detects the player is about to walk
onto air it changes the block to diamond:

.. literalinclude:: examples/bridge1.py
:caption: bridge1.py

Nice, but we can do better. The following script enhances the recipe so that
only blocks which are air are changed to diamond, and the bridge "cleans up"
after itself:

.. literalinclude:: examples/bridge2.py
:caption: bridge2.py

The script uses a list to keep track of the blocks which are present in the
bridge, popping off old blocks when the bridge has more than 10 blocks in it.
Expand All @@ -124,7 +122,6 @@ For example, the following script prints a message to the console when you hit
a block, detailing the block's coordinates and the face that you hit:

.. literalinclude:: examples/poll.py
:caption: poll.py

This is similar to the method used by the official mcpi library. It's fine for
simple scripts but you can probably see how more complex scripts that check
Expand All @@ -134,7 +131,6 @@ of blocks near the player on startup: a black block (which ends the script when
hit), and a white block (which makes multi-colored blocks fall from the sky):

.. literalinclude:: examples/rain1.py
:caption: rain1.py

The alternate method of event handling in picraft is to rely on picraft's
built-in event loop. This involves "tagging" functions which will react to
Expand All @@ -144,15 +140,13 @@ picraft to continually poll the server and call the tagged functions when their
criteria are matched by a block-hit event:

.. literalinclude:: examples/rain2.py
:caption: rain2.py
:emphasize-lines: 14,18

One advantage of this method (other than slightly cleaner code) is that event
handlers can easily be made multi-threaded (to run in parallel with each other)
simply by modifying the decorator used:

.. literalinclude:: examples/rain3.py
:caption: rain3.py
:emphasize-lines: 18

Now you should find that the rain all falls simultaneously (more or less, given
Expand Down Expand Up @@ -190,15 +184,13 @@ Given an origin and a side-length it's a simple matter to iterate over each
side generating the necessary point:

.. literalinclude:: examples/shapes1.py
:caption: shapes1.py

Next we need a function which will iterate over the number of sides for each
required polygon, using the :func:`~picraft.vector.lines` function to generate
the points required to draw the shape. Then it's a simple matter to draw each
polygon in turn, wiping it before displaying the next one:

.. literalinclude:: examples/shapes2.py
:caption: shapes2.py

.. image:: images/shapes.png
:align: center
Expand All @@ -220,12 +212,10 @@ Below is an example object file, which defines the walls and ceiling of a
house.

.. literalinclude:: examples/house.obj
:caption: house.obj

We can render this model with the following simple code:

.. literalinclude:: examples/house.py
:caption: house.py

.. image:: images/house.png
:align: center
Expand All @@ -237,7 +227,6 @@ materials map can be as simple as a :class:`dict` mapping material names to
:class:`~picraft.block.Block` instances. For example:

.. literalinclude:: examples/materials.py
:caption: materials.py

.. image:: images/airboat.png
:align: center
Expand All @@ -254,7 +243,6 @@ quickly previewing a shape without performing any material mapping; simply
provide a function which always returns the same block type:

.. literalinclude:: examples/preview.py
:caption: preview.py

.. _object files: https://en.wikipedia.org/wiki/Wavefront_.obj_file
.. _Alias|Wavefront: https://en.wikipedia.org/wiki/Alias_Systems_Corporation
Expand All @@ -271,7 +259,6 @@ within the cube, then uses the :meth:`~picraft.vector.Vector.rotate` method to
rotate them about the X axis:

.. literalinclude:: examples/anim1.py
:caption: anim1.py

As you can see in the script above we draw the first frame, wait for a bit,
then wipe the frame by setting all coordinates in that frame's state back to
Expand All @@ -288,15 +275,13 @@ coordinates (in the form of :class:`~picraft.vector.Vector` instances) to
:class:`~picraft.block.Block` instances:

.. literalinclude:: examples/anim2.py
:caption: anim2.py

That's more like it, but the updates aren't terribly fast despite using the
batch functionality. In order to improve this we should only update those
blocks which have actually changed between each frame. Thankfully, because
we're storing the state of each as a dict, this is quite easy:

.. literalinclude:: examples/anim3.py
:caption: anim3.py

Note: this still isn't perfect. Ideally, we would identify contiguous blocks of
coordinates to be updated which have the same block and set them all at the
Expand All @@ -315,7 +300,6 @@ as blocks in the Minecraft world. Then we need a class to construct the TV
model itself and enable interaction with it:

.. literalinclude:: examples/tv.py
:caption: tv.py

Don't expect to be able to recognize much in the Minecraft TV; the resolution
is extremely low and the color matching is far from perfect. Still, if you
Expand Down

0 comments on commit 2ee1129

Please sign in to comment.