<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Silveira Neto &#187; gamedev</title>
	<atom:link href="http://silveiraneto.net/tag/gamedev/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description>the world is a pixel</description>
	<lastBuildDate>Sun, 08 Jan 2012 05:17:57 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>My Free Tileset, version 7</title>
		<link>http://silveiraneto.net/2009/02/02/my-free-tileset-version-7/</link>
		<comments>http://silveiraneto.net/2009/02/02/my-free-tileset-version-7/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 15:01:50 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[Pixelart]]></category>
		<category><![CDATA[tileset]]></category>
		<category><![CDATA[warrior]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2226</guid>
		<description><![CDATA[Another version of the my free tileset project with a lot of improvements. Examples of usage: A hotel I did for helping me in a prototype. Outdoor scenario. A city. Another outdoor scenario. A warrior (unpublished character here) walking in a forest. Changelog: Reorganization of tile positions. Now they are all in a 32&#215;32 grid. [...]]]></description>
			<content:encoded><![CDATA[<p>Another version of the <a href="http://silveiraneto.net/tag/tileset">my free tileset project</a> with a lot of improvements.</p>
<p style="text-align: center;"><img class="size-full wp-image-2227 aligncenter" title="free tileset version 7" src="http://silveiraneto.net/wp-content/uploads/2009/02/free_tileset_version_7.png" alt="free tileset version 7" width="480" height="736" /></p>
<p><strong>Examples of usage:</strong></p>
<p>A hotel I did for helping me in a prototype.</p>
<p style="text-align: center;"><strong><img class="size-full wp-image-2228 aligncenter" title="Pixelart hotel" src="http://silveiraneto.net/wp-content/uploads/2009/02/hotel.png" alt="Pixelart hotel" width="640" height="640" /></strong></p>
<p>Outdoor scenario. A city.</p>
<p style="text-align: center;"><img class="size-full wp-image-2230 aligncenter" title="pixelart city" src="http://silveiraneto.net/wp-content/uploads/2009/02/city.png" alt="pixelart city" width="320" height="320" /></p>
<p>Another outdoor scenario. A warrior (<span style="text-decoration: line-through;">unpublished character</span> <a title="warrior char" href="http://silveiraneto.net/2009/03/29/warrior-my-free-charset-version-3/">here</a>) walking in a forest.</p>
<p style="text-align: center;"><strong><img class="size-full wp-image-2229 aligncenter" title="forest" src="http://silveiraneto.net/wp-content/uploads/2009/02/forest.png" alt="forest" width="289" height="251" /><br />
</strong></p>
<p><strong>Changelog:</strong></p>
<ul>
<li>Reorganization of tile positions. Now they are all in a 32&#215;32 grid.</li>
<li>
<div id="result_box" style="text-align: left;" dir="ltr">Shelf of drinks, two tables and chairs.</div>
</li>
<li>I placed some characters in this tileset just to help during the creation of prototypes. They should not be really used in maps.</li>
<li>Now is possible to create also outdoors scenarios:
<ul>
<li>Two buildings, streets, pedestrian crossing, sidewalks and a manhole cover.</li>
<li>A tree, cut tree and a bush.</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/02/02/my-free-tileset-version-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Game map edition using Tiled</title>
		<link>http://silveiraneto.net/2009/01/11/game-map-edition-using-tiled/</link>
		<comments>http://silveiraneto.net/2009/01/11/game-map-edition-using-tiled/#comments</comments>
		<pubDate>Sun, 11 Jan 2009 20:48:25 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Adam Turk]]></category>
		<category><![CDATA[Bjørn Lindeijer]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[game map]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[map]]></category>
		<category><![CDATA[map editor]]></category>
		<category><![CDATA[Mappy]]></category>
		<category><![CDATA[Pixelart]]></category>
		<category><![CDATA[Tiled]]></category>
		<category><![CDATA[tileset]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2085</guid>
		<description><![CDATA[Tiled is general purpose game map editor, with support of several map formats (XML, JSON), multi plataform and runs installed or from browser, supports plugins to read and write others map formats and all free (under GPL license). Installing You can lauch Tiled via Java Web Start or download it&#8217;s lastest version zip file. After [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-2146 aligncenter" title="Tiled logo" src="http://silveiraneto.net/wp-content/uploads/2009/01/logo.png" alt="Tiled logo" width="200" height="104" /></p>
<p><a href="http://mapeditor.org/">Tiled</a> is general purpose game map editor, with support of several map formats (XML, JSON), multi plataform and runs installed or from browser, supports plugins to read and write others map formats and all free (under GPL license).</p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2009/01/map_editor_tiles_tileset_game-deveopment.png"><img class="size-medium wp-image-2114 aligncenter" title="map editor tiles tileset game deveopment" src="http://silveiraneto.net/wp-content/uploads/2009/01/map_editor_tiles_tileset_game-deveopment-500x343.png" alt="map editor tiles tileset game deveopment" width="500" height="343" /></a></p>
<p><strong>Installing</strong></p>
<p>You can <a title="JNPL" href="http://mapeditor.org/tiled.jnlp">lauch Tiled via Java Web Start</a> or <a title="map editor download" href="http://mapeditor.org/downloads.html">download it&#8217;s lastest version</a> zip file. After download it just unzip it and run:</p>
<blockquote><p>java -jar tiled.jar</p></blockquote>
<p>Make sure you have at least Java 1.5 installed and configured.</p>
<p><strong>Creating a empty map</strong></p>
<p>After<strong> </strong>lauching it, open the menu <em>File</em> → <em>New</em> and create a new 10&#215;10 orthogonal map<strong> </strong>with 32&#215;32 tiles.</p>
<p style="text-align: center;"><strong><img class="size-full wp-image-2137 aligncenter" title="Tiled: New Map" src="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_new_map.png" alt="Tiled: New Map" width="314" height="223" /></strong></p>
<p>Like this one</p>
<p style="text-align: center;"><img class="size-medium wp-image-2140 aligncenter" title="tiled 10x10 map" src="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_10x10_map-500x366.png" alt="tiled 10x10 map" width="500" height="366" /></p>
<p><strong>Creating a tileset<br />
</strong></p>
<p>Now we need to add a tileset to start drawing a map. Let&#8217;s use this one</p>
<p style="text-align: center;"><img class="size-full wp-image-2141 aligncenter" title="batalhao tileset cc by sa" src="http://silveiraneto.net/wp-content/uploads/2009/01/batalhao_tileset_cc_by_sa.png" alt="batalhao tileset cc by sa" width="512" height="96" /></p>
<p>Save the tileset image above.  Open the menu <em>Tilesets</em> → <em>New Tileset </em>select<em> Reference tileset image </em>and browser to find the tileset image you saved. Keep tile width and height as 32 and tile spacing and margin as 0.</p>
<p style="text-align: center;"><img class="size-full wp-image-2143 aligncenter" title="tiled new tileset" src="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_new_tileset.png" alt="tiled new tileset" width="353" height="347" /></p>
<p>Notice a new tab on the <em>Tile palette</em> section.</p>
<p style="text-align: center;"><img class="size-full wp-image-2144 aligncenter" title="tiled tileset" src="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_tileset.png" alt="tiled tileset" width="574" height="178" /></p>
<p><strong>Working with layers<br />
</strong></p>
<p>Select the first grass tile from the tileset and select the  fill tool (<a href="http://silveiraneto.net/wp-content/uploads/2009/01/bucket.png"><img class="alignnone size-full wp-image-2149" title="bucket" src="http://silveiraneto.net/wp-content/uploads/2009/01/bucket.png" alt="bucket" width="22" height="22" /></a> icon) to create a grass field. Use the paint tool (<a href="http://silveiraneto.net/wp-content/uploads/2009/01/pencil.png"><img class="alignnone size-full wp-image-2150" title="pencil" src="http://silveiraneto.net/wp-content/uploads/2009/01/pencil.png" alt="pencil" width="22" height="22" /></a> icon) to add some stones and trees at random locations on grass. On the <em>Layers</em> section double click at <em>Layer Name</em> and put a name like &#8220;field&#8221;.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_field.png"><img class="size-medium wp-image-2145 aligncenter" title="tiled field" src="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_field-442x375.png" alt="tiled field" width="442" height="375" /></a></p>
<p>Now let&#8217;s create another layer to put the buildings and streets. We can do that by opening the menu<em> Layer</em> → <em>Add Layer</em> or just clicking the <img class="alignnone size-full wp-image-2147" title="new" src="http://silveiraneto.net/wp-content/uploads/2009/01/gnome-new.png" alt="new" width="16" height="16" /> icon on layer&#8217;s section. Let&#8217;s call it &#8220;city&#8221;.</p>
<p>Now build your city by selecting tiles on the palette and using the paint tool. There&#8217;s tiles for horizontal and vertical street and all kinds of intersection. For the building you can click and drag in the palette to select multiple tiles at once.</p>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_city.png"><img class="size-medium wp-image-2148 aligncenter" title="tiled city" src="http://silveiraneto.net/wp-content/uploads/2009/01/tiled_city-442x375.png" alt="tiled city" width="442" height="375" /></a></p>
<p><strong>Saving</strong></p>
<p>You can save the map as tmx (XML Tiled map file) , JSON, LUA, wlk, map (<a title="Mappy" href="http://www.tilemap.co.uk/mappy.php">Mappy</a>) or export it as a image. There&#8217;s some options accessible on the <em>Edit</em> → <em>Preferences</em> menu like use base-64  gziped encoding.</p>
<p>Thanks to Adam Turk and  Bjørn Lindeijer for developing that great project.</p>
<p>In a next post I want to show how to integrate this with a Java/JavaFX game.</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/01/11/game-map-edition-using-tiled/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>My Free Tileset, version 4</title>
		<link>http://silveiraneto.net/2008/12/22/my-free-tileset-version-4/</link>
		<comments>http://silveiraneto.net/2008/12/22/my-free-tileset-version-4/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 07:09:47 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[free culture]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[GPL]]></category>
		<category><![CDATA[open]]></category>
		<category><![CDATA[Pixelart]]></category>
		<category><![CDATA[sprites]]></category>
		<category><![CDATA[Tile Set]]></category>
		<category><![CDATA[tileset]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1983</guid>
		<description><![CDATA[Changelog: PNG alpha channel instead of white background. 70% alpha channel for shadows. Added a television that I forgot to put since first version.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-1982 aligncenter" title="GPL PixelArt TileSet Version 4" src="http://silveiraneto.net/wp-content/uploads/2008/12/silveira_neto_gpl_pixelart_tileset_version_4.png" alt="GPL PixelArt TileSet Version 4" width="391" height="570" /></p>
<p>Changelog:</p>
<ul>
<li>PNG alpha channel instead of white background.</li>
<li>70% alpha channel for shadows.</li>
<li>Added a television that I forgot to put since first version.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/12/22/my-free-tileset-version-4/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JavaFX, Simple Tile Set</title>
		<link>http://silveiraneto.net/2008/12/20/javafx-simple-tile-set/</link>
		<comments>http://silveiraneto.net/2008/12/20/javafx-simple-tile-set/#comments</comments>
		<pubDate>Sat, 20 Dec 2008 19:23:57 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[openjfx]]></category>
		<category><![CDATA[pixel art]]></category>
		<category><![CDATA[Tile Set]]></category>
		<category><![CDATA[tileset]]></category>
		<category><![CDATA[video game]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1951</guid>
		<description><![CDATA[Tile sets are a very simple way to draw scenarios with repeated elements. From simple to complex ones using a very low footprint. First step, load the png file that stores the tileset into a Image. The file tiles.png shoud be in the same directory of the source code. I adjusted some tiles from those [...]]]></description>
			<content:encoded><![CDATA[<p>Tile sets are a very simple way to draw scenarios with repeated elements. From simple to complex ones using a very low footprint.</p>
<p>First step, load the png file that stores the tileset into a <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.scene.image/javafx.scene.image.Image.html">Image</a>. The file tiles.png shoud be in the same directory of the source code. I adjusted some tiles from those tile set <a title="Tile set" href="http://silveiraneto.net/2008/08/31/my-free-tileset-version-2/">I&#8217;ve blogged here before</a> into a grid of 10&#215;10 tiles.</p>
<p style="text-align: center;"><img class="size-full wp-image-1955 aligncenter" title="Set of tiles, example" src="http://silveiraneto.net/wp-content/uploads/2008/12/tiles.png" alt="Set of tiles, example" width="320" height="320" /></p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">var tileset <span style="color: #339933;">=</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
   url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}tiles.png&quot;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Notice that each tile have 32 of height and 32 of width. We will assume this and use theses numbers when performing calculations to find a single tile in our tile set.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">def w <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;
def h <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;</pre>
</div>
</div>
<p>To display a Image in the screen we use a <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.scene.image/javafx.scene.image.ImageView.html">ImageView</a> node. A ImageView can have a viewport property to create crop or zoom effect. A viewport is just a <a href="http://java.sun.com/javafx/1/docs/api/javafx.geometry/javafx.geometry.Rectangle2D.html">Rectangle2D</a>, a object with position (minX and minY), height and width. If we want to display the first tile in the tileset we do</p>
<p style="text-align: center;"><img class="size-full wp-image-1956 aligncenter" title="first tile" src="http://silveiraneto.net/wp-content/uploads/2008/12/first_tile.png" alt="first tile" width="32" height="32" /></p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">ImageView <span style="color: #009900;">&#123;</span>
   image<span style="color: #339933;">:</span> tileset
   viewport<span style="color: #339933;">:</span> <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
      minX<span style="color: #339933;">:</span> 0, minY<span style="color: #339933;">:</span> 0, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Notice that the minX determines the column and minY the row in the tileset. The first row is 0*32, the second row is 1*32 and so on. If we want to display the tile at the second line and third column of the tileset we do</p>
<p style="text-align: center;"><img class="size-full wp-image-1957 aligncenter" title="another_tile" src="http://silveiraneto.net/wp-content/uploads/2008/12/another_tile.png" alt="another_tile" width="32" height="32" /></p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">ImageView <span style="color: #009900;">&#123;</span>
   image<span style="color: #339933;">:</span> tileset
   viewport<span style="color: #339933;">:</span> <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
      minX<span style="color: #339933;">:</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">32</span> , minY<span style="color: #339933;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">32</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Those properties in a Rectangle2D are for init and read only. So I created a list with all Rectangles I can need for use as a viewport.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">def viewports <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
           minX<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, minY<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h, height<span style="color: #339933;">:</span> w, width<span style="color: #339933;">:</span> h
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>The scenario map is stored in another list. The first element of the list is 7, that is, the first tile in the scenario is the 7th tile from the tile set.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">var map <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #cc66cc;">7</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">8</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">41</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">23</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">36</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">51</span>, <span style="color: #cc66cc;">34</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">34</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">57</span>, <span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">44</span>, <span style="color: #cc66cc;">45</span>, <span style="color: #cc66cc;">46</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">35</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">27</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">55</span>, <span style="color: #cc66cc;">56</span>,  <span style="color: #cc66cc;">5</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">38</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">60</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">47</span>, <span style="color: #cc66cc;">48</span>, <span style="color: #cc66cc;">15</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">61</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">70</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">33</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">71</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">49</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">17</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>, <span style="color: #cc66cc;">18</span>,
<span style="color: #009900;">&#93;</span>;</pre>
</div>
</div>
<p>Finally to create a scenario with 100 tiles, 10 per row and with 10 rows, in a list called <em>tiles</em>. Each iteration of this loop creates a <em>ImageView</em>. Each <em>ImageView</em> will store a single tile. We get the tile number in the <em>map</em> list and so use it to index the <em>viewports</em> list.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">var tiles <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      ImageView <span style="color: #009900;">&#123;</span>
         x<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, y<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h,
         viewport<span style="color: #339933;">:</span> bind viewports<span style="color: #009900;">&#91;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>
         image<span style="color: #339933;">:</span> tileset
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Additionally I added two things to transform this program also in a (extremely)  simple map editor. At each <em>ImageView</em> I added a callback for <em>onMouseClicked</em> event. When you click on a tile, it changes its <em>map</em> position, ie, the tile. The next tile for the left button and the last tile for any other button.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">onMouseClicked<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span> e<span style="color: #339933;">:</span> <span style="color: #003399;">MouseEvent</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
   var amount <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">button</span> <span style="color: #339933;">==</span> MouseButton.<span style="color: #006633;">PRIMARY</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span>;
   map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> amount<span style="color: #009900;">&#41;</span> mod <span style="color: #cc66cc;">100</span>;
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>The other thing is to print the <em>map</em> list when the program is over. There is the full program:</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">tileeditor</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.stage.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Scene</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.ImageView</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.Image</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.CustomNode</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Group</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Node</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.geometry.Rectangle2D</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.input.MouseEvent</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.input.MouseButton</span>;
&nbsp;
def w <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;
def h <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span>;
&nbsp;
var map <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
    <span style="color: #cc66cc;">7</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">8</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">26</span>, <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">41</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">23</span>, <span style="color: #cc66cc;">24</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">36</span>, <span style="color: #cc66cc;">50</span>, <span style="color: #cc66cc;">51</span>, <span style="color: #cc66cc;">34</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">34</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">57</span>, <span style="color: #cc66cc;">58</span>, <span style="color: #cc66cc;">44</span>, <span style="color: #cc66cc;">45</span>, <span style="color: #cc66cc;">46</span>,  <span style="color: #cc66cc;">2</span>,  <span style="color: #cc66cc;">2</span>, <span style="color: #cc66cc;">35</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">27</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">6</span>, <span style="color: #cc66cc;">55</span>, <span style="color: #cc66cc;">56</span>,  <span style="color: #cc66cc;">5</span>,  <span style="color: #cc66cc;">3</span>,  <span style="color: #cc66cc;">3</span>, <span style="color: #cc66cc;">38</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">60</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">47</span>, <span style="color: #cc66cc;">48</span>, <span style="color: #cc66cc;">15</span>, <span style="color: #cc66cc;">13</span>, <span style="color: #cc66cc;">61</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">70</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">33</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">71</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">19</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>,  <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">49</span>, <span style="color: #cc66cc;">19</span>,
   <span style="color: #cc66cc;">17</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>,  <span style="color: #cc66cc;">9</span>, <span style="color: #cc66cc;">18</span>,
<span style="color: #009900;">&#93;</span>;
&nbsp;
var tileset <span style="color: #339933;">=</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>
    url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}tiles.png&quot;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
def viewports <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #003399;">Rectangle2D</span><span style="color: #009900;">&#123;</span>
           minX<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, minY<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h, height<span style="color: #339933;">:</span> w, width<span style="color: #339933;">:</span> h
       <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
var tiles <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>row in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>col in <span style="color: #009900;">&#91;</span>0..9<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      ImageView <span style="color: #009900;">&#123;</span>
         x<span style="color: #339933;">:</span> col <span style="color: #339933;">*</span> w, y<span style="color: #339933;">:</span> row <span style="color: #339933;">*</span> h,
         viewport<span style="color: #339933;">:</span> bind viewports<span style="color: #009900;">&#91;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span>
         image<span style="color: #339933;">:</span> tileset
&nbsp;
         onMouseClicked<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span> e<span style="color: #339933;">:</span> <span style="color: #003399;">MouseEvent</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span><span style="color: #003399;">Void</span> <span style="color: #009900;">&#123;</span>
            var amount <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">button</span> <span style="color: #339933;">==</span> MouseButton.<span style="color: #006633;">PRIMARY</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#125;</span>;
            map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#91;</span>row <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> col<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> amount<span style="color: #009900;">&#41;</span> mod <span style="color: #cc66cc;">100</span>;
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
Stage <span style="color: #009900;">&#123;</span>
    title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;JavaFX Simple Tile Editor&quot;</span>
    scene<span style="color: #339933;">:</span> Scene <span style="color: #009900;">&#123;</span>
        content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> tiles <span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span>
    onClose<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        println<span style="color: #009900;">&#40;</span>map<span style="color: #009900;">&#41;</span>;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Here is the result for that<em> map</em></p>
<p style="text-align: center;"><img class="size-full wp-image-1961 aligncenter" title="tlemap javafx" src="http://silveiraneto.net/wp-content/uploads/2008/12/tilemap_javafx.png" alt="tlemap javafx" width="320" height="320" /></p>
<p>And you can try it yourself in your browser.<strong> <a title="Simple Tile Editor Online" href="http://silveiraneto.net/downloads/SimpleTileEditor/dist/JavaFxSandBox.html">Play it online now</a></strong>.</p>
<p>Here is a video of it working</p>
<p style="text-align: center;"><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/lxuBEoItB5E&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/lxuBEoItB5E&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></object></p>
<p><strong>Downloads:</strong></p>
<ul>
<li>Complete source code and project in NetBeans, <a title="Simple Tile Editor" href="http://silveiraneto.net/downloads/SimpleTileEditor.tar.bz2">SimpleTileEditor.tar.bz2</a>.</li>
<li>Video of it working, <a title="OGG Video" href="http://silveiraneto.net/downloads/javafx_tile_set.ogv">javafx_tile_set.ogv</a>.</li>
<li>Program main class, <a title="Main class" href="http://silveiraneto.net/downloads/SimpleTileEditor/src/tileeditor/Main.fx">Main.fx</a>.</li>
</ul>
<p><strong>Possibilities</strong></p>
<p>We are using just  a image that can handle 100 tiles, <a href="ttp://silveiraneto.net/wp-content/uploads/2008/12/tiles.png">tiles.png</a> with less than 30Kb. The map is also composed with 100 tiles. Each tile we can choose between 100 different tiles, so we can compose 10<sup>100</sup> different maps (one <a title="Wikipedia, english" href="http://en.wikipedia.org/wiki/Googol">googol</a><sup>10</sup> ). Most of them are useless and without any sense, but some are cool. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/12/20/javafx-simple-tile-set/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaFX, how to create a rpg like game</title>
		<link>http://silveiraneto.net/2008/12/08/javafx-how-to-create-a-rpg-like-game/</link>
		<comments>http://silveiraneto.net/2008/12/08/javafx-how-to-create-a-rpg-like-game/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 07:38:04 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[applet]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[game development]]></category>
		<category><![CDATA[gamedev]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Web Start]]></category>
		<category><![CDATA[JavaFX]]></category>
		<category><![CDATA[jfx]]></category>
		<category><![CDATA[ogv]]></category>
		<category><![CDATA[openjfx]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1861</guid>
		<description><![CDATA[JavaFX 1.0 is out and there are tons of new cool features, specially for game development.trans I&#8217;ll show in this tutorial how to create a very simple demo that shows how to load imtrages, handle sprites, collisions and keyboard events that you can use to create a game with a old school rpg like vision. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://javafx.com">JavaFX 1.0</a> is out and there are tons of new cool features, specially for game development.trans</p>
<p>I&#8217;ll show in this tutorial how to create a very simple demo that shows how to load imtrages, handle sprites, collisions and keyboard events that you can use to create a game with a old school rpg like vision.</p>
<p>For the background scenario I&#8217;m using the house <a title="My Free Tileset version 2" href="http://silveiraneto.net/2008/08/31/my-free-tileset-version-2/">that I drew</a> and we&#8217;ll call as <strong>house.png</strong>.</p>
<p style="text-align: center;"><a title="Pixelart home" href="http://silveiraneto.net/wp-content/uploads/2008/08/silveira_neto_gpl_pixelart_kitchen_home1.png"><img class="size-full wp-image-1190 aligncenter" title="House pixelart free GPL" src="../wp-content/uploads/2008/08/silveira_neto_gpl_pixelart_kitchen_home1.png" alt="" width="416" height="384" /></a></p>
<p>That we load as a <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.scene.image/javafx.scene.image.Image.html">Image</a> and place into a <a title="JavaFX API" href="http://java.sun.com/javafx/1/docs/api/javafx.scene.image/javafx.scene.image.ImageView.html">ImageView</a>.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">ImageView<span style="color: #009900;">&#123;</span>
   image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}house.png&quot;</span><span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>For the character I&#8217;m using the last character I drew, <a title="The Nerdy Guy" href="http://silveiraneto.net/2008/12/07/nerdy-guy-my-free-charset-version-2/">the nerdy guy</a>.</p>
<p style="text-align: center;"><img class="size-full wp-image-1863 aligncenter" title="nerdyguy creative commons att share alike" src="../wp-content/uploads/2008/12/nerdyguy_from_silveiranetonet_creativecommons_att_share_alike.png" alt="" width="101" height="183" /></p>
<p>To make the animation easier, I spited it into 9 pieces:</p>
<p><strong>down0.png</strong>, <strong>down1.png</strong> and <strong>down2.png</strong></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/12/down0.png"><img class="alignnone size-full wp-image-1867" title="down0" src="http://silveiraneto.net/wp-content/uploads/2008/12/down0.png" alt="" width="30" height="39" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/down1.png"><img class="alignnone size-full wp-image-1868" title="down1" src="http://silveiraneto.net/wp-content/uploads/2008/12/down1.png" alt="" width="30" height="39" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/down2.png"><img class="alignnone size-full wp-image-1869" title="down2" src="http://silveiraneto.net/wp-content/uploads/2008/12/down2.png" alt="" width="30" height="39" /></a></p>
<p><strong>left0.png</strong>, <strong>left1.png</strong> and <strong>left2.png</strong></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/12/left0.png"><img class="alignnone size-full wp-image-1874" title="left0" src="http://silveiraneto.net/wp-content/uploads/2008/12/left0.png" alt="" width="30" height="39" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/left1.png"><img class="alignnone size-full wp-image-1875" title="left1" src="http://silveiraneto.net/wp-content/uploads/2008/12/left1.png" alt="" width="30" height="39" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/left2.png"><img class="alignnone size-full wp-image-1876" title="left2" src="http://silveiraneto.net/wp-content/uploads/2008/12/left2.png" alt="" width="30" height="39" /></a></p>
<p><strong>right0.png</strong>, <strong>right1.png</strong> and <strong>righ2.png</strong></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/12/right0.png"><img class="alignnone size-full wp-image-1872" title="right0" src="http://silveiraneto.net/wp-content/uploads/2008/12/right0.png" alt="" width="30" height="40" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/right1.png"><img class="alignnone size-full wp-image-1873" title="right1" src="http://silveiraneto.net/wp-content/uploads/2008/12/right1.png" alt="" width="30" height="40" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/right2.png"><img class="alignnone size-medium wp-image-1872" title="right2" src="http://silveiraneto.net/wp-content/uploads/2008/12/right2.png" alt="" width="30" height="40" /></a></p>
<p><strong>up0.png</strong>,<strong> up1.png </strong>and <strong>up2.png</strong></p>
<p><a href="http://silveiraneto.net/wp-content/uploads/2008/12/up0.png"><img class="alignnone size-full wp-image-1877" title="up0" src="http://silveiraneto.net/wp-content/uploads/2008/12/up0.png" alt="" width="30" height="40" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/up1.png"><img class="alignnone size-full wp-image-1878" title="up1" src="http://silveiraneto.net/wp-content/uploads/2008/12/up1.png" alt="" width="30" height="40" /></a> <a href="http://silveiraneto.net/wp-content/uploads/2008/12/up2.png"><img class="alignnone size-full wp-image-1879" title="up2" src="http://silveiraneto.net/wp-content/uploads/2008/12/up2.png" alt="" width="30" height="40" /></a></p>
<blockquote><p><img class="alignnone size-full wp-image-1881" title="warning" src="http://silveiraneto.net/wp-content/uploads/2008/12/dialog-warning.png" alt="" width="16" height="16" /> All images I&#8217;m using should be in the same directory of source code.</p></blockquote>
<p>Let&#8217;s start loading the scenario and a single character sprite.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.stage.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.Scene</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.*</span>;
&nbsp;
Stage <span style="color: #009900;">&#123;</span>
   title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;RPG-like demo&quot;</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">424</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">412</span>
   visible<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
   scene<span style="color: #339933;">:</span> Scene<span style="color: #009900;">&#123;</span>
      content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
         ImageView<span style="color: #009900;">&#123;</span>
         image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}house.png&quot;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>,
         ImageView<span style="color: #009900;">&#123;</span>
            x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">320</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">80</span>
            image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}down1.png&quot;</span><span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#93;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>Saved as Game.fx you can compile and run with in your terminal:</p>
<blockquote><p>$ javafxc Game.fx</p>
<p>$ javafx Game</p></blockquote>
<p style="text-align: center;"><a href="http://silveiraneto.net/wp-content/uploads/2008/12/screenshot1.png"><img class="size-full wp-image-1883 aligncenter" title="javafx rpg like game demo" src="http://silveiraneto.net/wp-content/uploads/2008/12/screenshot1.png" alt="" width="451" height="433" /></a></p>
<blockquote><p><img class="alignnone size-full wp-image-1881" title="warning" src="http://silveiraneto.net/wp-content/uploads/2008/12/dialog-warning.png" alt="" width="16" height="16" /> <strong>Hint:</strong> You can use <a title="JavaFX Downloads" href="http://javafx.com/downloads">NetBeans 6.5 JavaFX plugin</a> to easier the JavaFX development.</p></blockquote>
<p>To put animation on the character we load all sprites into four lists. Each list for each direction.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// sprites</span>
def up    <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}up{i}.png&quot;</span>    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
def right <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}right{i}.png&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
def down  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}down{i}.png&quot;</span>  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
def left  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}left{i}.png&quot;</span>  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>And create vars to store the character position and frame of animation.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;">var frame <span style="color: #339933;">=</span> 0;
var posx <span style="color: #339933;">=</span> <span style="color: #cc66cc;">320</span>;
var posy <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span>;</pre>
</div>
</div>
<p>Also store the house background.</p>
<pre>// house background
def house = ImageView{ image: Image {url: "{__DIR__}house.png"} };</pre>
<p>I create booleans to store some key states and at each interval of time I see how they are and do something about. You can handle keyboard event with less code but I like this way because keep visual and game logics a little bit more separated.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// keyboard</span>
var    upkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var rightkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var  downkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var  leftkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// player</span>
var player <span style="color: #339933;">=</span> ImageView<span style="color: #009900;">&#123;</span>
   x<span style="color: #339933;">:</span> bind posx y<span style="color: #339933;">:</span> bind posy
   image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}down1.png&quot;</span><span style="color: #009900;">&#125;</span>
   onKeyPressed<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">KeyEvent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      downkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_UP</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         upkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_LEFT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         leftkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_RIGHT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         rightkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// onKeyPressed</span>
&nbsp;
   onKeyReleased<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span> <span style="color: #003399;">KeyEvent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         downkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_UP</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         upkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_LEFT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         leftkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_RIGHT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         rightkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// onKeyReleased</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>See a video of the game working so far:</p>
<p style="text-align: center;"><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/Xv5z-9LGuOc&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/Xv5z-9LGuOc&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></object></p>
<p>Now we will add collisions. In a <a href="http://silveiraneto.net/2008/10/30/javafx-rectangular-collision-detection/">previous post</a> I showed some math behind bounding box game collisions. The good news are that you no longer need to worry about that. There are a lot of API improvements in JavaFX 1.0 that do all the hard work for you, specially the new classes on javafx.geometry package, <a href="http://java.sun.com/javafx/1/docs/api/javafx.geometry/javafx.geometry.Rectangle2D.html">Rectangle2D</a> and <a href="http://java.sun.com/javafx/1/docs/api/javafx.geometry/javafx.geometry.Point2D.html">Point2D</a>.</p>
<p>We create rectangles that represent the obstacles in the house.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// collidable obstacles</span>
def obstacles <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">382</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">414</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">384</span> y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">382</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">224</span> y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">288</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">288</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">96</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">352</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">352</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">224</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">320</span> width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">96</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">250</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">250</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">255</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">170</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">257</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">288</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">320</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">352</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">295</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">60</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">327</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">23</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
<span style="color: #009900;">&#93;</span>;</pre>
</div>
</div>
<p style="text-align: center;"><img class="size-full wp-image-1887 aligncenter" title="bounding boxes" src="http://silveiraneto.net/wp-content/uploads/2008/12/boundingboxes.png" alt="" width="416" height="384" /></p>
<p>We just have to change a little bit the game logics in order to handle collisions.</p>
<p style="text-align: center;"><img class="size-full wp-image-1889 aligncenter" title="boudingbox" src="http://silveiraneto.net/wp-content/uploads/2008/12/boudingbox.png" alt="" width="200" height="260" /></p>
<p>We define a bounding box around the player, it&#8217;s a rectangle from (4, 25) at the player coordinates system and with width 19 and height 10. The idea is to prospect where the player will be in the next step, see if it&#8217;s bouding box don&#8217;t collide with any obstacle and so pass it to the real game position.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// game logics</span>
var gamelogics <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
   repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
   keyFrames<span style="color: #339933;">:</span> KeyFrame <span style="color: #009900;">&#123;</span>
      time <span style="color: #339933;">:</span> 1s<span style="color: #339933;">/</span><span style="color: #cc66cc;">8</span>
      action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         var nextposx <span style="color: #339933;">=</span> posx;
         var nextposy <span style="color: #339933;">=</span> posy;
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>downkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposy <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> down<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>upkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposy <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> up<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>rightkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposx <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> right<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>leftkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposx <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> left<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>obst in obstacles<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>obst.<span style="color: #006633;">boundsInLocal</span>.<span style="color: #006633;">intersects</span><span style="color: #009900;">&#40;</span>nextposx <span style="color: #339933;">+</span> <span style="color: #cc66cc;">4</span>, nextposy <span style="color: #339933;">+</span> <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #000000; font-weight: bold;">return</span>;
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
         posx <span style="color: #339933;">=</span> nextposx;
         posy <span style="color: #339933;">=</span> nextposy;
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p>This is enough to do the trick but I also added a way to smoothly show the obstacles when pressing the space key.</p>
<p style="text-align: center;"><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/k-MHh6irvwE&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/k-MHh6irvwE&amp;rel=0&amp;color1=0x3a3a3a&amp;color2=0x999999" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></object></p>
<p>Here is the complete source code.</p>
<div class="wp_syntax">
<div class="code">
<pre class="java java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">Game</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.stage.Stage</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.image.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.input.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.paint.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.scene.shape.*</span>;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javafx.animation.*</span>;
&nbsp;
var frame <span style="color: #339933;">=</span> 0;
var posx <span style="color: #339933;">=</span> <span style="color: #cc66cc;">320</span>;
var posy <span style="color: #339933;">=</span> <span style="color: #cc66cc;">80</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// sprites</span>
def up    <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}up{i}.png&quot;</span>    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
def right <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}right{i}.png&quot;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
def down  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}down{i}.png&quot;</span>  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
def left  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>i in <span style="color: #009900;">&#91;</span>0..2<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}left{i}.png&quot;</span>  <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// house background</span>
def house <span style="color: #339933;">=</span> ImageView<span style="color: #009900;">&#123;</span> image<span style="color: #339933;">:</span> <span style="color: #003399;">Image</span> <span style="color: #009900;">&#123;</span>url<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;{__DIR__}house.png&quot;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// keyboard</span>
var    upkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var rightkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var  downkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
var  leftkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// player</span>
var player <span style="color: #339933;">=</span> ImageView<span style="color: #009900;">&#123;</span>
   x<span style="color: #339933;">:</span> bind posx y<span style="color: #339933;">:</span> bind posy image<span style="color: #339933;">:</span> down<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span>
   onKeyPressed<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span><span style="color: #003399;">KeyEvent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         downkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_UP</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         upkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_LEFT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         leftkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_RIGHT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         rightkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span>;
      <span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_SPACE</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>fade<span style="color: #339933;">==</span><span style="color: #cc66cc;">0.0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         	fadein.<span style="color: #006633;">playFromStart</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>fade<span style="color: #339933;">==</span><span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				fadeout.<span style="color: #006633;">playFromStart</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// onKeyPressed</span>
&nbsp;
   onKeyReleased<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span>e<span style="color: #339933;">:</span> <span style="color: #003399;">KeyEvent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         downkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_UP</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         upkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_LEFT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         leftkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">code</span> <span style="color: #339933;">==</span> KeyCode.<span style="color: #006633;">VK_RIGHT</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         rightkey <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">false</span>;
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">// onKeyReleased</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// collidable obstacles</span>
def obstacles <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">382</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">414</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">384</span> y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">382</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">224</span> y<span style="color: #339933;">:</span>   0 width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">288</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">288</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">96</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>   0 y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">352</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">352</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">224</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">320</span> width<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">RED</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">96</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">128</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">250</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">64</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">250</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">255</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">200</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">170</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">20</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">257</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">288</span> y<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">320</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">192</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span> <span style="color: #cc66cc;">352</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">295</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">32</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">60</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
	<span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>  <span style="color: #cc66cc;">32</span> y<span style="color: #339933;">:</span> <span style="color: #cc66cc;">327</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">64</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">23</span> stroke<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">YELLOW</span> <span style="color: #009900;">&#125;</span>,
<span style="color: #009900;">&#93;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// game logics</span>
var gamelogics <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
   repeatCount<span style="color: #339933;">:</span> Timeline.<span style="color: #006633;">INDEFINITE</span>
   keyFrames<span style="color: #339933;">:</span> KeyFrame <span style="color: #009900;">&#123;</span>
      time <span style="color: #339933;">:</span> 1s<span style="color: #339933;">/</span><span style="color: #cc66cc;">8</span>
      action<span style="color: #339933;">:</span> function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
         var nextposx <span style="color: #339933;">=</span> posx;
         var nextposy <span style="color: #339933;">=</span> posy;
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>downkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposy <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> down<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>upkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposy <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> up<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>rightkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposx <span style="color: #339933;">+=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> right<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>leftkey<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            nextposx <span style="color: #339933;">-=</span> <span style="color: #cc66cc;">5</span>;
            player.<span style="color: #006633;">image</span> <span style="color: #339933;">=</span> left<span style="color: #009900;">&#91;</span><span style="color: #339933;">++</span>frame mod <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span>;
         <span style="color: #009900;">&#125;</span>
         <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>obst in obstacles<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>obst.<span style="color: #006633;">boundsInLocal</span>.<span style="color: #006633;">intersects</span><span style="color: #009900;">&#40;</span>nextposx <span style="color: #339933;">+</span> <span style="color: #cc66cc;">4</span>, nextposy <span style="color: #339933;">+</span> <span style="color: #cc66cc;">25</span>, <span style="color: #cc66cc;">19</span>, <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #000000; font-weight: bold;">return</span>;
            <span style="color: #009900;">&#125;</span>
         <span style="color: #009900;">&#125;</span>
         posx <span style="color: #339933;">=</span> nextposx;
         posy <span style="color: #339933;">=</span> nextposy;
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
gamelogics.<span style="color: #006633;">play</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// obstacles view</span>
var fade <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0.0</span>;
&nbsp;
var obstacleslayer <span style="color: #339933;">=</span> <span style="color: #003399;">Group</span> <span style="color: #009900;">&#123;</span>
   opacity<span style="color: #339933;">:</span> bind fade
   content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
      <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span> x<span style="color: #339933;">:</span>0 y<span style="color: #339933;">:</span>0 width<span style="color: #339933;">:</span><span style="color: #cc66cc;">500</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">500</span> fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span> <span style="color: #009900;">&#125;</span>,
      obstacles,
      <span style="color: #003399;">Rectangle</span> <span style="color: #009900;">&#123;</span>
        x<span style="color: #339933;">:</span> bind posx <span style="color: #339933;">+</span> <span style="color: #cc66cc;">4</span> y<span style="color: #339933;">:</span> bind posy <span style="color: #339933;">+</span> <span style="color: #cc66cc;">25</span> width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">19</span> height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">10</span>
        fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">LIME</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
var fadein <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
	keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
   	at <span style="color: #009900;">&#40;</span>0s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>fade <span style="color: #339933;">=&amp;</span>gt; <span style="color: #cc66cc;">0.0</span><span style="color: #009900;">&#125;</span>
   	at <span style="color: #009900;">&#40;</span>1s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>fade <span style="color: #339933;">=&amp;</span>gt; <span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
var fadeout <span style="color: #339933;">=</span> Timeline <span style="color: #009900;">&#123;</span>
	keyFrames<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>
   	at <span style="color: #009900;">&#40;</span>0s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>fade <span style="color: #339933;">=&amp;</span>gt; <span style="color: #cc66cc;">1.0</span><span style="color: #009900;">&#125;</span>
   	at <span style="color: #009900;">&#40;</span>1s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>fade <span style="color: #339933;">=&amp;</span>gt; <span style="color: #cc66cc;">0.0</span><span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// game stage</span>
Stage <span style="color: #009900;">&#123;</span>
	title<span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;RPG-like demo&quot;</span>, width<span style="color: #339933;">:</span> <span style="color: #cc66cc;">424</span>, height<span style="color: #339933;">:</span> <span style="color: #cc66cc;">412</span>
	visible<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">true</span>
	scene<span style="color: #339933;">:</span> Scene<span style="color: #009900;">&#123;</span>
      fill<span style="color: #339933;">:</span> <span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span>
		content<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span>house, player, obstacleslayer<span style="color: #009900;">&#93;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre>
</div>
</div>
<p><strong>Play Through Java Web Start<br />
</strong></p>
<p style="text-align: center;"><a title="Click to launch" href="http://silveiraneto.net/downloads/nerdy/dist/Nerdy.jnlp"><img class="size-full wp-image-1474 aligncenter" title="webstart" src="../wp-content/uploads/2008/10/webstart.png" alt="" width="88" height="23" /></a></p>
<p>or <a title="Applet Game" href="http://silveiraneto.net/downloads/nerdy/dist/Nerdy.html">click here to play via applet</a>, inside your browser.</p>
<p><small><strong>update: </strong>The applet version and Java Web Start versions should be working now.  The applet version on Linux seems to be having problems with the keyboard handling, use the Java Web Start version while I&#8217;m trying to fix it.</small></p>
<p><strong>Downloads:</strong></p>
<ul>
<li>Source, images and jars, <a title="Zipball with sources and images" href="http://silveiraneto.net/downloads/nerdy.zip">nerdy.zip</a></li>
<li><a title="Nerdy Game" href="http://silveiraneto.net/downloads/nerdy/">All content</a></li>
<li>First video, <a title="OGG Video" href="http://silveiraneto.net/downloads/javafx_nerdy_without_collision.ogv">javafx_nerdy_without_collision.ogv</a></li>
<li>Second video, <a title="OGG Video" href="http://silveiraneto.net/downloads/javafx_nerdy.ogv">javafx_nerdy.ogv</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/12/08/javafx-how-to-create-a-rpg-like-game/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

