Skip to content

Commit

Permalink
- starting documentation (level building tutorial)
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1977 committed Jul 10, 2017
1 parent 0ef8ecc commit 18ace48
Show file tree
Hide file tree
Showing 59 changed files with 15,705 additions and 401 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/spygame.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# file GENERATED by distutils, do NOT edit
setup.py
spygame\__init__.py
spygame\examples\vikings.py
15 changes: 8 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#######
spygame
#######
########################
Quick Setup Instructions
########################

.. image:: https://raw.githubusercontent.com/sven1977/spygame/master/examples/platformer_2d/screen2.png
:alt: The Lost Vikings - Sample spygame Level
Expand All @@ -12,15 +12,15 @@ spygame

Get the code
------------
- Git the `spygame <www.github.com/sven1977/spygame>`_ code or do a `pip install spygame`
- You may need a pygame version that matches your python version. E.g. for Windows 10 64bit + python3.6, you can download `pygame‑1.9.3‑cp36‑cp36m‑win_amd64.whl from here <http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame>`_ and then do a ``pip install [path to downloaded wheel]``
- Git the `spygame <www.github.com/sven1977/spygame>`_ code or do a ``pip install spygame``

Get started
-----------
- write a simple game against the engine:

.. highlight:: python
:linenos:

::

import spygame as spyg
Expand Down Expand Up @@ -60,8 +60,9 @@ Get started
# that's it, play one of the levels -> this will enter an endless game loop
game.levels_by_name["MAZE"].play()


All you need in order to run this game is the above code in a directory, and the additional subdirectories data/ and images/, which can
be found `here <www.github.com/sven1977/spygame/tree/master/examples/maze_runner>`_. These directories contain the necessary SpriteSheets,
be found `here <http://github.com/sven1977/spygame/tree/master/examples/maze_runner>`_. These directories contain the necessary SpriteSheets,
level background images and level setup (collision layers, background images, position and class of the player, etc..).

This should give you a level like this:
Expand All @@ -80,7 +81,7 @@ Next steps
----------

If you would like to create more complex levels (or entire Games with many Screens and Levels), read the spygame documentation, in which we'll
create a full-blown 2D platformer Level.
create a full-blown 2D platformer Level (sorry, documentation is still very WIP!).

AI (Reinforcement Learning) with spygame
----------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- make Animation setting not dependent on SpriteSheet's name (some SpriteSheets contain many Anim settings , e.g. enemies.tsx)
- include water, quicksand, waterfall, etc.. in the ladder-processing algo run on the background layer (if build_ladders=true)
- create shootable coconuts that end up in the quicksand for Baleog to be able to cross
- create key items that can be picked up by the Vikings
699 changes: 449 additions & 250 deletions docs/_build/html/_modules/spygame.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/_build/html/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Welcome to spygame's documentation!
===================================

.. toctree::
:maxdepth: 2
:maxdepth: 3
:caption: Contents:

readme_link.rst
intro.rst
how_to_build_a_platformer.rst
spygame.rst
modules.rst

Expand Down
46 changes: 38 additions & 8 deletions docs/_build/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ <h2 id="A">A</h2>
<li><a href="spygame.html#spygame.PhysicsComponent.added">(spygame.PhysicsComponent method)</a>
</li>
<li><a href="spygame.html#spygame.PlatformerPhysics.added">(spygame.PlatformerPhysics method)</a>
</li>
<li><a href="spygame.html#spygame.SimpleHumanBrain.added">(spygame.SimpleHumanBrain method)</a>
</li>
<li><a href="spygame.html#spygame.TopDownPhysics.added">(spygame.TopDownPhysics method)</a>
</li>
Expand All @@ -140,6 +142,8 @@ <h2 id="A">A</h2>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Sprite.added_to_stage">added_to_stage() (spygame.Sprite method)</a>
</li>
<li><a href="spygame.html#spygame.AIBrain">AIBrain (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.HumanPlayerBrain.anim_ends">anim_ends() (spygame.HumanPlayerBrain method)</a>
Expand All @@ -164,13 +168,15 @@ <h2 id="B">B</h2>
</li>
<li><a href="spygame.html#spygame.KeyboardBrainTranslation.BLOCK_OTHER_CMD_UNTIL_ANIM_COMPLETE">BLOCK_OTHER_CMD_UNTIL_ANIM_COMPLETE (spygame.KeyboardBrainTranslation attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.KeyboardBrainTranslation.BLOCK_REPEAT_UNTIL_ANIM_COMPLETE">BLOCK_REPEAT_UNTIL_ANIM_COMPLETE (spygame.KeyboardBrainTranslation attribute)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Brain">Brain (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.TiledTileLayer.build_sprite_surface">build_sprite_surface() (spygame.TiledTileLayer method)</a>
</li>
<li><a href="spygame.html#spygame.AIBrain.bumped">bumped() (spygame.AIBrain method)</a>
</li>
</ul></td>
</tr></table>
Expand Down Expand Up @@ -209,11 +215,19 @@ <h2 id="C">C</h2>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.PlatformerPhysics.collide_in_one_direction">collide_in_one_direction() (spygame.PlatformerPhysics method)</a>

<ul>
<li><a href="spygame.html#spygame.TopDownPhysics.collide_in_one_direction">(spygame.TopDownPhysics method)</a>
</li>
</ul></li>
<li><a href="spygame.html#spygame.TiledTileLayer.collide_simple_with_sprite">collide_simple_with_sprite() (spygame.TiledTileLayer method)</a>
</li>
<li><a href="spygame.html#spygame.PlatformerPhysics.collide_with_collision_layer">collide_with_collision_layer() (spygame.PlatformerPhysics method)</a>

<ul>
<li><a href="spygame.html#spygame.TopDownPhysics.collide_with_collision_layer">(spygame.TopDownPhysics method)</a>
</li>
</ul></li>
<li><a href="spygame.html#spygame.Collision">Collision (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.PhysicsComponent.collision">collision() (spygame.PhysicsComponent method)</a>
Expand Down Expand Up @@ -407,15 +421,17 @@ <h2 id="L">L</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Ladder">Ladder (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.MovableRock.land">land() (spygame.MovableRock method)</a>
</li>
<li><a href="spygame.html#spygame.Level">Level (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.Game.level_aborted">level_aborted() (spygame.Game method)</a>
</li>
<li><a href="spygame.html#spygame.Game.level_lost">level_lost() (spygame.Game method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Game.level_lost">level_lost() (spygame.Game method)</a>
</li>
<li><a href="spygame.html#spygame.Game.level_mastered">level_mastered() (spygame.Game method)</a>
</li>
<li><a href="spygame.html#spygame.Stage.locate">locate() (spygame.Stage method)</a>
Expand All @@ -431,6 +447,8 @@ <h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Stage.max_stages">max_stages (spygame.Stage attribute)</a>
</li>
<li><a href="spygame.html#spygame.MovableRock">MovableRock (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.Dockable.move">move() (spygame.Dockable method)</a>

Expand Down Expand Up @@ -513,6 +531,8 @@ <h2 id="P">P</h2>
<li><a href="spygame.html#spygame.Dockable.PREVIOUSLY_DOCKED">PREVIOUSLY_DOCKED (spygame.Dockable attribute)</a>
</li>
<li><a href="spygame.html#spygame.PlatformerPhysics.push_an_object">push_an_object() (spygame.PlatformerPhysics method)</a>
</li>
<li><a href="spygame.html#spygame.PlatformerPhysics.push_back">push_back() (spygame.PlatformerPhysics method)</a>
</li>
</ul></td>
</tr></table>
Expand Down Expand Up @@ -571,6 +591,8 @@ <h2 id="S">S</h2>
<li><a href="spygame.html#spygame.Viewport.shake_viewport">shake_viewport() (spygame.Viewport method)</a>
</li>
<li><a href="spygame.html#spygame.Stage.show">show() (spygame.Stage method)</a>
</li>
<li><a href="spygame.html#spygame.SimpleHumanBrain">SimpleHumanBrain (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.SimpleScreen">SimpleScreen (class in spygame)</a>
</li>
Expand All @@ -583,11 +605,11 @@ <h2 id="S">S</h2>
<li><a href="spygame.html#spygame.Stage.solve_collisions">solve_collisions() (spygame.Stage method)</a>
</li>
<li><a href="spygame.html#spygame.Sprite">Sprite (class in spygame)</a>
</li>
<li><a href="spygame.html#spygame.SpriteSheet">SpriteSheet (class in spygame)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.SpriteSheet">SpriteSheet (class in spygame)</a>
</li>
<li><a href="spygame.html#module-spygame">spygame (module)</a>
</li>
<li><a href="spygame.html#spygame.Stage">Stage (class in spygame)</a>
Expand Down Expand Up @@ -638,10 +660,14 @@ <h2 id="T">T</h2>
<li><a href="spygame.html#spygame.HumanPlayerBrain.tick">(spygame.HumanPlayerBrain method)</a>
</li>
<li><a href="spygame.html#spygame.KeyboardInputs.tick">(spygame.KeyboardInputs method)</a>
</li>
<li><a href="spygame.html#spygame.MovableRock.tick">(spygame.MovableRock method)</a>
</li>
<li><a href="spygame.html#spygame.PhysicsComponent.tick">(spygame.PhysicsComponent method)</a>
</li>
<li><a href="spygame.html#spygame.PlatformerPhysics.tick">(spygame.PlatformerPhysics method)</a>
</li>
<li><a href="spygame.html#spygame.SimpleHumanBrain.tick">(spygame.SimpleHumanBrain method)</a>
</li>
<li><a href="spygame.html#spygame.Stage.tick">(spygame.Stage method)</a>
</li>
Expand All @@ -652,6 +678,8 @@ <h2 id="T">T</h2>
</ul></li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Stage.tick_sprite">tick_sprite() (spygame.Stage static method)</a>
</li>
<li><a href="spygame.html#spygame.PhysicsComponent.tile_sprite_handler">tile_sprite_handler() (spygame.PhysicsComponent static method)</a>
</li>
<li><a href="spygame.html#spygame.TiledObjectGroup">TiledObjectGroup (class in spygame)</a>
Expand Down Expand Up @@ -687,15 +715,17 @@ <h2 id="U">U</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Dockable.undock">undock() (spygame.Dockable method)</a>
</li>
<li><a href="spygame.html#spygame.Dockable.undock_all_docked_objects">undock_all_docked_objects() (spygame.Dockable method)</a>
</li>
<li><a href="spygame.html#spygame.Viewport.unfollow_object_with_viewport">unfollow_object_with_viewport() (spygame.Viewport method)</a>
</li>
<li><a href="spygame.html#spygame.PlatformerPhysics.unlock_ladder">unlock_ladder() (spygame.PlatformerPhysics method)</a>
</li>
<li><a href="spygame.html#spygame.Stage.unpause">unpause() (spygame.Stage method)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="spygame.html#spygame.Stage.unpause">unpause() (spygame.Stage method)</a>
</li>
<li><a href="spygame.html#spygame.EventObject.unregister_event">unregister_event() (spygame.EventObject method)</a>
</li>
<li><a href="spygame.html#spygame.EventObject.unregister_events">unregister_events() (spygame.EventObject method)</a>
Expand Down
42 changes: 35 additions & 7 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Introduction to spygame" href="intro.html" />
<link rel="next" title="Quick Setup Instructions" href="readme_link.html" />
</head>
<body>
<div class="related" role="navigation" aria-label="related navigation">
Expand All @@ -40,7 +40,7 @@ <h3>Navigation</h3>
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="intro.html" title="Introduction to spygame"
<a href="readme_link.html" title="Quick Setup Instructions"
accesskey="N">next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">spygame 0.1.0 documentation</a> &#187;</li>
</ul>
Expand All @@ -54,8 +54,8 @@ <h3><a href="#">Table Of Contents</a></h3>
</ul>

<h4>Next topic</h4>
<p class="topless"><a href="intro.html"
title="next chapter">Introduction to spygame</a></p>
<p class="topless"><a href="readme_link.html"
title="next chapter">Quick Setup Instructions</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
Expand Down Expand Up @@ -86,17 +86,45 @@ <h1>Welcome to spygame’s documentation!<a class="headerlink" href="#welcome-to
<div class="toctree-wrapper compound">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="readme_link.html">Quick Setup Instructions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="readme_link.html#d-game-engine-based-on-pygame-and-level-tmx-files">2D game engine based on Pygame and level-tmx files</a><ul>
<li class="toctree-l3"><a class="reference internal" href="readme_link.html#get-the-code">Get the code</a></li>
<li class="toctree-l3"><a class="reference internal" href="readme_link.html#get-started">Get started</a></li>
<li class="toctree-l3"><a class="reference internal" href="readme_link.html#next-steps">Next steps</a></li>
<li class="toctree-l3"><a class="reference internal" href="readme_link.html#ai-reinforcement-learning-with-spygame">AI (Reinforcement Learning) with spygame</a></li>
<li class="toctree-l3"><a class="reference internal" href="readme_link.html#contribute-to-spygame">Contribute to spygame</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introduction to spygame</a><ul>
<li class="toctree-l2"><a class="reference internal" href="intro.html#what-is-spygame">What is spygame?</a></li>
<li class="toctree-l2"><a class="reference internal" href="intro.html#main-features">Main Features</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="how_to_build_a_platformer.html">How to build a Platformer</a><ul>
<li class="toctree-l2"><a class="reference internal" href="how_to_build_a_platformer.html#level-tmx-files">Level tmx-files</a></li>
<li class="toctree-l2"><a class="reference internal" href="how_to_build_a_platformer.html#layers">Layers</a><ul>
<li class="toctree-l3"><a class="reference internal" href="how_to_build_a_platformer.html#the-collision-layer">The Collision Layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="how_to_build_a_platformer.html#background-and-foreground-layers">Background and Foreground Layers</a></li>
<li class="toctree-l3"><a class="reference internal" href="how_to_build_a_platformer.html#the-object-layer">The Object Layer</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="how_to_build_a_platformer.html#writing-a-class-in-spygame">Writing a Class in spygame</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="spygame.html">spygame package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="spygame.html#module-spygame">Module contents</a></li>
<li class="toctree-l2"><a class="reference internal" href="spygame.html#module-spygame">Module contents</a><ul>
<li class="toctree-l3"><a class="reference internal" href="spygame.html#spygame-pygame-based-2d-game-engine-for-the-openai-gym">spygame (pygame based 2D game engine for the openAI gym)</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="modules.html">spygame</a><ul>
<li class="toctree-l2"><a class="reference internal" href="spygame.html">spygame package</a></li>
<li class="toctree-l2"><a class="reference internal" href="spygame.html">spygame package</a><ul>
<li class="toctree-l3"><a class="reference internal" href="spygame.html#module-spygame">Module contents</a></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down Expand Up @@ -127,7 +155,7 @@ <h3>Navigation</h3>
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="intro.html" title="Introduction to spygame"
<a href="readme_link.html" title="Quick Setup Instructions"
>next</a> |</li>
<li class="nav-item nav-item-0"><a href="#">spygame 0.1.0 documentation</a> &#187;</li>
</ul>
Expand Down
Binary file modified docs/_build/html/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions docs/how_to_build_a_platformer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
How to build a Platformer
=========================

In this tutorial, we will be building a 2D platformer from scratch using the spygame library. You will need the following software and files to follow along
with the different steps:

- The "Tiled" editor to create spygame's level-tmx files. A level-tmx file contains all necessary information for spygame to build a complete level, i.e.
background and foreground graphics, objects that the level will start with (e.g. player, enemies, traps, elevators, ladders, etc..).
You can download `Tiled from here <http://www.mapeditor.org>`_.
- The spygame library: See `Quick Setup Instructions <readme_link.html#get-the-code>`_ for all necessary details on how to get and install spygame.
- Some asset files: Download the following two folders into the directory, in which you would like to develop the game. This will be the directory, in
which we will write the platformer_2d.py file (the only file we are going to edit in this tutorial).

a) images/ (`from here <>`_)
b) data/ (create this as an empty directory, we'll be populating it from scratch with one level-tmx and several tsx (spygame SpriteSheet) files)

Level tmx-files
---------------

Layers
------

The Collision Layer
+++++++++++++++++++

Background and Foreground Layers
++++++++++++++++++++++++++++++++

The Object Layer
++++++++++++++++


Writing a Class in spygame
--------------------------


4 changes: 3 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Welcome to spygame's documentation!
===================================

.. toctree::
:maxdepth: 2
:maxdepth: 3
:caption: Contents:

readme_link.rst
intro.rst
how_to_build_a_platformer.rst
spygame.rst
modules.rst

Expand Down
1 change: 1 addition & 0 deletions docs/readme_link.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../README.rst
2 changes: 0 additions & 2 deletions examples/platformer_2d/__init__.py

This file was deleted.

4 changes: 4 additions & 0 deletions examples/platformer_2d/data/arrow.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset name="arrow" tilewidth="16" tileheight="5" tilecount="4" columns="4">
<image source="../images/arrow.png" width="64" height="10"/>
</tileset>
Loading

0 comments on commit 18ace48

Please sign in to comment.