<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.spheredev.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bruce+Pascoe</id>
		<title>Spherical wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.spheredev.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Bruce+Pascoe"/>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Special:Contributions/Bruce_Pascoe"/>
		<updated>2026-05-13T19:46:56Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.29.0</generator>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10158</id>
		<title>API:Sphere.now</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10158"/>
				<updated>2017-11-15T05:55:45Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Clarify some stuff, add note on odometer rollover&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere.now()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;''' [[API:Functions|Core API]] function returns the number of frames processed since the engine started running.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''frames_elapsed'' = '''Sphere.now'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;''' returns the number of complete event loop turns since the calling game started, each event loop turn corresponding to a frame.  Therefore, on the very first frame this will return 0, on the next frame 1, and so on.  Because &amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt; counts frames instead of wall-clock time, this allows you to use it as a frame-perfect timer, which is often more predictable than wall-clock time, particularly if the game begins dropping frames.&lt;br /&gt;
&lt;br /&gt;
By default, Sphere regulates the event loop such that 60 frames are processed every second (60 FPS).  Your game can change that by setting the value of &amp;lt;tt&amp;gt;[[API:Sphere.frameRate|Sphere.frameRate]]&amp;lt;/tt&amp;gt; to something other than 60.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This function has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
The number of complete frames processed since the game started running.  This value will roll over, like an odometer, after exactly 4,294,967,296 frames.  This is not a practical concern: running at 60 frames per second, your game would need to run continuously, ''for 2 years straight'', before the counter will roll over.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.frameRate|Sphere.frameRate]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10157</id>
		<title>API:Sphere.now</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10157"/>
				<updated>2017-11-02T16:32:51Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add Sphere.now() page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere.now()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;''' [[API:Functions|Core API]] function returns the number of frames processed since the engine started running.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''frames_elapsed'' = '''Sphere.now'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;''' returns the number of complete frames processed since the calling game started.  Therefore, on the very first frame this will return 0, on the next frame 1, and so on.  Specifically the return value is the number of full event loop turns, which by definition is the same as the number of updates performed.  This allows you to use &amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt; as a frame-perfect timer in cases where using wall-clock time (e.g. &amp;lt;tt&amp;gt;Date.now()&amp;lt;/tt&amp;gt;) is not desirable.&lt;br /&gt;
&lt;br /&gt;
By default, Sphere will regulate updates so that 60 frames will be processed every second (60 FPS).  Your game can change that by setting the value of &amp;lt;tt&amp;gt;[[API:Sphere.frameRate|Sphere.frameRate]]&amp;lt;/tt&amp;gt; to something other than 60.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This function has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
The number of complete frames processed since the game started running.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.frameRate|Sphere.frameRate]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10156</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10156"/>
				<updated>2017-11-02T16:05:36Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Sphere Game Platform */ Add APIs from mS 5 final&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Compiler|Sphere.Compiler]]&lt;br /&gt;
* [[API:Sphere.Engine|Sphere.Engine]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.frameRate|Sphere.frameRate]]&lt;br /&gt;
* [[API:Sphere.frameSkip|Sphere.frameSkip]]&lt;br /&gt;
* [[API:Sphere.fullScreen|Sphere.fullScreen]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.now|Sphere.now()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.setResolution|Sphere.setResolution()]]&lt;br /&gt;
* [[API:Sphere.shutDown|Sphere.shutDown()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.flipScreen|SSj.flipScreen()]]&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and import objects from the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;cell-runtime&amp;lt;/tt&amp;gt; module, as appropriate:&lt;br /&gt;
&lt;br /&gt;
==== In a Sphere game ====&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
==== In a Cellscript ====&lt;br /&gt;
&lt;br /&gt;
 import { assert, transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;image&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Image|new Image()]]&lt;br /&gt;
** [[API:Image::blitTo|Image::blitTo()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;logger&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Logger|new Logger()]]&lt;br /&gt;
** [[API:Logger::beginGroup|Logger::beginGroup()]]&lt;br /&gt;
** [[API:Logger::endGroup|Logger::endGroup()]]&lt;br /&gt;
** [[API:Logger::write|Logger::write()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;music&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Music.adjusting|Music.adjusting]]&lt;br /&gt;
* [[API:Music.adjustVolume|Music.adjustVolume()]]&lt;br /&gt;
* [[API:Music.override|Music.override()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
* [[API:Music.pop|Music.pop()]]&lt;br /&gt;
* [[API:Music.push|Music.push()]]&lt;br /&gt;
* [[API:Music.reset|Music.reset()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;prim&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Prim.blit|Prim.blit()]]&lt;br /&gt;
* [[API:Prim.blitSection|Prim.blitSection()]]&lt;br /&gt;
* [[API:Prim.drawCircle|Prim.drawCircle()]]&lt;br /&gt;
* [[API:Prim.drawEllipse|Prim.drawEllipse()]]&lt;br /&gt;
* [[API:Prim.drawLine|Prim.drawLine()]]&lt;br /&gt;
* [[API:Prim.drawPoint|Prim.drawPoint()]]&lt;br /&gt;
* [[API:Prim.drawRectangle|Prim.drawRectangle()]]&lt;br /&gt;
* [[API:Prim.drawSolidCircle|Prim.drawSolidCircle()]]&lt;br /&gt;
* [[API:Prim.drawSolidEllipse|Prim.drawSolidEllipse()]]&lt;br /&gt;
* [[API:Prim.drawSolidRectangle|Prim.drawSolidRectangle()]]&lt;br /&gt;
* [[API:Prim.fill|Prim.fill()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;random&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Random.chance|Random.chance()]]&lt;br /&gt;
* [[API:Random.discrete|Random.discrete()]]&lt;br /&gt;
* [[API:Random.normal|Random.normal()]]&lt;br /&gt;
* [[API:Random.sample|Random.sample()]]&lt;br /&gt;
* [[API:Random.string|Random.string()]]&lt;br /&gt;
* [[API:Random.uniform|Random.uniform()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;thread&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Thread.join|Thread.join()]]&lt;br /&gt;
* [[API:Thread.self|Thread.self()]]&lt;br /&gt;
* [[API:Thread|new Thread()]]&lt;br /&gt;
** [[API:Thread::running|Thread::running]]&lt;br /&gt;
** [[API:Thread::start|Thread::start()]]&lt;br /&gt;
** [[API:Thread::stop|Thread::stop()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Miscellaneous =&lt;br /&gt;
&lt;br /&gt;
* [[SphereFS]] - How the file system prefixes work.&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10150</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10150"/>
				<updated>2017-10-28T03:48:04Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* The debugger: SSJ */ Flesh out SSj description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSj ====&lt;br /&gt;
&lt;br /&gt;
SSj is a JavaScript debugger that allows you to debug your code in realtime.  You can use it to view variable values, see which functions are being called, and evaluate JavaScript code, all while the game is actively running.  When your game crashes or shows unwanted behavior somewhere, SSj gives you the tools to figure out where it's happening and why.  It's an invaluable time saver, and can even help you find bugs that would be impossible to track down otherwise!&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
// install the game's scripts and modules&lt;br /&gt;
install('@/scripts', files('src/*.mjs', true));&lt;br /&gt;
install('@/scripts', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
// now we determine which additional folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt; copies files from the source directory into the final distribution (what you're building with Cell and running with Sphere).&lt;br /&gt;
** You will have to put your source modules into a &amp;lt;tt&amp;gt;src/&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
** After compilation of your project, the installed scripts will end up in the &amp;lt;tt&amp;gt;dist/scripts&amp;lt;/tt&amp;gt; folder, unless you change the parameters of &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With additional &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt; directives, you define what files and folders get included into your distributed game, and under what name the folder will be known.  In this case, all files from &amp;lt;tt&amp;gt;srcdir/&amp;lt;/tt&amp;gt; will be recursively copied into &amp;lt;tt&amp;gt;dist/distdir&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
Every Sphere game must have a main module--let's call it for the sake of argument &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--which contains the game's startup code.  At its most basic, the typical main module looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        /* ready... set...G*MUNCH*    stupid pig */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
Encapsulating the startup code with a class rather than a simple function (as was done in Sphere 1.5) offers a few benefits.  Most notably, you can take advantage of subclassing.  Deriving from &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, for example, gives you built-in update and render hooks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
export default&lt;br /&gt;
class MyGame extends Thread&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // when subclassing, the constructor must call the superclass before&lt;br /&gt;
        // doing anything else.&lt;br /&gt;
        super();&lt;br /&gt;
&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    on_update()&lt;br /&gt;
    {&lt;br /&gt;
        /* code here will run once per frame */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    on_render()&lt;br /&gt;
    {&lt;br /&gt;
        /* code to perform rendering for each frame, may be skipped to&lt;br /&gt;
           prevent slowdown */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When subclassing &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method is required because it's already provided by the &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy &amp;lt;code&amp;gt;minisphere.exe&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ChakraCore.dll&amp;lt;/code&amp;gt;, and the entire &amp;lt;code&amp;gt;system&amp;lt;/code&amp;gt; folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click &amp;lt;code&amp;gt;minisphere.exe&amp;lt;/code&amp;gt; to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10149</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10149"/>
				<updated>2017-10-28T01:09:05Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Creating the project folder yourself */ Remove transpile(), reword stuff&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
// install the game's scripts and modules&lt;br /&gt;
install('@/scripts', files('src/*.mjs', true));&lt;br /&gt;
install('@/scripts', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
// now we determine which additional folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt; copies files from the source directory into the final distribution (what you're building with Cell and running with Sphere).&lt;br /&gt;
** You will have to put your source modules into a &amp;lt;tt&amp;gt;src/&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
** After compilation of your project, the installed scripts will end up in the &amp;lt;tt&amp;gt;dist/scripts&amp;lt;/tt&amp;gt; folder, unless you change the parameters of &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With additional &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt; directives, you define what files and folders get included into your distributed game, and under what name the folder will be known.  In this case, all files from &amp;lt;tt&amp;gt;srcdir/&amp;lt;/tt&amp;gt; will be recursively copied into &amp;lt;tt&amp;gt;dist/distdir&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
Every Sphere game must have a main module--let's call it for the sake of argument &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--which contains the game's startup code.  At its most basic, the typical main module looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        /* ready... set...G*MUNCH*    stupid pig */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
Encapsulating the startup code with a class rather than a simple function (as was done in Sphere 1.5) offers a few benefits.  Most notably, you can take advantage of subclassing.  Deriving from &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, for example, gives you built-in update and render hooks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
export default&lt;br /&gt;
class MyGame extends Thread&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // when subclassing, the constructor must call the superclass before&lt;br /&gt;
        // doing anything else.&lt;br /&gt;
        super();&lt;br /&gt;
&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    on_update()&lt;br /&gt;
    {&lt;br /&gt;
        /* code here will run once per frame */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    on_render()&lt;br /&gt;
    {&lt;br /&gt;
        /* code to perform rendering for each frame, may be skipped to&lt;br /&gt;
           prevent slowdown */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When subclassing &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method is required because it's already provided by the &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy &amp;lt;code&amp;gt;minisphere.exe&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ChakraCore.dll&amp;lt;/code&amp;gt;, and the entire &amp;lt;code&amp;gt;system&amp;lt;/code&amp;gt; folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click &amp;lt;code&amp;gt;minisphere.exe&amp;lt;/code&amp;gt; to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10148</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10148"/>
				<updated>2017-10-18T02:34:24Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* thread Module */ mS 5.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Platform|Sphere.Platform]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.frameRate|Sphere.frameRate]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.now|Sphere.now()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.exit|Sphere.shutDown()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.flipScreen|SSj.flipScreen()]]&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and import objects from the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;cell-runtime&amp;lt;/tt&amp;gt; module, as appropriate:&lt;br /&gt;
&lt;br /&gt;
==== In a Sphere game ====&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
==== In a Cellscript ====&lt;br /&gt;
&lt;br /&gt;
 import { assert, transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;image&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Image|new Image()]]&lt;br /&gt;
** [[API:Image::blitTo|Image::blitTo()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;logger&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Logger|new Logger()]]&lt;br /&gt;
** [[API:Logger::beginGroup|Logger::beginGroup()]]&lt;br /&gt;
** [[API:Logger::endGroup|Logger::endGroup()]]&lt;br /&gt;
** [[API:Logger::write|Logger::write()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;music&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Music.adjusting|Music.adjusting]]&lt;br /&gt;
* [[API:Music.adjustVolume|Music.adjustVolume()]]&lt;br /&gt;
* [[API:Music.override|Music.override()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
* [[API:Music.pop|Music.pop()]]&lt;br /&gt;
* [[API:Music.push|Music.push()]]&lt;br /&gt;
* [[API:Music.reset|Music.reset()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;prim&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Prim.blit|Prim.blit()]]&lt;br /&gt;
* [[API:Prim.blitSection|Prim.blitSection()]]&lt;br /&gt;
* [[API:Prim.drawCircle|Prim.drawCircle()]]&lt;br /&gt;
* [[API:Prim.drawEllipse|Prim.drawEllipse()]]&lt;br /&gt;
* [[API:Prim.drawLine|Prim.drawLine()]]&lt;br /&gt;
* [[API:Prim.drawPoint|Prim.drawPoint()]]&lt;br /&gt;
* [[API:Prim.drawRectangle|Prim.drawRectangle()]]&lt;br /&gt;
* [[API:Prim.drawSolidCircle|Prim.drawSolidCircle()]]&lt;br /&gt;
* [[API:Prim.drawSolidEllipse|Prim.drawSolidEllipse()]]&lt;br /&gt;
* [[API:Prim.drawSolidRectangle|Prim.drawSolidRectangle()]]&lt;br /&gt;
* [[API:Prim.fill|Prim.fill()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;random&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Random.chance|Random.chance()]]&lt;br /&gt;
* [[API:Random.discrete|Random.discrete()]]&lt;br /&gt;
* [[API:Random.normal|Random.normal()]]&lt;br /&gt;
* [[API:Random.sample|Random.sample()]]&lt;br /&gt;
* [[API:Random.string|Random.string()]]&lt;br /&gt;
* [[API:Random.uniform|Random.uniform()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;thread&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Thread.join|Thread.join()]]&lt;br /&gt;
* [[API:Thread.self|Thread.self()]]&lt;br /&gt;
* [[API:Thread|new Thread()]]&lt;br /&gt;
** [[API:Thread::running|Thread::running]]&lt;br /&gt;
** [[API:Thread::start|Thread::start()]]&lt;br /&gt;
** [[API:Thread::stop|Thread::stop()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ...and more to come! =&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10147</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10147"/>
				<updated>2017-10-17T13:30:29Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Sphere Game Platform */ Update for mS 5 API&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Platform|Sphere.Platform]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.frameRate|Sphere.frameRate]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.now|Sphere.now()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.exit|Sphere.shutDown()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.flipScreen|SSj.flipScreen()]]&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and import objects from the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;cell-runtime&amp;lt;/tt&amp;gt; module, as appropriate:&lt;br /&gt;
&lt;br /&gt;
==== In a Sphere game ====&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
==== In a Cellscript ====&lt;br /&gt;
&lt;br /&gt;
 import { assert, transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;image&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Image|new Image()]]&lt;br /&gt;
** [[API:Image::blitTo|Image::blitTo()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;logger&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Logger|new Logger()]]&lt;br /&gt;
** [[API:Logger::beginGroup|Logger::beginGroup()]]&lt;br /&gt;
** [[API:Logger::endGroup|Logger::endGroup()]]&lt;br /&gt;
** [[API:Logger::write|Logger::write()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;music&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Music.adjusting|Music.adjusting]]&lt;br /&gt;
* [[API:Music.adjustVolume|Music.adjustVolume()]]&lt;br /&gt;
* [[API:Music.override|Music.override()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
* [[API:Music.pop|Music.pop()]]&lt;br /&gt;
* [[API:Music.push|Music.push()]]&lt;br /&gt;
* [[API:Music.reset|Music.reset()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;prim&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Prim.blit|Prim.blit()]]&lt;br /&gt;
* [[API:Prim.blitSection|Prim.blitSection()]]&lt;br /&gt;
* [[API:Prim.drawCircle|Prim.drawCircle()]]&lt;br /&gt;
* [[API:Prim.drawEllipse|Prim.drawEllipse()]]&lt;br /&gt;
* [[API:Prim.drawLine|Prim.drawLine()]]&lt;br /&gt;
* [[API:Prim.drawPoint|Prim.drawPoint()]]&lt;br /&gt;
* [[API:Prim.drawRectangle|Prim.drawRectangle()]]&lt;br /&gt;
* [[API:Prim.drawSolidCircle|Prim.drawSolidCircle()]]&lt;br /&gt;
* [[API:Prim.drawSolidEllipse|Prim.drawSolidEllipse()]]&lt;br /&gt;
* [[API:Prim.drawSolidRectangle|Prim.drawSolidRectangle()]]&lt;br /&gt;
* [[API:Prim.fill|Prim.fill()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;random&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Random.chance|Random.chance()]]&lt;br /&gt;
* [[API:Random.discrete|Random.discrete()]]&lt;br /&gt;
* [[API:Random.normal|Random.normal()]]&lt;br /&gt;
* [[API:Random.sample|Random.sample()]]&lt;br /&gt;
* [[API:Random.string|Random.string()]]&lt;br /&gt;
* [[API:Random.uniform|Random.uniform()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;thread&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Thread.create|Thread.create()]]&lt;br /&gt;
* [[API:Thread.isRunning|Thread.isRunning()]]&lt;br /&gt;
* [[API:Thread.join|Thread.join()]]&lt;br /&gt;
* [[API:Thread.kill|Thread.kill()]]&lt;br /&gt;
* [[API:Thread.self|Thread.self()]]&lt;br /&gt;
* [[API:Thread|new Thread()]]&lt;br /&gt;
** [[API:Thread::running|Thread::running]]&lt;br /&gt;
** [[API:Thread::dispose|Thread::dispose()]]&lt;br /&gt;
** [[API:Thread::join|Thread::join()]]&lt;br /&gt;
** [[API:Thread::start|Thread::start()]]&lt;br /&gt;
** [[API:Thread::stop|Thread::stop()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ...and more to come! =&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10146</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10146"/>
				<updated>2017-10-17T13:28:19Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Debugging */ Add SSj.flipScreen()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Platform|Sphere.Platform]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.exit|Sphere.exit()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.run|Sphere.run()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.flipScreen|SSj.flipScreen()]]&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and import objects from the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;cell-runtime&amp;lt;/tt&amp;gt; module, as appropriate:&lt;br /&gt;
&lt;br /&gt;
==== In a Sphere game ====&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
==== In a Cellscript ====&lt;br /&gt;
&lt;br /&gt;
 import { assert, transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;image&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Image|new Image()]]&lt;br /&gt;
** [[API:Image::blitTo|Image::blitTo()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;logger&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Logger|new Logger()]]&lt;br /&gt;
** [[API:Logger::beginGroup|Logger::beginGroup()]]&lt;br /&gt;
** [[API:Logger::endGroup|Logger::endGroup()]]&lt;br /&gt;
** [[API:Logger::write|Logger::write()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;music&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Music.adjusting|Music.adjusting]]&lt;br /&gt;
* [[API:Music.adjustVolume|Music.adjustVolume()]]&lt;br /&gt;
* [[API:Music.override|Music.override()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
* [[API:Music.pop|Music.pop()]]&lt;br /&gt;
* [[API:Music.push|Music.push()]]&lt;br /&gt;
* [[API:Music.reset|Music.reset()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;prim&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Prim.blit|Prim.blit()]]&lt;br /&gt;
* [[API:Prim.blitSection|Prim.blitSection()]]&lt;br /&gt;
* [[API:Prim.drawCircle|Prim.drawCircle()]]&lt;br /&gt;
* [[API:Prim.drawEllipse|Prim.drawEllipse()]]&lt;br /&gt;
* [[API:Prim.drawLine|Prim.drawLine()]]&lt;br /&gt;
* [[API:Prim.drawPoint|Prim.drawPoint()]]&lt;br /&gt;
* [[API:Prim.drawRectangle|Prim.drawRectangle()]]&lt;br /&gt;
* [[API:Prim.drawSolidCircle|Prim.drawSolidCircle()]]&lt;br /&gt;
* [[API:Prim.drawSolidEllipse|Prim.drawSolidEllipse()]]&lt;br /&gt;
* [[API:Prim.drawSolidRectangle|Prim.drawSolidRectangle()]]&lt;br /&gt;
* [[API:Prim.fill|Prim.fill()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;random&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Random.chance|Random.chance()]]&lt;br /&gt;
* [[API:Random.discrete|Random.discrete()]]&lt;br /&gt;
* [[API:Random.normal|Random.normal()]]&lt;br /&gt;
* [[API:Random.sample|Random.sample()]]&lt;br /&gt;
* [[API:Random.string|Random.string()]]&lt;br /&gt;
* [[API:Random.uniform|Random.uniform()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;thread&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Thread.create|Thread.create()]]&lt;br /&gt;
* [[API:Thread.isRunning|Thread.isRunning()]]&lt;br /&gt;
* [[API:Thread.join|Thread.join()]]&lt;br /&gt;
* [[API:Thread.kill|Thread.kill()]]&lt;br /&gt;
* [[API:Thread.self|Thread.self()]]&lt;br /&gt;
* [[API:Thread|new Thread()]]&lt;br /&gt;
** [[API:Thread::running|Thread::running]]&lt;br /&gt;
** [[API:Thread::dispose|Thread::dispose()]]&lt;br /&gt;
** [[API:Thread::join|Thread::join()]]&lt;br /&gt;
** [[API:Thread::start|Thread::start()]]&lt;br /&gt;
** [[API:Thread::stop|Thread::stop()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ...and more to come! =&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10144</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10144"/>
				<updated>2017-10-15T17:38:20Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* As a stand-alone game */ Update for miniSphere 5&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
transpile('@/scripts/', files('src/*.mjs', true));&lt;br /&gt;
transpile('@/scripts/', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
//Now we determine which folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*.*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt; will compile the ES6 JavaScript modules that the Sphere 2 API uses into something that the Sphere engine knows how to use, since it has a more conventional JavaScript environment. (This is called transpilation.)&lt;br /&gt;
** You will have to put your script code into a src folder.&lt;br /&gt;
** After compilation of your project, the transpiled scripts will end up in the dist/scripts folder, unless you change the parameters of &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;, you define what files and folders get included into your distributed game, and under what name the folder will be known. In this case, all files from srcdir will be recursively copied into dist/distdir.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
Every Sphere game must have a main module--let's call it for the sake of argument &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--which contains the game's startup code.  At its most basic, the typical main module looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        /* ready... set...G*MUNCH*    stupid pig */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
Encapsulating the startup code with a class rather than a simple function (as was done in Sphere 1.5) offers a few benefits.  Most notably, you can take advantage of subclassing.  Deriving from &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, for example, gives you built-in update and render hooks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
export default&lt;br /&gt;
class MyGame extends Thread&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // when subclassing, the constructor must call the superclass before&lt;br /&gt;
        // doing anything else.&lt;br /&gt;
        super();&lt;br /&gt;
&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    on_update()&lt;br /&gt;
    {&lt;br /&gt;
        /* code here will run once per frame */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    on_render()&lt;br /&gt;
    {&lt;br /&gt;
        /* code to perform rendering for each frame, may be skipped to&lt;br /&gt;
           prevent slowdown */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When subclassing &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method is required because it's already provided by the &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy &amp;lt;code&amp;gt;minisphere.exe&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;ChakraCore.dll&amp;lt;/code&amp;gt;, and the entire &amp;lt;code&amp;gt;system&amp;lt;/code&amp;gt; folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click &amp;lt;code&amp;gt;minisphere.exe&amp;lt;/code&amp;gt; to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10143</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10143"/>
				<updated>2017-09-13T21:03:21Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Creating the project folder yourself */ Fix sample Cellscript&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
transpile('@/scripts/', files('src/*.mjs', true));&lt;br /&gt;
transpile('@/scripts/', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
//Now we determine which folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*.*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt; will compile the ES6 JavaScript modules that the Sphere 2 API uses into something that the Sphere engine knows how to use, since it has a more conventional JavaScript environment. (This is called transpilation.)&lt;br /&gt;
** You will have to put your script code into a src folder.&lt;br /&gt;
** After compilation of your project, the transpiled scripts will end up in the dist/scripts folder, unless you change the parameters of &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;, you define what files and folders get included into your distributed game, and under what name the folder will be known. In this case, all files from srcdir will be recursively copied into dist/distdir.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
Every Sphere game must have a main module--let's call it for the sake of argument &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--which contains the game's startup code.  At its most basic, the typical main module looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        /* ready... set...G*MUNCH*    stupid pig */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
Encapsulating the startup code with a class rather than a simple function (as was done in Sphere 1.5) offers a few benefits.  Most notably, you can take advantage of subclassing.  Deriving from &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, for example, gives you built-in update and render hooks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
export default&lt;br /&gt;
class MyGame extends Thread&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // when subclassing, the constructor must call the superclass before&lt;br /&gt;
        // doing anything else.&lt;br /&gt;
        super();&lt;br /&gt;
&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    on_update()&lt;br /&gt;
    {&lt;br /&gt;
        /* code here will run once per frame */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    on_render()&lt;br /&gt;
    {&lt;br /&gt;
        /* code to perform rendering for each frame, may be skipped to&lt;br /&gt;
           prevent slowdown */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When subclassing &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method is required because it's already provided by the &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy minisphere.exe and its system folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
* Rename the dist folder to 'startup'.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click minisphere.exe to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream::rewind&amp;diff=10142</id>
		<title>API:DirectoryStream::rewind</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream::rewind&amp;diff=10142"/>
				<updated>2017-08-23T14:15:50Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add DirectoryStream::rewind() to wiki&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:DirectoryStream::rewind()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;DirectoryStream::rewind()&amp;lt;/tt&amp;gt;''' [[API:Functions#Core_API|Core API]] method resets a directory stream to the beginning to be read again.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dirstream_obj''.'''rewind'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''DirectoryStream::rewind()'''&amp;lt;/tt&amp;gt; refreshes a directory stream and resets its &amp;lt;tt&amp;gt;[[API:DirectoryStream::position|DirectoryStream::position]]&amp;lt;/tt&amp;gt; to 0.  This allows you to read new or deleted items in a directory without having to construct a new &amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; object.  Note that this is '''not''' the same as manually setting &amp;lt;tt&amp;gt;[[API:DirectoryStream::position|DirectoryStream::position]]&amp;lt;/tt&amp;gt; to 0 as that isn't guaranteed to reflect changes.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This method has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
This method doesn't return a meaningful value.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:FS.fullPath&amp;diff=10141</id>
		<title>API:FS.fullPath</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:FS.fullPath&amp;diff=10141"/>
				<updated>2017-08-21T03:22:44Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:FS.fullPath()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;FS.fullPath()&amp;lt;/tt&amp;gt;''' [[API:Functions|Core API]] function computes the canonical [[SphereFS]] pathname for a specified relative path and base directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''canon_path'' = '''FS.fullPath'''(''file_or_dir_name''[, ''base_path'']);&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;FS.fullPath()&amp;lt;/tt&amp;gt;''' returns the complete, canonical SphereFS pathname for a given file or directory.  If the path to be resolved already includes a SphereFS prefix such as &amp;lt;tt&amp;gt;@/&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;~/&amp;lt;/tt&amp;gt;, then Sphere simply canonicalizes it (by removing any relative components); otherwise the path itself is considered relative and will be rebased before canonicalization.  This allows you to get the full pathname of a file or directory given only its name and a known base directory, which can be useful in libraries.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Default Value&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;file_or_dir_name&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|''n/a (Required)''&lt;br /&gt;
|The name of a file or directory.  May include path components.  It doesn't need to actually exist.&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;base_path&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|&amp;lt;tt&amp;gt;&amp;quot;@/&amp;quot;&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Specifies the base directory onto which relative paths will be rebased.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
The full SphereFS pathname of the specified file or directory.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:FS.relativePath&amp;diff=10140</id>
		<title>API:FS.relativePath</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:FS.relativePath&amp;diff=10140"/>
				<updated>2017-08-18T18:37:49Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:FS.relativePath()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;FS.relativePath()&amp;lt;/tt&amp;gt;''' [[API:Functions|Core API]] function computes an abbreviated path for a specified file or directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''rel_path'' = '''FS.relativePath'''(''file_or_dir_name''[, ''base_dir_name'']);&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;FS.relativePath()&amp;lt;/tt&amp;gt;''' takes a file or directory name and returns an abbreviated version relative to a specified base directory.  This is useful when logging or displaying filenames where the full path might be too verbose.&lt;br /&gt;
&lt;br /&gt;
If the [[SphereFS]] prefixes of the (canonicalized) input path and base directory differ, then the full pathname is returned without attempting to abbreviate it.  This ensures that one can always recover the original path by doing:&lt;br /&gt;
&lt;br /&gt;
 rel_path = FS.relativePath(path, base_dir);&lt;br /&gt;
 /* ... */&lt;br /&gt;
 path = FS.fullPath(rel_path, base_dir);&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Default&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;file_or_dir_name&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|&lt;br /&gt;
|The name of a file or directory, resolved per SphereFS rules (relative to &amp;lt;tt&amp;gt;@/&amp;lt;/tt&amp;gt;).  It doesn't need to actually exist.&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;base_dir_name&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|&lt;br /&gt;
|Specifies the base directory for the relative path.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
An abbreviated version of &amp;lt;tt&amp;gt;''file_or_dir_name''&amp;lt;/tt&amp;gt; relative to the specified base directory.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:FS.relativePath&amp;diff=10139</id>
		<title>API:FS.relativePath</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:FS.relativePath&amp;diff=10139"/>
				<updated>2017-08-18T18:32:23Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add FS.relativePath() page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:FS.relativePath()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;FS.relativePath()&amp;lt;/tt&amp;gt;''' function computes an abbreviated path for a specified file or directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''rel_path'' = '''FS.relativePath'''(''file_or_dir_name''[, ''base_dir_name'']);&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;FS.relativePath()&amp;lt;/tt&amp;gt;''' takes a file or directory name and returns an abbreviated version relative to a specified base directory.  This is useful when logging or displaying filenames where the full path might be too verbose.&lt;br /&gt;
&lt;br /&gt;
If the [[SphereFS]] prefixes of the (canonicalized) input path and base directory differ, then the full pathname is returned without attempting to abbreviate it.  This ensures that one can always recover the original path by doing:&lt;br /&gt;
&lt;br /&gt;
 rel_path = FS.relativePath(path, base_dir);&lt;br /&gt;
 /* ... */&lt;br /&gt;
 path = FS.fullPath(rel_path, base_dir);&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Default&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;file_or_dir_name&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|&lt;br /&gt;
|The name of a file or directory, resolved per SphereFS rules (relative to &amp;lt;tt&amp;gt;@/&amp;lt;/tt&amp;gt;).  It doesn't need to actually exist.&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;base_dir_name&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|&lt;br /&gt;
|Specifies the base directory for the relative path.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
An abbreviated version of &amp;lt;tt&amp;gt;''file_or_dir_name''&amp;lt;/tt&amp;gt; relative to the specified base directory.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10138</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10138"/>
				<updated>2017-08-18T02:59:30Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Sphere Runtime */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Platform|Sphere.Platform]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.exit|Sphere.exit()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.run|Sphere.run()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and import objects from the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;cell-runtime&amp;lt;/tt&amp;gt; module, as appropriate:&lt;br /&gt;
&lt;br /&gt;
==== In a Sphere game ====&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
==== In a Cellscript ====&lt;br /&gt;
&lt;br /&gt;
 import { assert, transpile } from 'cell-runtime';&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;image&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Image|new Image()]]&lt;br /&gt;
** [[API:Image::blitTo|Image::blitTo()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;logger&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Logger|new Logger()]]&lt;br /&gt;
** [[API:Logger::beginGroup|Logger::beginGroup()]]&lt;br /&gt;
** [[API:Logger::endGroup|Logger::endGroup()]]&lt;br /&gt;
** [[API:Logger::write|Logger::write()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;music&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Music.adjusting|Music.adjusting]]&lt;br /&gt;
* [[API:Music.adjustVolume|Music.adjustVolume()]]&lt;br /&gt;
* [[API:Music.override|Music.override()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
* [[API:Music.pop|Music.pop()]]&lt;br /&gt;
* [[API:Music.push|Music.push()]]&lt;br /&gt;
* [[API:Music.reset|Music.reset()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;prim&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Prim.blit|Prim.blit()]]&lt;br /&gt;
* [[API:Prim.blitSection|Prim.blitSection()]]&lt;br /&gt;
* [[API:Prim.drawCircle|Prim.drawCircle()]]&lt;br /&gt;
* [[API:Prim.drawEllipse|Prim.drawEllipse()]]&lt;br /&gt;
* [[API:Prim.drawLine|Prim.drawLine()]]&lt;br /&gt;
* [[API:Prim.drawPoint|Prim.drawPoint()]]&lt;br /&gt;
* [[API:Prim.drawRectangle|Prim.drawRectangle()]]&lt;br /&gt;
* [[API:Prim.drawSolidCircle|Prim.drawSolidCircle()]]&lt;br /&gt;
* [[API:Prim.drawSolidEllipse|Prim.drawSolidEllipse()]]&lt;br /&gt;
* [[API:Prim.drawSolidRectangle|Prim.drawSolidRectangle()]]&lt;br /&gt;
* [[API:Prim.fill|Prim.fill()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;random&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Random.chance|Random.chance()]]&lt;br /&gt;
* [[API:Random.discrete|Random.discrete()]]&lt;br /&gt;
* [[API:Random.normal|Random.normal()]]&lt;br /&gt;
* [[API:Random.sample|Random.sample()]]&lt;br /&gt;
* [[API:Random.string|Random.string()]]&lt;br /&gt;
* [[API:Random.uniform|Random.uniform()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;thread&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Thread.create|Thread.create()]]&lt;br /&gt;
* [[API:Thread.isRunning|Thread.isRunning()]]&lt;br /&gt;
* [[API:Thread.join|Thread.join()]]&lt;br /&gt;
* [[API:Thread.kill|Thread.kill()]]&lt;br /&gt;
* [[API:Thread.self|Thread.self()]]&lt;br /&gt;
* [[API:Thread|new Thread()]]&lt;br /&gt;
** [[API:Thread::running|Thread::running]]&lt;br /&gt;
** [[API:Thread::dispose|Thread::dispose()]]&lt;br /&gt;
** [[API:Thread::join|Thread::join()]]&lt;br /&gt;
** [[API:Thread::start|Thread::start()]]&lt;br /&gt;
** [[API:Thread::stop|Thread::stop()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ...and more to come! =&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10137</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10137"/>
				<updated>2017-08-18T02:53:10Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Sphere Runtime */ Add more modules to list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Platform|Sphere.Platform]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.exit|Sphere.exit()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.run|Sphere.run()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and specify the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; module, like so:&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';  // in a Sphere game&lt;br /&gt;
 import { transpile } from 'cell-runtime';              // in a Cellscript&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;image&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Image|new Image()]]&lt;br /&gt;
** [[API:Image::blitTo|Image::blitTo()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;logger&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Logger|new Logger()]]&lt;br /&gt;
** [[API:Logger::beginGroup|Logger::beginGroup()]]&lt;br /&gt;
** [[API:Logger::endGroup|Logger::endGroup()]]&lt;br /&gt;
** [[API:Logger::write|Logger::write()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;music&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Music.adjusting|Music.adjusting]]&lt;br /&gt;
* [[API:Music.adjustVolume|Music.adjustVolume()]]&lt;br /&gt;
* [[API:Music.override|Music.override()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
* [[API:Music.pop|Music.pop()]]&lt;br /&gt;
* [[API:Music.push|Music.push()]]&lt;br /&gt;
* [[API:Music.reset|Music.reset()]]&lt;br /&gt;
* [[API:Music.play|Music.play()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;prim&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Prim.blit|Prim.blit()]]&lt;br /&gt;
* [[API:Prim.blitSection|Prim.blitSection()]]&lt;br /&gt;
* [[API:Prim.drawCircle|Prim.drawCircle()]]&lt;br /&gt;
* [[API:Prim.drawEllipse|Prim.drawEllipse()]]&lt;br /&gt;
* [[API:Prim.drawLine|Prim.drawLine()]]&lt;br /&gt;
* [[API:Prim.drawPoint|Prim.drawPoint()]]&lt;br /&gt;
* [[API:Prim.drawRectangle|Prim.drawRectangle()]]&lt;br /&gt;
* [[API:Prim.drawSolidCircle|Prim.drawSolidCircle()]]&lt;br /&gt;
* [[API:Prim.drawSolidEllipse|Prim.drawSolidEllipse()]]&lt;br /&gt;
* [[API:Prim.drawSolidRectangle|Prim.drawSolidRectangle()]]&lt;br /&gt;
* [[API:Prim.fill|Prim.fill()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;random&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Random.chance|Random.chance()]]&lt;br /&gt;
* [[API:Random.discrete|Random.discrete()]]&lt;br /&gt;
* [[API:Random.normal|Random.normal()]]&lt;br /&gt;
* [[API:Random.sample|Random.sample()]]&lt;br /&gt;
* [[API:Random.string|Random.string()]]&lt;br /&gt;
* [[API:Random.uniform|Random.uniform()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;thread&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Thread.create|Thread.create()]]&lt;br /&gt;
* [[API:Thread.isRunning|Thread.isRunning()]]&lt;br /&gt;
* [[API:Thread.join|Thread.join()]]&lt;br /&gt;
* [[API:Thread.kill|Thread.kill()]]&lt;br /&gt;
* [[API:Thread.self|Thread.self()]]&lt;br /&gt;
* [[API:Thread|new Thread()]]&lt;br /&gt;
** [[API:Thread::running|Thread::running]]&lt;br /&gt;
** [[API:Thread::dispose|Thread::dispose()]]&lt;br /&gt;
** [[API:Thread::join|Thread::join()]]&lt;br /&gt;
** [[API:Thread::start|Thread::start()]]&lt;br /&gt;
** [[API:Thread::stop|Thread::stop()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ...and more to come! =&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10136</id>
		<title>API:Functions</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Functions&amp;diff=10136"/>
				<updated>2017-08-17T19:24:20Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Start cataloguing Sphere v2 functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:Sphere v2 API}}&lt;br /&gt;
&lt;br /&gt;
The '''Sphere API''' is the collective name for the set of bindings (functions, objects, and methods) available for use by all Sphere games.  The API provides access to a host of convenient features, allowing you to get up and running quickly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
{{section|sph-section-green|Making new function/object pages|Simple steps:&lt;br /&gt;
#Before getting started, please check the [[Article standards and practices]].&lt;br /&gt;
#Click a red link.&lt;br /&gt;
#Place the following code in the empty edit box:&lt;br /&gt;
##For a new function: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:functemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
##For a new object: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;{{subst:objecttemp|preamble=REPLACEME|function=REPLACEME|object=REPLACEME|returns=REPLACEME|params=REPLACEME}}&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
#Check the minor edit flag and save.&lt;br /&gt;
#Click 'edit' at the top of the page to add content.&lt;br /&gt;
#Try to be [http://en.wiktionary.org/wiki/objective objective] when writing, and save when you're done.&lt;br /&gt;
#Remove description from this page, add page link to list at the top of the matching section.&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Core API ==&lt;br /&gt;
&lt;br /&gt;
The '''Core API''' provides low-level access to the engine's features and includes all bindings provided directly by the engine.  These bindings are exposed to the global scope and can be used without importing any extra modules.&lt;br /&gt;
&lt;br /&gt;
=== Sphere Game Platform ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.APILevel|Sphere.APILevel]]&lt;br /&gt;
* [[API:Sphere.Game|Sphere.Game]]&lt;br /&gt;
* [[API:Sphere.Platform|Sphere.Platform]]&lt;br /&gt;
* [[API:Sphere.Version|Sphere.Version]]&lt;br /&gt;
* [[API:Sphere.abort|Sphere.abort()]]&lt;br /&gt;
* [[API:Sphere.exit|Sphere.exit()]]&lt;br /&gt;
* [[API:Sphere.restart|Sphere.restart()]]&lt;br /&gt;
* [[API:Sphere.run|Sphere.run()]]&lt;br /&gt;
* [[API:Sphere.sleep|Sphere.sleep()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:SSj.log|SSj.log()]]&lt;br /&gt;
* [[API:SSj.trace|SSj.trace()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Files and Directories ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
** [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
** [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
** [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
** [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
** [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
** [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
** [[API:FileStream::fileName|FileStream::fileName]]&lt;br /&gt;
** [[API:FileStream::fileSize|FileStream::fileSize]]&lt;br /&gt;
** [[API:FileStream::position|FileStream::position]]&lt;br /&gt;
** [[API:FileStream::dispose|FileStream::dispose()]]&lt;br /&gt;
** [[API:FileStream::read|FileStream::read()]]&lt;br /&gt;
** [[API:FileStream::write|FileStream::write()]]&lt;br /&gt;
* [[API:FS.createDirectory|FS.createDirectory()]]&lt;br /&gt;
* [[API:FS.deleteFile|FS.deleteFile()]]&lt;br /&gt;
* [[API:FS.directoryExists|FS.directoryExists()]]&lt;br /&gt;
* [[API:FS.fileExists|FS.fileExists()]]&lt;br /&gt;
* [[API:FS.fullPath|FS.fullPath()]]&lt;br /&gt;
* [[API:FS.readFile|FS.readFile()]]&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
* [[API:FS.removeDirectory|FS.removeDirectory()]]&lt;br /&gt;
* [[API:FS.rename|FS.rename()]]&lt;br /&gt;
* [[API:FS.writeFile|FS.writeFile()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Random Number Generation ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
* [[API:RNG|new RNG()]]&lt;br /&gt;
** [[API:RNG::state|RNG::state]]&lt;br /&gt;
** [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sphere Runtime ==&lt;br /&gt;
&lt;br /&gt;
The '''Sphere Runtime''' is a standard collection of JavaScript modules included with the engine.  Some modules can even be used in Cellscripts as well!  Unlike the Core API above which was organized by category, the following list is organized by module.  Most modules export only a single object or function; to import more than one at a time, you can use an ES2015 &amp;lt;tt&amp;gt;import&amp;lt;/tt&amp;gt; statement and specify the &amp;lt;tt&amp;gt;sphere-runtime&amp;lt;/tt&amp;gt; module, like so:&lt;br /&gt;
&lt;br /&gt;
 import { from, Music, Thread } from 'sphere-runtime';  // in a Sphere game&lt;br /&gt;
 import { transpile } from 'cell-runtime';              // in a Cellscript&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;from&amp;lt;/tt&amp;gt; Module ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
** [[API:from::all|from::all()]]&lt;br /&gt;
** [[API:from::allIn|from::allIn()]]&lt;br /&gt;
** [[API:from::any|from::any()]]&lt;br /&gt;
** [[API:from::anyIn|from::anyIn()]]&lt;br /&gt;
** [[API:from::anyIs|from::anyIs()]]&lt;br /&gt;
** [[API:from::ascending|from::ascending()]]&lt;br /&gt;
** [[API:from::besides|from::besides()]]&lt;br /&gt;
** [[API:from::count|from::count()]]&lt;br /&gt;
** [[API:from::descending|from::descending()]]&lt;br /&gt;
** [[API:from::each|from::each()]]&lt;br /&gt;
** [[API:from::first|from::first()]]&lt;br /&gt;
** [[API:from::from|from::from()]]&lt;br /&gt;
** [[API:from::including|from::including()]]&lt;br /&gt;
** [[API:from::last|from::last()]]&lt;br /&gt;
** [[API:from::random|from::random()]]&lt;br /&gt;
** [[API:from::reduce|from::reduce()]]&lt;br /&gt;
** [[API:from::remove|from::remove()]]&lt;br /&gt;
** [[API:from::sample|from::sample()]]&lt;br /&gt;
** [[API:from::select|from::select()]]&lt;br /&gt;
** [[API:from::shuffle|from::shuffle()]]&lt;br /&gt;
** [[API:from::skip|from::skip()]]&lt;br /&gt;
** [[API:from::take|from::take()]]&lt;br /&gt;
** [[API:from::toArray|from::toArray()]]&lt;br /&gt;
** [[API:from::update|from::update()]]&lt;br /&gt;
** [[API:from::where|from::where()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= ...and more to come! =&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=SphereFS&amp;diff=10135</id>
		<title>SphereFS</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=SphereFS&amp;diff=10135"/>
				<updated>2017-08-17T18:10:47Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add WIP SphereFS page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''SphereFS''' is a standardized system used by Sphere for unambiguously specifying pathnames of files and directories within the sandboxed JavaScript environment.&lt;br /&gt;
&lt;br /&gt;
A canonical SphereFS pathname consists of a prefix, for example &amp;lt;tt&amp;gt;@/&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;~/&amp;lt;/tt&amp;gt;, followed by one or more directory components separated by slashes, and finally an optional filename.  Each prefix is either a unique root in itself or else an alias for a directory within one of those roots.  Prefixes other than &amp;lt;tt&amp;gt;~/&amp;lt;/tt&amp;gt; are write-protected, and it is not possible to reference files outside the sandbox.  OS paths such as '''C:\file.txt''' or '''/usr/bin/eatypig''' are not legal within the SphereFS sandbox, nor are relative paths that extend uplevel from a prefix, e.g. '''@/../../maggie.fat'''.  Passing such a path to a Sphere API function expecting a file or directory name will cause an exception.&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
TODO: write this section&lt;br /&gt;
&lt;br /&gt;
== Prefixes ==&lt;br /&gt;
&lt;br /&gt;
TODO: write this section&lt;br /&gt;
&lt;br /&gt;
== Path Resolution ==&lt;br /&gt;
&lt;br /&gt;
TODO: write this section too&lt;br /&gt;
&lt;br /&gt;
== Save ID ==&lt;br /&gt;
&lt;br /&gt;
In order for a game to use the &amp;lt;tt&amp;gt;~/&amp;lt;/tt&amp;gt; prefix, it must include a '''save ID ''' in its JSON manifest.  The save ID should be unique for each game or series and typically takes the form &amp;lt;tt&amp;gt;''authorName''.''gameName''&amp;lt;/tt&amp;gt;, where both parts are written in camelCase.  For example, ''Spectacles: Bruce's Story'''s save ID is &amp;lt;tt&amp;gt;fatCerberus.spectacles&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* [[THE PIG]]: It eats you in 2 seconds&lt;br /&gt;
* [[THE COW]]: It eats a bunch of cats&lt;br /&gt;
* [[THE APE]]: It's the size of the universe.  Bye bye cow and pig!&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:FS.fullPath&amp;diff=10134</id>
		<title>API:FS.fullPath</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:FS.fullPath&amp;diff=10134"/>
				<updated>2017-08-17T17:34:35Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: FS.fullPath() API page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:FS.fullPath()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;FS.fullPath()&amp;lt;/tt&amp;gt;''' function computes the canonical [[SphereFS]] pathname for a specified relative path and base directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''canon_path'' = '''FS.fullPath'''(''file_or_dir_name''[, ''base_path'']);&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;FS.fullPath()&amp;lt;/tt&amp;gt;''' returns the complete, canonical SphereFS pathname for a given file or directory.  If the path to be resolved already includes a SphereFS prefix such as &amp;lt;tt&amp;gt;@/&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;~/&amp;lt;/tt&amp;gt;, then Sphere simply canonicalizes it (by removing any relative components); otherwise the path itself is considered relative and will be rebased before canonicalization.  This allows you to get the full pathname of a file or directory given only its name and a known base directory, which can be useful in libraries.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Name&lt;br /&gt;
!Type&lt;br /&gt;
!Default Value&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;file_or_dir_name&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|''n/a (Required)''&lt;br /&gt;
|The name of a file or directory.  May include path components.  It doesn't need to actually exist.&lt;br /&gt;
|-&lt;br /&gt;
|''&amp;lt;tt&amp;gt;base_path&amp;lt;/tt&amp;gt;''&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|&amp;lt;tt&amp;gt;&amp;quot;@/&amp;quot;&amp;lt;/tt&amp;gt;&lt;br /&gt;
|Specifies the base directory onto which relative paths will be rebased.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
The full SphereFS pathname of the specified file or directory.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:FS.relativePath|FS.relativePath()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream::next&amp;diff=10133</id>
		<title>API:DirectoryStream::next</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream::next&amp;diff=10133"/>
				<updated>2017-08-17T16:32:33Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Note that return value is iterator-like&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:DirectoryStream::next()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;DirectoryStream::next()&amp;lt;/tt&amp;gt;''' method reads the next directory entry from a directory stream.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dir_entry'' = ''dirstream_obj''.'''next'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''DirectoryStream::next()'''&amp;lt;/tt&amp;gt; reads the next directory entry from the stream and advances the stream position.  The value of &amp;lt;tt&amp;gt;[[API:DirectoryStream::position|DirectoryStream::position]]&amp;lt;/tt&amp;gt; determines which entry is read.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This method has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
An object with two properties, &amp;lt;tt&amp;gt;.done&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.value&amp;lt;/tt&amp;gt;, with semantics compatible with the ES2015 iterator protocol.  If there are no more entries to retrieve, &amp;lt;tt&amp;gt;.done&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.value&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;undefined&amp;lt;/tt&amp;gt;.  Otherwise, &amp;lt;tt&amp;gt;.done&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.value&amp;lt;/tt&amp;gt; is an object describing the directory entry:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Property&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;.fileName&amp;lt;/tt&amp;gt;&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|The name of the file or directory, e.g. &amp;lt;tt&amp;gt;pig.js&amp;lt;/tt&amp;gt;.  If the entry is a directory, &amp;lt;tt&amp;gt;.fileName&amp;lt;/tt&amp;gt; will end in a slash (&amp;lt;tt&amp;gt;/&amp;lt;/tt&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;.fullPath&amp;lt;/tt&amp;gt;&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|The full SphereFS pathname of the file or directory, e.g. &amp;lt;tt&amp;gt;@/scripts/pig.js&amp;lt;/tt&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;.isDirectory&amp;lt;/tt&amp;gt;&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''boolean''&lt;br /&gt;
|&amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if the entry is a directory, otherwise &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
* [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream::next&amp;diff=10132</id>
		<title>API:DirectoryStream::next</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream::next&amp;diff=10132"/>
				<updated>2017-08-15T18:31:45Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add page for DirectoryStream::next()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:DirectoryStream::next()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;DirectoryStream::next()&amp;lt;/tt&amp;gt;''' method reads the next directory entry from a directory stream.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dir_entry'' = ''dirstream_obj''.'''next'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''DirectoryStream::next()'''&amp;lt;/tt&amp;gt; reads the next directory entry from the stream and advances the stream position.  The value of &amp;lt;tt&amp;gt;[[API:DirectoryStream::position|DirectoryStream::position]]&amp;lt;/tt&amp;gt; determines which entry is read.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This method has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
An object with two properties, &amp;lt;tt&amp;gt;.done&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.value&amp;lt;/tt&amp;gt;.  If there are no more entries to retrieve, &amp;lt;tt&amp;gt;.done&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.value&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;undefined&amp;lt;/tt&amp;gt;.  Otherwise, &amp;lt;tt&amp;gt;.done&amp;lt;/tt&amp;gt; is &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;.value&amp;lt;/tt&amp;gt; is an object describing the directory entry:&lt;br /&gt;
&lt;br /&gt;
:{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Property&lt;br /&gt;
!Type&lt;br /&gt;
!Description&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;.fileName&amp;lt;/tt&amp;gt;&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|The name of the file or directory, e.g. &amp;lt;tt&amp;gt;pig.js&amp;lt;/tt&amp;gt;.  If the entry is a directory, &amp;lt;tt&amp;gt;.fileName&amp;lt;/tt&amp;gt; will end in a slash (&amp;lt;tt&amp;gt;/&amp;lt;/tt&amp;gt;).&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;.fullPath&amp;lt;/tt&amp;gt;&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''string''&lt;br /&gt;
|The full SphereFS pathname of the file or directory, e.g. &amp;lt;tt&amp;gt;@/scripts/pig.js&amp;lt;/tt&amp;gt;.&lt;br /&gt;
|-&lt;br /&gt;
|&amp;lt;tt&amp;gt;.isDirectory&amp;lt;/tt&amp;gt;&lt;br /&gt;
|style=&amp;quot;text-align: center;&amp;quot;|''boolean''&lt;br /&gt;
|&amp;lt;tt&amp;gt;true&amp;lt;/tt&amp;gt; if the entry is a directory, otherwise &amp;lt;tt&amp;gt;false&amp;lt;/tt&amp;gt;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream|new DirectoryStream()]]&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
* [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10131</id>
		<title>API:DirectoryStream</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10131"/>
				<updated>2017-08-14T03:26:34Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add DirectoryStream::dispose()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:new DirectoryStream()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;new DirectoryStream()&amp;lt;/tt&amp;gt;''' constructor initializes an object that allows you to enumerate the contents of a directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dirstream_obj'' = '''new DirectoryStream'''(''dir_name'');&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''new DirectoryStream()'''&amp;lt;/tt&amp;gt; constructs a Directory Stream object, which allows you to enumerate the contents of a directory.  Directory streams only provide filenames; you must use a &amp;lt;tt&amp;gt;[[API:FileStream|FileStream]]&amp;lt;/tt&amp;gt; to access the contents of a file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;''Note:''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;The &amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; class implements the JavaScript ''iterator protocol'', which means you can use them in &amp;lt;tt&amp;gt;[[API:from|from()]]&amp;lt;/tt&amp;gt; queries and &amp;lt;tt&amp;gt;for-of&amp;lt;/tt&amp;gt; loops.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=right width=100&amp;gt;'''''dir_name'''''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Path to the directory to be enumerated.  Relative to the game manifest unless a SphereFS prefix is included.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
A newly constructed &amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; object pointing at &amp;lt;tt&amp;gt;''dir_name''&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Class Information ==&lt;br /&gt;
&lt;br /&gt;
=== Properties ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
* [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::dispose|DirectoryStream::dispose()]]&lt;br /&gt;
* [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
* [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10130</id>
		<title>API:DirectoryStream</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10130"/>
				<updated>2017-08-12T14:34:02Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: More organization - split function and class info&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:new DirectoryStream()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;new DirectoryStream()&amp;lt;/tt&amp;gt;''' constructor initializes an object that allows you to enumerate the contents of a directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dirstream_obj'' = '''new DirectoryStream'''(''dir_name'');&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''new DirectoryStream()'''&amp;lt;/tt&amp;gt; constructs a Directory Stream object, which allows you to enumerate the contents of a directory.  Directory streams only provide filenames; you must use a &amp;lt;tt&amp;gt;[[API:FileStream|FileStream]]&amp;lt;/tt&amp;gt; to access the contents of a file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;''Note:''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;The &amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; class implements the JavaScript ''iterator protocol'', which means you can use them in &amp;lt;tt&amp;gt;[[API:from|from()]]&amp;lt;/tt&amp;gt; queries and &amp;lt;tt&amp;gt;for-of&amp;lt;/tt&amp;gt; loops.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=right width=100&amp;gt;'''''dir_name'''''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Path to the directory to be enumerated.  Relative to the game manifest unless a SphereFS prefix is included.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
A newly constructed &amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; object pointing at &amp;lt;tt&amp;gt;''dir_name''&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Class Information ==&lt;br /&gt;
&lt;br /&gt;
=== Properties ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
* [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
* [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10129</id>
		<title>API:DirectoryStream</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10129"/>
				<updated>2017-08-12T04:31:07Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add See Also section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:new DirectoryStream()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;new DirectoryStream()&amp;lt;/tt&amp;gt;''' constructor initializes an object that allows you to enumerate the contents of a directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dirstream_obj'' = '''new DirectoryStream'''(''dir_name'');&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''new DirectoryStream()'''&amp;lt;/tt&amp;gt; constructs a Directory Stream object, which allows you to enumerate the contents of a directory.  Directory streams only provide filenames; you must use a &amp;lt;tt&amp;gt;[[API:FileStream|FileStream]]&amp;lt;/tt&amp;gt; to access the contents of a file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;''Note:''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; objects are compatible with the JavaScript ''iterator protocol'', so you can use them in a &amp;lt;tt&amp;gt;[[API:from|from()]]&amp;lt;/tt&amp;gt; query.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=right width=100&amp;gt;'''''dir_name'''''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Path to the directory to be enumerated.  Relative to the game manifest unless a SphereFS prefix is included.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Properties ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
* [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
* [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:from|from()]]&lt;br /&gt;
* [[API:FileStream|new FileStream()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10128</id>
		<title>API:DirectoryStream</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:DirectoryStream&amp;diff=10128"/>
				<updated>2017-08-12T04:27:53Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Create DirectoryStream constructor page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:new DirectoryStream()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;new DirectoryStream()&amp;lt;/tt&amp;gt;''' constructor initializes an object that allows you to enumerate the contents of a directory.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''dirstream_obj'' = '''new DirectoryStream'''(''dir_name'');&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''new DirectoryStream()'''&amp;lt;/tt&amp;gt; constructs a Directory Stream object, which allows you to enumerate the contents of a directory.  Directory streams only provide filenames; you must use a &amp;lt;tt&amp;gt;[[API:FileStream|FileStream]]&amp;lt;/tt&amp;gt; to access the contents of a file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;''Note:''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;tt&amp;gt;DirectoryStream&amp;lt;/tt&amp;gt; objects are compatible with the JavaScript ''iterator protocol'', so you can use them in a &amp;lt;tt&amp;gt;[[API:from|from()]]&amp;lt;/tt&amp;gt; query.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td align=right width=100&amp;gt;'''''dir_name'''''&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;Path to the directory to be enumerated.  Relative to the game manifest unless a SphereFS prefix is included.&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Properties ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::fileCount|DirectoryStream::fileCount]]&lt;br /&gt;
* [[API:DirectoryStream::fileName|DirectoryStream::fileName]]&lt;br /&gt;
* [[API:DirectoryStream::position|DirectoryStream::position]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:DirectoryStream::next|DirectoryStream::next()]]&lt;br /&gt;
* [[API:DirectoryStream::rewind|DirectoryStream::rewind()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10127</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10127"/>
				<updated>2017-08-12T04:08:56Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Add some subheadings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:new RNG()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;RNG()&amp;lt;/tt&amp;gt; constructor''' initializes a new instance of the pseudorandom number generator, seeded using the current time and date.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''rng_object'' = '''new RNG'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''new RNG()'''&amp;lt;/tt&amp;gt; initializes a new instance of the built-in pseudorandom number generator, seeded based on the current time and date.  Unlike &amp;lt;tt&amp;gt;Math.random()&amp;lt;/tt&amp;gt; which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers.&lt;br /&gt;
&lt;br /&gt;
To control the initial state of the generator, use &amp;lt;tt&amp;gt;[[API:RNG.fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;[[API:RNG.fromState|RNG.fromState()]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Properties ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Methods ===&lt;br /&gt;
&lt;br /&gt;
==== Static Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Instance Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG::next&amp;diff=10126</id>
		<title>API:RNG::next</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG::next&amp;diff=10126"/>
				<updated>2017-08-10T03:53:10Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Improving headings some more&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:RNG::next()}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;'''RNG::next()'''&amp;lt;/tt&amp;gt; method generates a random floating-point number in the range &amp;lt;tt&amp;gt;[0,1)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 ''number'' = ''rng_object''.'''next'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''RNG::next()'''&amp;lt;/tt&amp;gt; generates a pseudorandom floating-point number greater than or equal to 0 but less than 1 and returns the value generated.  The number generated is entirely determined by the current state of the &amp;lt;tt&amp;gt;RNG&amp;lt;/tt&amp;gt; instance before the call (see &amp;lt;tt&amp;gt;[[API:RNG::state|RNG::state]]&amp;lt;/tt&amp;gt;).  After calling this function, the state is advanced so a different value will be generated next time.  Therefore if you save the RNG's state before calling &amp;lt;tt&amp;gt;RNG.next()&amp;lt;/tt&amp;gt;, then restore it afterwards and call &amp;lt;tt&amp;gt;RNG.next()&amp;lt;/tt&amp;gt; again, the same value will be returned.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This method has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
A floating-point number in the range &amp;lt;tt&amp;gt;[0,1)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
=== Shuffle an array ===&lt;br /&gt;
&lt;br /&gt;
 let items = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]&lt;br /&gt;
 &lt;br /&gt;
 let rnGen = new RNG();&lt;br /&gt;
 for (let i = items.length - 1; i &amp;gt; 0; --i) {&lt;br /&gt;
     let j = Math.floor(rnGen.next() * (i + 1));  // discrete [0,i]&lt;br /&gt;
     let orig_i = items[i];&lt;br /&gt;
     items[i] = items[j];&lt;br /&gt;
     items[j] = orig_i;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG::next&amp;diff=10125</id>
		<title>API:RNG::next</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG::next&amp;diff=10125"/>
				<updated>2017-08-09T15:45:10Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Reorganize page, add sub-headings for organization, add description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:RNG::next()}}&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;'''RNG::next()'''&amp;lt;/tt&amp;gt; method returns a random floating-point number in the range &amp;lt;tt&amp;gt;[0,1)&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
 ''number'' = ''rng_object''.'''next'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''RNG::next()'''&amp;lt;/tt&amp;gt; generates a pseudorandom floating-point value greater than or equal to 0 but less than 1 and returns the value so generated.  The value this function returns is entirely determined by the current state of the &amp;lt;tt&amp;gt;RNG&amp;lt;/tt&amp;gt; instance before the call (see &amp;lt;tt&amp;gt;[[API:RNG::state|RNG::state]]&amp;lt;/tt&amp;gt;).  After calling this function, the state is advanced so a different value will be generated next time.  If you save the state before &amp;lt;tt&amp;gt;RNG.next()&amp;lt;/tt&amp;gt;, then restore it afterwards and call &amp;lt;tt&amp;gt;RNG.next()&amp;lt;/tt&amp;gt; again, the same value will be generated.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
==== Shuffle items in an array ====&lt;br /&gt;
&lt;br /&gt;
 let items = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]&lt;br /&gt;
 let rnGen = new RNG();&lt;br /&gt;
 for (let i = items.length - 1; i &amp;gt; 0; --i) {&lt;br /&gt;
     let j = Math.floor(rnGen.next() * (i + 1));  // discrete [0,i]&lt;br /&gt;
     let orig_i = items[i];&lt;br /&gt;
     items[i] = items[j];&lt;br /&gt;
     items[j] = orig_i;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG::state&amp;diff=10124</id>
		<title>API:RNG::state</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG::state&amp;diff=10124"/>
				<updated>2017-08-09T15:31:42Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Created page with &amp;quot;{{DISPLAYTITLE:RNG::state}}  '''&amp;lt;tt&amp;gt;RNG::state&amp;lt;/tt&amp;gt;''' is an accessor property which allows you to get or set the current state of the random number generator instance.  === U...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:RNG::state}}&lt;br /&gt;
&lt;br /&gt;
'''&amp;lt;tt&amp;gt;RNG::state&amp;lt;/tt&amp;gt;''' is an accessor property which allows you to get or set the current state of the random number generator instance.&lt;br /&gt;
&lt;br /&gt;
=== Usage ===&lt;br /&gt;
&lt;br /&gt;
 ''current_state'' = ''rng_object''.'''state''';&lt;br /&gt;
 ''rng_object''.'''state''' = ''new_state'';&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''RNG::state'''&amp;lt;/tt&amp;gt; is a 32-byte hexadecimal string that encodes the exact state of the &amp;lt;tt&amp;gt;RNG&amp;lt;/tt&amp;gt; instance.  If you save the value of this property to a file and load it in a later session, you can resume a random number sequence from where you left off.  This is distinct from seeding (see &amp;lt;tt&amp;gt;[[API:RNG::fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt;), which starts a sequence from the beginning.&lt;br /&gt;
&lt;br /&gt;
One use of this is to combat &amp;quot;save scumming&amp;quot;, where a player saves a game before a randomly-determined event and reloads until they get a result they like (in Pokémon, for instance).  If you save the state of the random number generator along with the other game data, the RNG becomes much harder to exploit since the same sequence of numbers will be generated again after the reload.  This is also why Sphere allows you to construct multiple &amp;lt;tt&amp;gt;RNG&amp;lt;/tt&amp;gt; instances: by having separate instances for different events and persisting their states across saves, you can combat RNG manipulation.&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
==== Saving ====&lt;br /&gt;
&lt;br /&gt;
 let save = {&lt;br /&gt;
     name:     heroGuy.name,&lt;br /&gt;
     level:    heroGuy.level,&lt;br /&gt;
     rngState: myRNG.state,&lt;br /&gt;
     // etc...&lt;br /&gt;
 };&lt;br /&gt;
 let saveData = JSON.stringify(save);  // JSON encode&lt;br /&gt;
 FS.writeFile('~/saveGame.json', saveData);&lt;br /&gt;
&lt;br /&gt;
==== Loading ====&lt;br /&gt;
&lt;br /&gt;
 let saveData = FS.readFile('~/saveGame.json');&lt;br /&gt;
 let save = JSON.parse(saveData);  // JSON decode&lt;br /&gt;
 heroGuy.name = save.name;&lt;br /&gt;
 heroGuy.level = save.level;&lt;br /&gt;
 myRNG = RNG.fromState(save.state);  // or: myRNG.state = save.state;&lt;br /&gt;
 // etc...&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10123</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10123"/>
				<updated>2017-08-08T15:01:03Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Improve documentation conventions a bit&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:new RNG()}}&lt;br /&gt;
&lt;br /&gt;
The '''&amp;lt;tt&amp;gt;RNG()&amp;lt;/tt&amp;gt; constructor''' initializes a new instance of the pseudorandom number generator, seeded using the current time and date.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 ''rng_object'' = '''new RNG'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''new RNG()'''&amp;lt;/tt&amp;gt; initializes a new instance of the built-in pseudorandom number generator, seeded based on the current time and date.  Unlike &amp;lt;tt&amp;gt;Math.random()&amp;lt;/tt&amp;gt; which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers.&lt;br /&gt;
&lt;br /&gt;
To control the initial state of the generator, use &amp;lt;tt&amp;gt;[[API:RNG.fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;[[API:RNG.fromState|RNG.fromState()]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
==== Static Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Instance Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG::next&amp;diff=10122</id>
		<title>API:RNG::next</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG::next&amp;diff=10122"/>
				<updated>2017-08-08T14:55:58Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: New page: RNG::next()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:RNG::next()}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;'''RNG::next()'''&amp;lt;/tt&amp;gt; generates a pseudorandom floating-point number between 0.0 and 1.0 (exclusive).&lt;br /&gt;
&lt;br /&gt;
==== Usage ====&lt;br /&gt;
 ''number'' = ''rng_object''.'''next'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
&lt;br /&gt;
 /* &lt;br /&gt;
  *  Shuffle a list of numbers (Fisher-Yates)&lt;br /&gt;
  */&lt;br /&gt;
 &lt;br /&gt;
 let numbers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]&lt;br /&gt;
 let rnGen = new RNG();&lt;br /&gt;
 for (let i = numbers.length - 1; i &amp;gt; 0; --i) {&lt;br /&gt;
     let j = Math.floor(rnGen.next() * (i + 1));  // integer, [0,i]&lt;br /&gt;
     let orig_i = numbers[i];&lt;br /&gt;
     numbers[i] = numbers[j];&lt;br /&gt;
     numbers[j] = orig_i;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10121</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10121"/>
				<updated>2017-08-08T06:14:10Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:RNG Constructor}}&lt;br /&gt;
&lt;br /&gt;
Constructs a new instance of the pseudorandom number generator.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 rng_obj = '''new RNG'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;'''RNG'''&amp;lt;/tt&amp;gt; constructor initializes a new instance of the Sphere random number generator, seeded based on the current time and date.  Unlike &amp;lt;tt&amp;gt;Math.random()&amp;lt;/tt&amp;gt; which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers.&lt;br /&gt;
&lt;br /&gt;
To control the initial state of the generator, use &amp;lt;tt&amp;gt;[[API:RNG.fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;[[API:RNG.fromState|RNG.fromState()]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
==== Static Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Instance Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10120</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10120"/>
				<updated>2017-08-08T06:12:58Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Constructs a new instance of the pseudorandom number generator.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 rng_obj = '''new RNG'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;'''RNG'''&amp;lt;/tt&amp;gt; constructor initializes a new instance of the Sphere random number generator, seeded based on the current time and date.  Unlike &amp;lt;tt&amp;gt;Math.random()&amp;lt;/tt&amp;gt; which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers.&lt;br /&gt;
&lt;br /&gt;
To control the initial state of the generator, use &amp;lt;tt&amp;gt;[[API:RNG.fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;[[API:RNG.fromState|RNG.fromState()]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
==== Static Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Instance Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10119</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10119"/>
				<updated>2017-08-08T04:36:54Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Constructs a new instance of the pseudorandom number generator.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 rng_obj = '''new RNG'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;'''RNG'''&amp;lt;/tt&amp;gt; constructor initializes a new instance of the Sphere random number generator, seeded based on the current time and date.  Unlike &amp;lt;tt&amp;gt;Math.random()&amp;lt;/tt&amp;gt; which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers.&lt;br /&gt;
&lt;br /&gt;
To control the initial state of the generator, use &amp;lt;tt&amp;gt;[[API:RNG.fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;[[API:RNG.fromState|RNG.fromState()]]&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
==== Static Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Instance Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10118</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10118"/>
				<updated>2017-08-08T04:35:54Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Initial draft of RNG constructor documentation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Constructs a new instance of the pseudorandom number generator.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 rng_obj = '''new RNG'''();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;'''RNG'''&amp;lt;/tt&amp;gt; constructor initializes a new instance of the Sphere random number generator, seeded based on the current time and date.  Unlike &amp;lt;tt&amp;gt;Math.random()&amp;lt;/tt&amp;gt; which uses a very basic linear generator, Sphere uses the ''xoroshiro128+'' algorithm, providing games with a very high-quality source of pseudorandom numbers.  To control the initial state of the generator, you should use one of &amp;lt;tt&amp;gt;[[API:RNG.fromSeed|RNG.fromSeed()]]&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;[[API:RNG.fromState|RNG.fromState()]]&amp;lt;/tt&amp;gt; instead.&lt;br /&gt;
&lt;br /&gt;
== Properties ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::state|RNG::state]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Methods ==&lt;br /&gt;
&lt;br /&gt;
==== Static Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG.fromSeed|RNG.fromSeed()]]&lt;br /&gt;
* [[API:RNG.fromState|RNG.fromState()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Instance Methods ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:RNG::next|RNG::next()]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10117</id>
		<title>API:RNG</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:RNG&amp;diff=10117"/>
				<updated>2017-08-07T18:35:15Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Created page with &amp;quot;{{subst:objecttemp|preamble=Constructs a new instance of the Sphere pseudorandom number generator.  The '''RNG''' object uses the xoroshiro128+ algorithm, providing high-quali...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{subst:objecttemp|preamble=Constructs a new instance of the Sphere pseudorandom number generator.  The '''RNG''' object uses the xoroshiro128+ algorithm, providing high-quality pseudorandom numbers.|function=RNG|object=RNG|returns=A new ```RNG``` instance.|params=none}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10039</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10039"/>
				<updated>2017-06-23T04:36:58Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Writing the game script */ Remove WIP tag&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { transpile } from 'compiler';&lt;br /&gt;
&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
transpile('@/scripts/', files('src/*.mjs', true));&lt;br /&gt;
transpile('@/scripts/', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
//Now we determine which folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*.*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt; will compile the ES6 JavaScript modules that the Sphere 2 API uses into something that the Sphere engine knows how to use, since it has a more conventional JavaScript environment. (This is called transpilation.)&lt;br /&gt;
** You will have to put your script code into a src folder.&lt;br /&gt;
** After compilation of your project, the transpiled scripts will end up in the dist/scripts folder, unless you change the parameters of &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;, you define what files and folders get included into your distributed game, and under what name the folder will be known. In this case, all files from srcdir will be recursively copied into dist/distdir.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
Every Sphere game must have a main module--let's call it for the sake of argument &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--which contains the game's startup code.  At its most basic, the typical main module looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        /* ready... set...G*MUNCH*    stupid pig */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
Encapsulating the startup code with a class rather than a simple function (as was done in Sphere 1.5) offers a few benefits.  Most notably, you can take advantage of subclassing.  Deriving from &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, for example, gives you built-in update and render hooks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
export default&lt;br /&gt;
class MyGame extends Thread&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // when subclassing, the constructor must call the superclass before&lt;br /&gt;
        // doing anything else.&lt;br /&gt;
        super();&lt;br /&gt;
&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    on_update()&lt;br /&gt;
    {&lt;br /&gt;
        /* code here will run once per frame */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    on_render()&lt;br /&gt;
    {&lt;br /&gt;
        /* code to perform rendering for each frame, may be skipped to&lt;br /&gt;
           prevent slowdown */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When subclassing &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method is required because it's already provided by the &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy minisphere.exe and its system folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
* Rename the dist folder to 'startup'.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click minisphere.exe to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10038</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10038"/>
				<updated>2017-06-23T04:32:39Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Writing the game script */ Add Thread subclass example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { transpile } from 'compiler';&lt;br /&gt;
&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
transpile('@/scripts/', files('src/*.mjs', true));&lt;br /&gt;
transpile('@/scripts/', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
//Now we determine which folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*.*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt; will compile the ES6 JavaScript modules that the Sphere 2 API uses into something that the Sphere engine knows how to use, since it has a more conventional JavaScript environment. (This is called transpilation.)&lt;br /&gt;
** You will have to put your script code into a src folder.&lt;br /&gt;
** After compilation of your project, the transpiled scripts will end up in the dist/scripts folder, unless you change the parameters of &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;, you define what files and folders get included into your distributed game, and under what name the folder will be known. In this case, all files from srcdir will be recursively copied into dist/distdir.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
''Work in progress.''&lt;br /&gt;
&lt;br /&gt;
Every Sphere game must have a main module--let's call it for the sake of argument &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--which contains the game's startup code.  At its most basic, the typical main module looks something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        /* ready... set...G*MUNCH*    stupid pig */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
Encapsulating the startup code with a class rather than a simple function (as was done in Sphere 1.5) offers a few benefits.  Most notably, you can take advantage of subclassing.  Deriving from &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, for example, gives you built-in update and render hooks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { Thread } from 'sphere-runtime';&lt;br /&gt;
&lt;br /&gt;
export default&lt;br /&gt;
class MyGame extends Thread&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // when subclassing, the constructor must call the superclass before&lt;br /&gt;
        // doing anything else.&lt;br /&gt;
        super();&lt;br /&gt;
&lt;br /&gt;
        /* load resources, set variables, etc. */&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    on_update()&lt;br /&gt;
    {&lt;br /&gt;
        /* code here will run once per frame */&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    on_render()&lt;br /&gt;
    {&lt;br /&gt;
        /* code to perform rendering for each frame, may be skipped to&lt;br /&gt;
           prevent slowdown */&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When subclassing &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt;, no &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method is required because it's already provided by the &amp;lt;code&amp;gt;Thread&amp;lt;/code&amp;gt; class.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy minisphere.exe and its system folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
* Rename the dist folder to 'startup'.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click minisphere.exe to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10037</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10037"/>
				<updated>2017-06-22T17:33:08Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Writing the game script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { transpile } from 'compiler';&lt;br /&gt;
&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
transpile('@/scripts/', files('src/*.mjs', true));&lt;br /&gt;
transpile('@/scripts/', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
//Now we determine which folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*.*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt; will compile the ES6 JavaScript modules that the Sphere 2 API uses into something that the Sphere engine knows how to use, since it has a more conventional JavaScript environment. (This is called transpilation.)&lt;br /&gt;
** You will have to put your script code into a src folder.&lt;br /&gt;
** After compilation of your project, the transpiled scripts will end up in the dist/scripts folder, unless you change the parameters of &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;, you define what files and folders get included into your distributed game, and under what name the folder will be known. In this case, all files from srcdir will be recursively copied into dist/distdir.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
''Work in progress.''&lt;br /&gt;
&lt;br /&gt;
The most basic Sphere v2 game has a main module--let's hypothetically call it &amp;lt;code&amp;gt;main.mjs&amp;lt;/code&amp;gt;--that looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
export default&lt;br /&gt;
class MyGame&lt;br /&gt;
{&lt;br /&gt;
    constructor()&lt;br /&gt;
    {&lt;br /&gt;
        // optional initialization here&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    start()&lt;br /&gt;
    {&lt;br /&gt;
        // ready... set...G*MUNCH*          stupid pig&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;export default&amp;lt;/code&amp;gt; makes the class the default export for the module, so &amp;lt;code&amp;gt;MyGame&amp;lt;/code&amp;gt; can actually be named anything you want.  On startup, the engine will instantiate the exported class (read: create an object from it) and call the &amp;lt;code&amp;gt;start()&amp;lt;/code&amp;gt; method to kickstart execution.&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy minisphere.exe and its system folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
* Rename the dist folder to 'startup'.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click minisphere.exe to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10036</id>
		<title>Getting started</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Getting_started&amp;diff=10036"/>
				<updated>2017-06-22T17:04:32Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Don't use Sphere 1.5 for new games&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;To find out how to get started with the legacy Sphere 1.x, please check [[Getting started with Sphere 1.5]].  It is strongly recommended '''not''' to use the legacy engine for new projects!&lt;br /&gt;
&lt;br /&gt;
''This article is still a work in progress and not 100% complete yet.''&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
You can download miniSphere [http://www.spheredev.org/#download here].&lt;br /&gt;
&lt;br /&gt;
You may have just downloaded this &amp;quot;Sphere&amp;quot;, but have no idea what to do what to do with it. This article will explain everything that is useful to know about the game engine and its tools. Then it will walk you through creating a tiny little game from scratch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== File support ==&lt;br /&gt;
&lt;br /&gt;
miniSphere has native support for many different file formats, so you generally don't have to worry about having to convert files much.&lt;br /&gt;
&lt;br /&gt;
* Images: bmp, png, jpg, tga&lt;br /&gt;
* Sound: wav, ogg, flac, mod, xm, s3m, it.&lt;br /&gt;
** MP3 is not currently supported. It is recommended to use OGG files instead.&lt;br /&gt;
* Scripts: js, mjs&lt;br /&gt;
&lt;br /&gt;
=== Sphere-specific file formats ===&lt;br /&gt;
Besides the above, miniSphere also supports file formats Specicially made for the game engine.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! File&lt;br /&gt;
! What is it?&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| game.sgm, game.json&lt;br /&gt;
| Project file&lt;br /&gt;
| You can run your game by opening it with miniSphere. Contains some info about your game (like its name, author and resolution). The sgm is for legacy Sphere games while new ones use the json file.&lt;br /&gt;
|-&lt;br /&gt;
| .rmp&lt;br /&gt;
| Map file&lt;br /&gt;
| Can be created with editors like Sphere Studio or the legacy Sphere editor.&lt;br /&gt;
|-&lt;br /&gt;
| .rts&lt;br /&gt;
| Map tileset&lt;br /&gt;
| Contains tile images and tile data. It can be reused across maps.&lt;br /&gt;
|-&lt;br /&gt;
| .rss&lt;br /&gt;
| Spriteset&lt;br /&gt;
| For creating game sprites. They can be animated.&lt;br /&gt;
|-&lt;br /&gt;
| .rfn&lt;br /&gt;
| Bitmap font&lt;br /&gt;
| A font file consisting of many images per character that you can edit.&lt;br /&gt;
|-&lt;br /&gt;
| .rws&lt;br /&gt;
| Windowstyle&lt;br /&gt;
| For designing resizable windows that go around things like text boxes and menus.&lt;br /&gt;
|-&lt;br /&gt;
| .spk&lt;br /&gt;
| Sphere game package&lt;br /&gt;
| This is a packaged Sphere game, for easy distribution of your game (and some protection if you don't want your source code to be shown).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== The tools ==&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with several different tools:&lt;br /&gt;
&lt;br /&gt;
* The game engine itself (miniSphere);&lt;br /&gt;
* A development environment for Windows (Sphere Studio);&lt;br /&gt;
* A debugger (SSJ);&lt;br /&gt;
* A programmable compiler (Cell).&lt;br /&gt;
&lt;br /&gt;
==== The game engine: miniSphere ====&lt;br /&gt;
&lt;br /&gt;
This is the game engine that will ultimately allow you to run your game. If you associate .sgm and game.json files with it, you can simply double-click them and run the game. (There are other ways to make it easy for distribution as well.)&lt;br /&gt;
&lt;br /&gt;
==== The editor: Sphere Studio ====&lt;br /&gt;
&lt;br /&gt;
miniSphere comes with Sphere Studio, an integrated editor, which lets you create, view and edit the different file types mentioned above. It also has a built-in code editor for editing your JavaScript (js and mjs) files.&lt;br /&gt;
&lt;br /&gt;
==== The debugger: SSJ ====&lt;br /&gt;
&lt;br /&gt;
SSJ allows you to debug your game. This means that when your game crashes or shows unwanted behavior somewhere, you can figure out where it's happening and why. It's an invaluable time saver.&lt;br /&gt;
&lt;br /&gt;
==== The compiler: Cell ====&lt;br /&gt;
&lt;br /&gt;
Cell allows you to compile your game project into something that can be distributed on the internet! Once compiled, you will have a &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder that you can put online.&lt;br /&gt;
&lt;br /&gt;
Please see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for details on this tool.&lt;br /&gt;
&lt;br /&gt;
Cell requires a build script (Cellscript.mjs) in your project folder to compile the game. Sphere Studio will generate this file for you and so compiling is made easy (just one click).&lt;br /&gt;
&lt;br /&gt;
== Starting a new game project ==&lt;br /&gt;
&lt;br /&gt;
There are several ways to start a new game project:&lt;br /&gt;
&lt;br /&gt;
* Creating a new project in Sphere Studio;&lt;br /&gt;
* Creating the project folder yourself;&lt;br /&gt;
* Using a template.&lt;br /&gt;
&lt;br /&gt;
In the future, a feature will be added that allows you to create a new project from the command line.&lt;br /&gt;
&lt;br /&gt;
In any case, you will end up with a project folder containing a Cell.mjs file. This is your build script that Cell will use to compile your game.&lt;br /&gt;
&lt;br /&gt;
=== Creating a new project in Sphere Studio ===&lt;br /&gt;
&lt;br /&gt;
This one is easy: fire up Sphere Studio. After the first-run configuration screens, you can create a new project right from the menu.&lt;br /&gt;
&lt;br /&gt;
=== Using a template ===&lt;br /&gt;
&lt;br /&gt;
[http://www.spheredev.org/files/sphere2-template.zip Download the template]&lt;br /&gt;
&lt;br /&gt;
It includes the required Cellscript.mjs, some commonly used folders, and an example scrip in the src folder.&lt;br /&gt;
&lt;br /&gt;
=== Creating the project folder yourself ===&lt;br /&gt;
&lt;br /&gt;
Finally, it's not too difficult to start a new project entirely from scratch. All you need is a text editor to create a valid Cellscript.mjs.&lt;br /&gt;
&lt;br /&gt;
Cellscript.mjs should, at the very minimum, contain the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import { transpile } from 'compiler';&lt;br /&gt;
&lt;br /&gt;
Object.assign(Sphere.Game, {&lt;br /&gt;
	name: &amp;quot;Your game name here&amp;quot;,&lt;br /&gt;
	version: 2,&lt;br /&gt;
	author: &amp;quot;Your name here&amp;quot;,&lt;br /&gt;
	summary: &amp;quot;Summary of the game&amp;quot;,&lt;br /&gt;
	resolution: '1280x720',&lt;br /&gt;
	main: 'scripts/main.js',&lt;br /&gt;
});&lt;br /&gt;
&lt;br /&gt;
transpile('@/scripts/', files('src/*.mjs', true));&lt;br /&gt;
transpile('@/scripts/', files('src/*.js', true));&lt;br /&gt;
&lt;br /&gt;
//Now we determine which folders get added into the distributed version of the game&lt;br /&gt;
install('@/distdir', &amp;quot;srcdir/*.*&amp;quot;, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Notes and details =====&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;version&amp;lt;/tt&amp;gt; describes the Sphere API version. In this guide, we use the Sphere 2 API.&lt;br /&gt;
* &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt; will compile the ES6 JavaScript modules that the Sphere 2 API uses into something that the Sphere engine knows how to use, since it has a more conventional JavaScript environment. (This is called transpilation.)&lt;br /&gt;
** You will have to put your script code into a src folder.&lt;br /&gt;
** After compilation of your project, the transpiled scripts will end up in the dist/scripts folder, unless you change the parameters of &amp;lt;tt&amp;gt;transpile()&amp;lt;/tt&amp;gt;.&lt;br /&gt;
* With &amp;lt;tt&amp;gt;install()&amp;lt;/tt&amp;gt;, you define what files and folders get included into your distributed game, and under what name the folder will be known. In this case, all files from srcdir will be recursively copied into dist/distdir.&lt;br /&gt;
* Again, see the [https://github.com/fatcerberus/minisphere/blob/master/docs/cellscript-api.txt Cellscript API reference] for further details.&lt;br /&gt;
&lt;br /&gt;
== Creating your game ==&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a map ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Creating a sprite ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== Writing the game script ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
== Compiling the game ==&lt;br /&gt;
&lt;br /&gt;
This step is needed to create a version of your game project that can be run with miniSphere.&lt;br /&gt;
&lt;br /&gt;
=== From the editor ===&lt;br /&gt;
&lt;br /&gt;
If you're using Sphere Studio or any other compatible IDE, it's literally a matter of pressing the &amp;quot;Build&amp;quot; button. If you want to distribute your game, make sure you select &amp;quot;release&amp;quot; mode rather than &amp;quot;debug&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You can also click the &amp;quot;Run&amp;quot; button to both compile and start the game right away from the editor.&lt;br /&gt;
&lt;br /&gt;
''Note: when running the game from the editor, you have the option to use miniSphere's powerful debugging features. For this, the game needs to run in debug mode. See [[Using the debugger]] for more information.''&lt;br /&gt;
&lt;br /&gt;
=== From the command line/terminal ===&lt;br /&gt;
&lt;br /&gt;
* Open a terminal and navigate to the directory where your Cellscript.mjs is located.&lt;br /&gt;
* Run the following command&lt;br /&gt;
&lt;br /&gt;
    cell&lt;br /&gt;
&lt;br /&gt;
Your game will be compiled and a runnable version of it will be put in the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder.&lt;br /&gt;
&lt;br /&gt;
== Running the game ==&lt;br /&gt;
&lt;br /&gt;
Navigate to the &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder. Run the game.json file with miniSphere.&lt;br /&gt;
&lt;br /&gt;
== Packaging and distributing your game ==&lt;br /&gt;
&lt;br /&gt;
=== Just the game project ===&lt;br /&gt;
&lt;br /&gt;
It's as simple as renaming and zipping your &amp;lt;tt&amp;gt;dist&amp;lt;/tt&amp;gt; folder!&lt;br /&gt;
&lt;br /&gt;
=== As a stand-alone game ===&lt;br /&gt;
&lt;br /&gt;
You might want to make the game stand-alone so people don't need to have miniSphere to run it.&lt;br /&gt;
&lt;br /&gt;
* Make a new directory with your game's name.&lt;br /&gt;
* Copy minisphere.exe and its system folder into your newly created directory.&lt;br /&gt;
* Copy your game's dist folder there, too.&lt;br /&gt;
* Rename the dist folder to 'startup'.&lt;br /&gt;
&lt;br /&gt;
Now people can double-click minisphere.exe to run your game! Of course, you can also copy the Linux and OS X binaries into this same directory to offer a cross-platform way for people to run your game.&lt;br /&gt;
&lt;br /&gt;
=== Uploading and sharing! ===&lt;br /&gt;
&lt;br /&gt;
Upload your game somewhere (we have a [https://drive.google.com/open?id=0Bw-4UFVty4u1REhieE5WUTU0LVE public uploads folder available]). Then, share it with the Spherical community or wherever you like! (We love seeing new games and releases!)&lt;br /&gt;
&lt;br /&gt;
If the game is an RPG, [http://rpgmaker.net/ rpgmaker.net] is also a nice place to upload your game, find an audience and receive feedback.&lt;br /&gt;
&lt;br /&gt;
[[Category:Tutorials]]&lt;br /&gt;
[[Category:Sphere 2]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=9900</id>
		<title>MiniSphere</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=9900"/>
				<updated>2015-06-30T06:47:01Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://forums.spheredev.org/index.php/topic,1215.0.html '''minisphere'''] is a modern replacement for and evolution of the aging [[Sphere|Sphere 1.5]] engine.  It is not a fork of the original engine's codebase; it is a completely new implementation written from the ground up in C, based on [http://alleg.sourceforge.net/ Allegro] and [http://duktape.org/ Duktape], and includes support for modern features such as OpenGL shaders and CommonJS modules.  The vast majority of the Sphere 1.5 JavaScript API is also available for use in minisphere, with only a few functions missing from the implementation.  A complete implementation of the Sphere 1.5 map engine is also included and built in.&lt;br /&gt;
&lt;br /&gt;
The minisphere engine is available in both x86 (32-bit) and x64 (64-bit) variants, the latter of which is recommended on supported platforms as it typically provides better performance. The engine is tiny and self-contained, requiring only 3 MB for the 64-bit engine and its system assets.  As it is coded in C, it is also very portable and has been successfully compiled on both Linux and OS X platforms.&lt;br /&gt;
&lt;br /&gt;
As of this writing (June 30, 2015), there is not yet an official site on the Web for minisphere, but the engine is available for download and discussion on the Spherical forums [http://forums.spheredev.org/index.php/topic,1215.0.html here]. The current official release is '''minisphere 1.4.5'''.  A &amp;quot;minisphere GDK&amp;quot; version is available as well, which includes a console-enabled build of the engine and [[Sphere Studio]] for rapid game development.&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:minisphere}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Legacy:GetSeconds&amp;diff=9899</id>
		<title>Legacy:GetSeconds</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Legacy:GetSeconds&amp;diff=9899"/>
				<updated>2015-06-30T06:40:24Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Obtains the amount of time in seconds, in floating point, elapsed since an arbitrary time. This function typically has sub-microsecond precision, making it useful for benchmarking or any other situation where you need higher-precision timing than [[API:GetTime|GetTime]]() can give you. A '''Sphere 2.0''' engine such as [[minisphere]] is required to use this function.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
{{Usage|returns=number|func=GetSeconds}}&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var time = GetSeconds();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above gets the number of seconds passed since some predetermined time, and places it in the &amp;lt;var&amp;gt;time&amp;lt;/var&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var start_time = GetSeconds();&lt;br /&gt;
// Code that needs to be timed&lt;br /&gt;
// ...&lt;br /&gt;
var duration = GetSeconds() - start_time;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example will find out how long a particular piece of code runs for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var done = false;&lt;br /&gt;
var fps = GetFrameRate();&lt;br /&gt;
var updates_performed = 0;&lt;br /&gt;
var start_time = GetSeconds();&lt;br /&gt;
while (!done)&lt;br /&gt;
{&lt;br /&gt;
  while (updates_performed &amp;lt; (GetSeconds() - start_time) * fps)&lt;br /&gt;
  {&lt;br /&gt;
    // Update game here&lt;br /&gt;
    // ...&lt;br /&gt;
    updates_performed++;&lt;br /&gt;
  }&lt;br /&gt;
  // Draw the game screen here&lt;br /&gt;
  // ...&lt;br /&gt;
  FlipScreen();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example is one way to regulate the speed of a Sphere game inside a JavaScript loop. The game code will have to be separated into updates (player input processing, moving entities, checking collisions, etc.) and drawing (drawing sprites, the map, score, etc.).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var FPS = 60;                // The desired FPS&lt;br /&gt;
var delayTime = 1.0/FPS;     // The time between frames&lt;br /&gt;
var lastTime = GetSeconds(); // The time of the last frame&lt;br /&gt;
while(loopCondition)         // While we should continue looping&lt;br /&gt;
{&lt;br /&gt;
  if(GetSeconds() &amp;gt; lastTime + delayTime) // If enough time has elapsed&lt;br /&gt;
  {&lt;br /&gt;
    lastTime = GetSeconds(); // Record the time of this frame&lt;br /&gt;
    doStuff();               // Do your stuff&lt;br /&gt;
  }&lt;br /&gt;
  drawStuff();               // Draw your stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example is an alternative to the one above. Obviously, doStuff() and drawStuff() will correspond with functions that actually process the game logic and draw the game state respectively.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
*	The starting time can be assumed to be constant throughout the running of a game. Thus GetSeconds() is very useful as a tool to pace JavaScript loops, which would normally run at different speeds on different systems.&lt;br /&gt;
*	Core JavaScript provides a similar mechanism via the [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date] object's [https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime Date.getTime]() method. This counter, if used with a Date object that reflects the current time, displays the number of milliseconds since midnight 01 January, 1970 UTC. Refer to the links for more information.&lt;br /&gt;
*	Unlike [[API:GetTime|GetTime]](), the value returned by this function is not subject to wraparound.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*	[[API:FlipScreen|FlipScreen]]()&lt;br /&gt;
*	[[API:GetFrameRate|GetFrameRate]]()&lt;br /&gt;
*	Core JavaScript [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date] object&lt;br /&gt;
*	Core JavaScript [https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime Date.getTime]()&lt;br /&gt;
&lt;br /&gt;
{{API:Script/navbox}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Legacy:GetSeconds&amp;diff=9898</id>
		<title>Legacy:GetSeconds</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Legacy:GetSeconds&amp;diff=9898"/>
				<updated>2015-06-30T06:38:43Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: Created page with &amp;quot;Obtains the amount of time in seconds, in floating point, elapsed since an arbitrary time. This function typically has sub-microsecond precision, making it useful for benchmar...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Obtains the amount of time in seconds, in floating point, elapsed since an arbitrary time. This function typically has sub-microsecond precision, making it useful for benchmarking or any other situation where you need higher-precision timing than [[API:GetTime|GetTime]]() can give you. A Sphere 2.0 engine such as [[minisphere]] is required to use this function.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
{{Usage|returns=number|func=GetSeconds}}&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var time = GetSeconds();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above gets the number of seconds passed since some predetermined time, and places it in the &amp;lt;var&amp;gt;time&amp;lt;/var&amp;gt; variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var start_time = GetSeconds();&lt;br /&gt;
// Code that needs to be timed&lt;br /&gt;
// ...&lt;br /&gt;
var duration = GetTime() - start_time;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example will find out how long a particular piece of code runs for.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var done = false;&lt;br /&gt;
var fps = GetFrameRate();&lt;br /&gt;
var updates_performed = 0;&lt;br /&gt;
var start_time = GetSeconds();&lt;br /&gt;
while (!done)&lt;br /&gt;
{&lt;br /&gt;
  while (updates_performed &amp;lt; (GetSeconds() - start_time) * fps)&lt;br /&gt;
  {&lt;br /&gt;
    // Update game here&lt;br /&gt;
    // ...&lt;br /&gt;
    updates_performed++;&lt;br /&gt;
  }&lt;br /&gt;
  // Draw the game screen here&lt;br /&gt;
  // ...&lt;br /&gt;
  FlipScreen();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above example is one way to regulate the speed of a Sphere game inside a JavaScript loop. The game code will have to be separated into updates (player input processing, moving entities, checking collisions, etc.) and drawing (drawing sprites, the map, score, etc.).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var FPS = 60;                // The desired FPS&lt;br /&gt;
var delayTime = 1.0/FPS;     // The time between frames&lt;br /&gt;
var lastTime = GetSeconds(); // The time of the last frame&lt;br /&gt;
while(loopCondition)         // While we should continue looping&lt;br /&gt;
{&lt;br /&gt;
  if(GetSeconds() &amp;gt; lastTime + delayTime) // If enough time has elapsed&lt;br /&gt;
  {&lt;br /&gt;
    lastTime = GetSeconds(); // Record the time of this frame&lt;br /&gt;
    doStuff();               // Do your stuff&lt;br /&gt;
  }&lt;br /&gt;
  drawStuff();               // Draw your stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example is an alternative to the one above. Obviously, doStuff() and drawStuff() will correspond with functions that actually process the game logic and draw the game state respectively.&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
*	The starting time can be assumed to be constant throughout the running of a game. Thus GetSeconds() is very useful as a tool to pace JavaScript loops, which would normally run at different speeds on different systems.&lt;br /&gt;
*	Core JavaScript provides a similar mechanism via the [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date] object's [https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime Date.getTime]() method. This counter, if used with a Date object that reflects the current time, displays the number of milliseconds since midnight 01 January, 1970 UTC. Refer to the links for more information.&lt;br /&gt;
*	Unlike [[API:GetTime|GetTime]](), the value returned by this function is not subject to wraparound.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*	[[API:FlipScreen|FlipScreen]]()&lt;br /&gt;
*	[[API:GetFrameRate|GetFrameRate]]()&lt;br /&gt;
*	Core JavaScript [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date Date] object&lt;br /&gt;
*	Core JavaScript [https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/getTime Date.getTime]()&lt;br /&gt;
&lt;br /&gt;
{{API:Script/navbox}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=9897</id>
		<title>MiniSphere</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=9897"/>
				<updated>2015-06-30T06:31:46Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://forums.spheredev.org/index.php/topic,1215.0.html '''minisphere'''] is a modern replacement for the aging [[Sphere|Sphere 1.5]] engine.  It is not a fork of the original engine's codebase; it is a completely new implementation written from the ground up in C, based on [http://alleg.sourceforge.net/ Allegro] and [http://duktape.org/ Duktape], and includes support for modern features such as OpenGL shaders and CommonJS modules.  The vast majority of the Sphere 1.5 JavaScript API is also available for use in minisphere, with only a few functions missing from the implementation.  A complete implementation of the Sphere 1.5 map engine is also included and built in.&lt;br /&gt;
&lt;br /&gt;
The minisphere engine is available in both x86 (32-bit) and x64 (64-bit) variants, the latter of which is recommended as it typically provides better performance. The engine is tiny, requiring only 1.7 MB for the 64-bit engine and the official Windows build is completely self-contained in a single executable.  As it is coded in C, it is also very portable and has been successfully compiled on both Linux and OS X platforms.&lt;br /&gt;
&lt;br /&gt;
As of this writing (June 10, 2015), there is not yet an official site on the Web for minisphere, but the engine is available for download and discussion on the Spherical forums [http://forums.spheredev.org/index.php/topic,1215.0.html here]. The current official release is '''minisphere 1.4.5'''.&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:minisphere}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Legacy:CreateColor&amp;diff=9894</id>
		<title>Legacy:CreateColor</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Legacy:CreateColor&amp;diff=9894"/>
				<updated>2015-06-20T05:00:38Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Notes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Returns a Sphere [[API:Color|Color]] Object, to be used in color masks or drawing primitives.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''Sphere 1.0 API'''&amp;lt;/center&amp;gt;&lt;br /&gt;
{{Usage|func=CreateColor|params=r, g, b, a}}&lt;br /&gt;
&amp;lt;center&amp;gt;'''Sphere 2.0 API'''&amp;lt;/center&amp;gt;&lt;br /&gt;
{{Usage|func=new Color|params=r, g, b, a}}&lt;br /&gt;
&lt;br /&gt;
*	'''r''' the red component&lt;br /&gt;
*	'''g''' the green component&lt;br /&gt;
*	'''b''' the blue component&lt;br /&gt;
*	'''a''' the alpha component&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
* The alpha component is optional. By default it's complete opaque (255).&lt;br /&gt;
* Avoid creating Color objects on the fly in render scripts, particularly when the actual RGB values used don't change from frame to frame.  This seems innocent enough, but can slow down your game considerably.  Instead, try to create Colors ahead of time so they can be reused each frame.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
Create some colors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var Red    = CreateColor(255, 0  , 0);&lt;br /&gt;
var Green  = CreateColor(0  , 255, 0);&lt;br /&gt;
var Yellow = CreateColor(255, 255, 0);&lt;br /&gt;
&lt;br /&gt;
var TransparentRed = CreateColor(255, 0, 0, 125);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*	Sphere [[API:Color|Color]] Object&lt;br /&gt;
*	[[API:Line|Line]](x1, x2, y1, y2, color)&lt;br /&gt;
*	[[API:Point|Point]](x, y, color)&lt;br /&gt;
*	[[API:Rectangle|Rectangle]](x, y, width, height, color)&lt;br /&gt;
*	[[API:Image/blitMask|Image.blitMask]](x, y, color)&lt;br /&gt;
*	[[API:FlipScreen|FlipScreen]]()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{API:Color/navbox}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=Legacy:CreateColor&amp;diff=9893</id>
		<title>Legacy:CreateColor</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=Legacy:CreateColor&amp;diff=9893"/>
				<updated>2015-06-20T04:55:10Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Returns a Sphere [[API:Color|Color]] Object, to be used in color masks or drawing primitives.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;center&amp;gt;'''Sphere 1.0 API'''&amp;lt;/center&amp;gt;&lt;br /&gt;
{{Usage|func=CreateColor|params=r, g, b, a}}&lt;br /&gt;
&amp;lt;center&amp;gt;'''Sphere 2.0 API'''&amp;lt;/center&amp;gt;&lt;br /&gt;
{{Usage|func=new Color|params=r, g, b, a}}&lt;br /&gt;
&lt;br /&gt;
*	'''r''' the red component&lt;br /&gt;
*	'''g''' the green component&lt;br /&gt;
*	'''b''' the blue component&lt;br /&gt;
*	'''a''' the alpha component&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
The alpha component is optional. By default it's complete opaque (255).&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
Create some colors:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
var Red    = CreateColor(255, 0  , 0);&lt;br /&gt;
var Green  = CreateColor(0  , 255, 0);&lt;br /&gt;
var Yellow = CreateColor(255, 255, 0);&lt;br /&gt;
&lt;br /&gt;
var TransparentRed = CreateColor(255, 0, 0, 125);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*	Sphere [[API:Color|Color]] Object&lt;br /&gt;
*	[[API:Line|Line]](x1, x2, y1, y2, color)&lt;br /&gt;
*	[[API:Point|Point]](x, y, color)&lt;br /&gt;
*	[[API:Rectangle|Rectangle]](x, y, width, height, color)&lt;br /&gt;
*	[[API:Image/blitMask|Image.blitMask]](x, y, color)&lt;br /&gt;
*	[[API:FlipScreen|FlipScreen]]()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{API:Color/navbox}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=3878</id>
		<title>MiniSphere</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=3878"/>
				<updated>2015-06-13T03:05:50Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://forums.spheredev.org/index.php/topic,1215.0.html '''minisphere'''] is a modern replacement for the aging [[Sphere|Sphere 1.5]] engine.  It is not a fork of the original engine's codebase; it is a completely new implementation written from the ground up in C, based on [http://alleg.sourceforge.net/ Allegro] and [http://duktape.org/ Duktape], and includes support for modern features such as OpenGL shaders and CommonJS modules.  The vast majority of the Sphere 1.5 JavaScript API is also available for use in minisphere, with only a few functions missing from the implementation.  A complete implementation of the Sphere 1.5 map engine is also included and built in.&lt;br /&gt;
&lt;br /&gt;
The minisphere engine is available in both x86 (32-bit) and x64 (64-bit) variants, the latter of which is recommended as it typically provides better performance. The engine is tiny, requiring only 1.7 MB for the 64-bit engine and the official Windows build is completely self-contained in a single executable.  As it is coded in C, it is also very portable and has been successfully compiled on both Linux and OS X platforms.&lt;br /&gt;
&lt;br /&gt;
As of this writing (June 10, 2015), there is not yet an official site on the Web for minisphere, but the engine is available for download and discussion on the Spherical forums [http://forums.spheredev.org/index.php/topic,1215.0.html here]. The current official release is '''minisphere 1.2.4'''.&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:minisphere}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=1178</id>
		<title>MiniSphere</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=1178"/>
				<updated>2015-06-10T06:47:00Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://forums.spheredev.org/index.php/topic,1215.0.html '''minisphere'''] is a modern replacement for the aging [[Sphere|Sphere 1.5]] engine.  It is not a fork of the original engine's codebase; it is a completely new implementation written from the ground up in C, based on [http://alleg.sourceforge.net/ Allegro] and [http://duktape.org/ Duktape], and includes support for modern features such as OpenGL shaders and CommonJS modules.  The vast majority of the Sphere 1.5 JavaScript API is also available for use in minisphere, with only a few functions missing from the implementation.  A complete implementation of the Sphere 1.5 map engine is also included and built in.&lt;br /&gt;
&lt;br /&gt;
The minisphere engine is available in both x86 (32-bit) and x64 (64-bit) variants, the latter of which is recommended as it typically provides better performance. The engine is tiny, requiring only 1.7 MB for the 64-bit engine and the official Windows build is completely self-contained in a single executable.  As it is coded in C, it is also very portable and has been successfully compiled on both Linux and OS X platforms.&lt;br /&gt;
&lt;br /&gt;
As of this writing (June 10, 2015), there is not yet an official site on the Web for minisphere, but the engine is available for download and discussion on the Spherical forums [http://forums.spheredev.org/index.php/topic,1215.0.html here]. The current official release is '''minisphere 1.2.3'''.&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:minisphere}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=1177</id>
		<title>MiniSphere</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=1177"/>
				<updated>2015-06-10T06:46:23Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://forums.spheredev.org/index.php/topic,1215.0.html '''minisphere'''] is a modern replacement for the aging [[Sphere|Sphere 1.5]] engine.  It is not a fork of the original engine's codebase; it is a completely new implementation written from the ground up in C and is based on [http://alleg.sourceforge.net/ Allegro] and [http://duktape.org/ Duktape] and includes support for modern features such as OpenGL shaders and CommonJS modules.  The vast majority of the Sphere 1.5 JavaScript API is also available for use in minisphere, with only a few functions missing from the implementation.  A complete implementation of the Sphere 1.5 map engine is also included and built in.&lt;br /&gt;
&lt;br /&gt;
The minisphere engine is available in both x86 (32-bit) and x64 (64-bit) variants, the latter of which is recommended as it typically provides better performance. The engine is tiny, requiring only 1.7 MB for the 64-bit engine and the official Windows build is completely self-contained in a single executable.  As it is coded in C, it is also very portable and has been successfully compiled on both Linux and OS X platforms.&lt;br /&gt;
&lt;br /&gt;
As of this writing (June 10, 2015), there is not yet an official site on the Web for minisphere, but the engine is available for download and discussion on the Spherical forums [http://forums.spheredev.org/index.php/topic,1215.0.html here]. The current official release is '''minisphere 1.2.3'''.&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:minisphere}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	<entry>
		<id>http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=1176</id>
		<title>MiniSphere</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=MiniSphere&amp;diff=1176"/>
				<updated>2015-06-10T06:43:17Z</updated>
		
		<summary type="html">&lt;p&gt;Bruce Pascoe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[http://forums.spheredev.org/index.php/topic,1215.0.html '''minisphere'''] is a modern replacement for the aging [[Sphere 1.5]] engine.  It is not a fork of the original engine's codebase; it is a completely new implementation written from the ground up in C and is based on [http://alleg.sourceforge.net/ Allegro] and [http://duktape.org/ Duktape] and includes support for modern features such as OpenGL shaders and CommonJS modules.  The vast majority of the Sphere 1.5 JavaScript API is also available for use in minisphere, with only a few functions missing from the implementation.  A complete implementation of the Sphere 1.5 map engine is also included and built in.&lt;br /&gt;
&lt;br /&gt;
The minisphere engine is available in both x86 (32-bit) and x64 (64-bit) variants, the latter of which is recommended as it typically provides better performance. The engine is tiny, requiring only 1.7 MB for the 64-bit engine and the official Windows build is completely self-contained in a single executable.  As it is coded in C, it is also very portable and has been successfully compiled on both Linux and OS X platforms.&lt;br /&gt;
&lt;br /&gt;
As of this writing (June 10, 2015), there is not yet an official site on the Web for minisphere, but the engine is available for download and discussion on the Spherical forums [http://forums.spheredev.org/index.php/topic,1215.0.html here]. The current official release is '''minisphere 1.2.3'''.&lt;br /&gt;
&lt;br /&gt;
{{DISPLAYTITLE:minisphere}}&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>	</entry>

	</feed>