Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/Royce/GammaJS
Browse files Browse the repository at this point in the history
  • Loading branch information
delfick committed Jan 2, 2011
2 parents 6c49938 + a3c4bc1 commit b56c480
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 16 deletions.
82 changes: 74 additions & 8 deletions docs/advanced/install.txt
Expand Up @@ -3,15 +3,17 @@
Developing with Gamma
=====================

Gamma is a modular library that is split into many files. Whilst you can use a combined and :term:`minified` version of the library, as shown in the :ref:`getting started section <install>`, it's a lot easier to develop and debug you game if you can view the full source code. This allows you to see the code where errors originate from and set breakpoints in the Gamma library.
Gamma is a modular library that is split into many files. Whilst you can use a combined and :term:`minified` version of the library, as shown in the :ref:`getting started section <install>`, it's a lot easier to develop and debug your game if you can view the full source code. This allows you to see the code where errors originate from and set breakpoints in the Gamma library.

To install the non-minified version, you must download a few files and modify your HTML page to tell RequireJS where to find the Gamma library:
To make the process even easier, you can also :ref:`use the development server <devServer>` found in the support directory of the repository. However, for just executing your game, you can just create a html file as explained below. Either method still requires a copy of the source code, which can be gotten by running ``git clone git://github.com/Royce/GammaJS.git``.

To make your own html boilerplate files :

* Follow the :ref:`getting started section <install>`.

* Download all the `Gamma files <http://lodle.dyndns.org:8/code/gma.tar.bz2>`_ and untar it so you have the ``gma`` folder next to your other files.
* Download :ref:`RequireJS <requireJSNS>` from `here <http://requirejs.org/docs/release/0.2.1/minified/require-jquery-1.4.4.js>`_

* Download :ref:`RequireJS <requireJSNS>` and the other libraries that Gamma uses, which you can find in a `single, minifed file <http://lodle.dyndns.org:8/code/libs-min.js>`_.
* Get the ``libs.js`` from the ``support/lib/compiled`` directory.

* Inside ``game.html``, replace the ``head`` element with the following:

Expand All @@ -28,14 +30,78 @@ To install the non-minified version, you must download a few files and modify yo
<script type="text/javascript">
var require = {
baseUrl: "",
waitSeconds: 15,
context: "gma"
waitSeconds: 15
};
</script>

<!-- Include the necessary libraries -->
<script type="text/javascript" src="libs-min.js"></script>
<script type="text/javascript" src="require.js"></script>
<script type="text/javascript" src="libs.js"></script>

</head>


* Change baseUrl to point to the folder that contains the ``gma`` folder. So if you have the following folder structure, then baseUrl would be "GammaJS".

.. code-block:: javascript

game.html
game.js
require.js
libs.js
GammaJS/
gma/
support/
docs/
examples/
media/

* That's it!

Running the Tests
=================

To Run the tests, you must first preprocess them to convert them from the JSpec dsl to normal javascript. For this to then work with RequireJS, we need to fetch the tests, run the JSpec preprocessor over them and change the usage of require to define a dependency name (we're lazy and don't think we should have to define the dependency for each tests manually). Unfortunately this means XMLHttpRequest errors unless everything is served using HTTP.

In turn, this means you need the development server to be able to run the tests. However, once you have it setup, running the tests is literally as simple as clicking a link.

.. _devServer:

Running the Development server
==============================

Different parts of the development server require some environment variables to be set that point to where you have different parts of the code. If you keep the same structure as found in the repository, then the following environment variables should work.

.. code-block:: sh

GMA = /path/to/GammaJS
GMA_SRC = $GMA/gma
GMA_SUPPORT = $GMA/support
GMA_MEDIA = $GMA/media

To be able to run tests and examples:
* Install python-setuptools
* Use setuptools and do ``easy_install werkzeug paste django``
* Execute ``run.sh`` found in the support folder and go to ``http://localhost:8000`` in your webgl enabled web browser.

To be able to run js-coverage (linux and mac only):
* install autoconf and g++
* ``svn co http://svn.siliconforks.com/jscoverage/trunk jscoverage``
* ``cd jscoverage``
* ``./bootstrap.sh``
* ``make``
* ``make install``
* Execute ``coverage.sh`` inside the support directory
* Go to the development server and either click the ``coverage`` link next to the test you want to get coverage data from. Or click the ``Coverage`` button at the top of the page and choose your desired test from the drop down list.

To be able to make the documentation:
* ``easy_install sphinx``
* Go into the docs directory and run ``make html``

To build a minified, single file version of Gamma:
* Install Java
* Unzip the `RequireJS Optimisation tool <http://requirejs.org/docs/release/0.14.2/requirejs-0.14.2.zip>`_ somewhere
* Create an environment variable called ``REQUIRE`` that points to where you unzipped the optimisation tool
* Run ``python build.py`` inside the support directory
* The result can be found in $GMA_SUPPORT/lib/compiled

For an explanation of how it all works and general notes about the code, read the readme files that exist inside the support folder.
4 changes: 2 additions & 2 deletions docs/tutorials/collada.txt
Expand Up @@ -3,7 +3,7 @@ Using Collada

`Collada <https://collada.org>`_ is open standard xml schema to define a model. Most 3D modelling applications support exporting models in this format (a .dae file).

For this tutorial we will use `a gorilla model <http://lodle.dyndns.org:8/code/collada/gorilla.dae>`_ to represent the character. Download the `gorilla model <http://lodle.dyndns.org:8/code/collada/gorilla.dae>`_ and the `gorilla's texture file <http://lodle.dyndns.org:8/code/collada/skin.jpg>`_ and put them in the same directory.
For this tutorial we will use `a gorilla model <https://github.com/Royce/GammaJS/raw/master/media/collada/gorilla/gorilla.dae>`_ to represent the character. Download the `gorilla model <https://github.com/Royce/GammaJS/raw/master/media/collada/gorilla/gorilla.dae>`_ and the `gorilla's texture file <https://github.com/Royce/GammaJS/raw/master/media/collada/gorilla/skin.jpg>`_ and put them in the same directory.

Create a collada template
-------------------------
Expand Down Expand Up @@ -45,7 +45,7 @@ Unfortunately the gorilla is facing the wrong direction and not centered correct
.. note::
Loading the Collada file requires that your game's JavaScript file and the collada model are both fetched via http and from the same server. Accessing your game via the local filesystem (without a server) will not work.

If the url in thr browser starts with "file:///" then you're accessing your game straight from the local filesystem. You will need to serve you files from a web server like `Apache <http://httpd.apache.org/>`_, `Lighttpd <http://www.lighttpd.net/>`_ or `IIS <http://www.iis.net/>`_
If the url in the browser starts with "file:///" then you're accessing your game straight from the local filesystem. You will need to serve you files from a web server like `Apache <http://httpd.apache.org/>`_, `Lighttpd <http://www.lighttpd.net/>`_ or `IIS <http://www.iis.net/>`_

Assign the template to the character
------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/textures.txt
Expand Up @@ -14,7 +14,7 @@ To apply a texture to an entity you must first define a template. As when creati
}
});

.. note:: For this to work, you will need a file called ``bricks.jpg`` in the same folder as your HTML. You can either make your own, or just `download ours <http://lodle.dyndns.org:8/code/textures/bricks.jpg>`_.
.. note:: For this to work, you will need a file called ``bricks.jpg`` in the same folder as your HTML. You can either make your own, or just `download ours <https://github.com/Royce/GammaJS/raw/master/media/textures/bricks.jpg>`_.

The texture will loop once for every unit of height and width. For our brick texture, however, we want the bricks to be larger. This is achieved by decreasing the amount the texture is looped for every unit using the ``repeatX`` and ``repeatY`` attributes.

Expand Down
2 changes: 1 addition & 1 deletion support/APIgen/readme
Expand Up @@ -3,7 +3,7 @@ Author : Stephen Moore <delfick755@gmail.com>
APIGen
======

ApiGen is a tool based of YUIDoc (http://developer.yahoo.com/yui/yuidoc/) that is used to look at JavaScript code and create API documentation.
ApiGen is a tool based off YUIDoc (http://developer.yahoo.com/yui/yuidoc/) that is used to look at JavaScript code and create API documentation.

It does this by looking for particular expressive comments (using a style similar to JavaDoc) to discover how the application is structured. This is done instead of getting the data straight from the code so that the programmer may not be tied to any particular way of writing their code, which in JavaScript, can vary quite significantly.

Expand Down
6 changes: 3 additions & 3 deletions support/readme
Expand Up @@ -6,7 +6,7 @@ This is the support folder for the Gamma project. It holds within it the followi
* APIGen (see the readme in the APIGen folder)
* Support libraries (the lib folder)
* A development server for finding/executing code/tests (see readme in the web folder)
* Some scripts for conveience at the top level
* Some scripts for convenience at the top level

Requirements
============
Expand Down Expand Up @@ -48,6 +48,6 @@ To set them on windows, you go to the same place as above when you edited the PA
GMA = path to the main repository
GMA_SRC = path to the source code
GMA_MEDIA = path to a folder where you will keep any media files (i.e. images, collada, etc)
GMA_SUPPORT = path to a this repository
GMA_SUPPORT = path to a this folder

If you want to be able to build the Gamma code into a single javascript file you'll also need REQUIRE, which points to a copy of the requirejs optimization tool (http://requirejs.org/docs/release/0.14.2/requirejs-0.14.2.zip)
If you want to be able to build the Gamma code into a single javascript file you'll also need an environment variable called "REQUIRE", which points to a copy of the requirejs optimization tool (http://requirejs.org/docs/release/0.14.2/requirejs-0.14.2.zip)
2 changes: 1 addition & 1 deletion support/web/readme
Expand Up @@ -26,7 +26,7 @@ Currently the development server works and it does what it should and doesn't se
Starting the server
===================

To start the server, just run /web/server.py or "run.sh" at the top level. It will then be found at http://localhost:8000.
To start the server, just run /web/server.py or "run.sh" from the support folder. It will then be found at http://localhost:8000.

Url Scheme
==========
Expand Down

0 comments on commit b56c480

Please sign in to comment.