<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.gideros.rocks/index.php?action=history&amp;feed=atom&amp;title=Article_Tutorials%2FSquare_Dodge</id>
	<title>Article Tutorials/Square Dodge - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.gideros.rocks/index.php?action=history&amp;feed=atom&amp;title=Article_Tutorials%2FSquare_Dodge"/>
	<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;action=history"/>
	<updated>2026-11-17T15:30:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=23588&amp;oldid=prev</id>
		<title>MoKaLux at 09:54, 26 August 2024</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=23588&amp;oldid=prev"/>
		<updated>2024-08-26T09:54:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;a href=&quot;https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;amp;diff=23588&amp;amp;oldid=22984&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=22984&amp;oldid=prev</id>
		<title>MoKaLux at 17:14, 13 November 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=22984&amp;oldid=prev"/>
		<updated>2023-11-13T17:14:10Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 17:14, 13 November 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;__TOC__&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Displaying Images ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Displaying Images ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It’s time to put all of your knowledge together and actually make something worthwhile.  We’ll start off with a few functions and build it up to a fully-fledged, fun game!&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It’s time to put all of your knowledge together and actually make something worthwhile.  We’ll start off with a few functions and build it up to a fully-fledged, fun game!&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=22975&amp;oldid=prev</id>
		<title>MoKaLux at 16:56, 13 November 2023</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=22975&amp;oldid=prev"/>
		<updated>2023-11-13T16:56:14Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:56, 13 November 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l5&quot;&gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a new project. I called mine “Square Dodge”.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a new project. I called mine “Square Dodge”.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Download the code and all resources for this post from [https://github.com/plicatibu/gideros_external_tutorials/tree/master/bluebilby.com_2013-05-08_gideros-mobile-tutorial-creating-your-first-game here]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Download the code and all resources for this post from &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/ins&gt;[https://github.com/plicatibu/gideros_external_tutorials/tree/master/bluebilby.com_2013-05-08_gideros-mobile-tutorial-creating-your-first-game here]&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Square Dodge source code. (3.8 Mb)&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Square Dodge source code. (3.8 Mb)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l14&quot;&gt;Line 14:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 14:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The code below is heavily commented to help you understand how each part works.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The code below is heavily commented to help you understand how each part works.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Square Dodge by Jason Oakley (C) 2013 Blue Bilby&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;-- Square Dodge by Jason Oakley (C) 2013 Blue Bilby&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l771&quot;&gt;Line 771:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 770:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Next, we’ll go into more complex programming and explore some third-party applications to help make your game developing easier.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Next, we’ll go into more complex programming and explore some third-party applications to help make your game developing easier.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &#039;&#039;&#039;Note: This tutorial was written by [http://bluebilby.com/author/waulokadmin/ Jason Oakley] and was originally available here: http://bluebilby.com/2013/05/08/gideros-mobile-tutorial-creating-your-first-game/&#039;&#039;&#039;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Note:&lt;/del&gt;&#039;&#039;&#039; &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;This tutorial was written by [http://bluebilby.com/author/waulokadmin/ Jason Oakley] and was originally available here: http://bluebilby.com/2013/05/08/gideros-mobile-tutorial-creating-your-first-game/.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Written Tutorials]]&lt;/ins&gt;&#039;&#039;&#039;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;{{GIDEROS IMPORTANT LINKS}}&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=16949&amp;oldid=prev</id>
		<title>MoKaLux: formatting</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=16949&amp;oldid=prev"/>
		<updated>2020-08-16T22:44:35Z</updated>

		<summary type="html">&lt;p&gt;formatting&lt;/p&gt;
&lt;a href=&quot;https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;amp;diff=16949&amp;amp;oldid=14257&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>MoKaLux</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=14257&amp;oldid=prev</id>
		<title>Plicatibu at 22:57, 3 December 2019</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=14257&amp;oldid=prev"/>
		<updated>2019-12-03T22:57:24Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:57, 3 December 2019&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l5&quot;&gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a new project. I called mine “Square Dodge”.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Create a new project. I called mine “Square Dodge”.&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Download the code and all resources for this post from:  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Download the code and all resources for this post from &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[https&lt;/ins&gt;:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;//github.com/plicatibu/gideros_external_tutorials/tree/master/bluebilby.com_2013-05-08_gideros-mobile-tutorial-creating-your-first-game here]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Square Dodge source code. (3.8 Mb)&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Square Dodge source code. (3.8 Mb)&amp;lt;br&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Plicatibu</name></author>
	</entry>
	<entry>
		<id>https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=13867&amp;oldid=prev</id>
		<title>Plicatibu: Created page with &quot;== Displaying Images ==  It’s time to put all of your knowledge together and actually make something worthwhile.  We’ll start off with a few functions and build it up to a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.gideros.rocks/index.php?title=Article_Tutorials/Square_Dodge&amp;diff=13867&amp;oldid=prev"/>
		<updated>2019-12-03T01:12:45Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Displaying Images ==  It’s time to put all of your knowledge together and actually make something worthwhile.  We’ll start off with a few functions and build it up to a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Displaying Images ==&lt;br /&gt;
&lt;br /&gt;
It’s time to put all of your knowledge together and actually make something worthwhile.  We’ll start off with a few functions and build it up to a fully-fledged, fun game!&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a new project. I called mine “Square Dodge”.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the code and all resources for this post from: &lt;br /&gt;
&lt;br /&gt;
Square Dodge source code. (3.8 Mb)&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Don’t forget to import your audio and image assets!&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Jason-Oakley-Creating-Your-First-Game-Square-Dodge-project.png|thumb|center]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The code below is heavily commented to help you understand how each part works.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Square Dodge by Jason Oakley (C) 2013 Blue Bilby&lt;br /&gt;
-- Define our variables and tables as local to save memory&lt;br /&gt;
local score&lt;br /&gt;
local hiScore&lt;br /&gt;
local enemyShape = {}&lt;br /&gt;
local player&lt;br /&gt;
local isGameRunning&lt;br /&gt;
local scoreText&lt;br /&gt;
local hiScoreText&lt;br /&gt;
local MINNUMBEROFENEMIES = 7&lt;br /&gt;
local MAXNUMBEROFENEMIES = 101&lt;br /&gt;
local numberOfEnemies = MINNUMBEROFENEMIES&lt;br /&gt;
local enemyCountdown&lt;br /&gt;
local MAXCOUNTDOWN = 500&lt;br /&gt;
local gameoverImg&lt;br /&gt;
-- Cache math.random to make access faster&lt;br /&gt;
local rnd = math.random&lt;br /&gt;
-- Functions begin here&lt;br /&gt;
-- Load high score if it exists&lt;br /&gt;
local function loadScore()&lt;br /&gt;
    local file = io.open(&amp;quot;|D|settings.txt&amp;quot;, &amp;quot;r&amp;quot;)&lt;br /&gt;
    if not file then&lt;br /&gt;
        hiScore = 0&lt;br /&gt;
    else&lt;br /&gt;
        hiScore = tonumber(file:read(&amp;quot;*line&amp;quot;))&lt;br /&gt;
        file:close()&lt;br /&gt;
    end&lt;br /&gt;
    print(&amp;#039;&amp;#039;)&lt;br /&gt;
end&lt;br /&gt;
-- Save high score&lt;br /&gt;
local function saveScore()&lt;br /&gt;
    local file = io.open(&amp;quot;|D|settings.txt&amp;quot;, &amp;quot;w+&amp;quot;)&lt;br /&gt;
    file:write(hiScore .. &amp;quot;\n&amp;quot;)&lt;br /&gt;
    file:close()&lt;br /&gt;
end&lt;br /&gt;
-- Initialise scores and text&lt;br /&gt;
local function initScores()&lt;br /&gt;
    score = 0&lt;br /&gt;
    scoreText = TextField.new(nil, &amp;quot;Score: &amp;quot; .. score)&lt;br /&gt;
    scoreText:setPosition(10, 10)&lt;br /&gt;
    stage:addChild(scoreText)&lt;br /&gt;
    hiScoreText = TextField.new(nil, &amp;quot;Hi Score: &amp;quot; .. hiScore)&lt;br /&gt;
    hiScoreText:setPosition(200, 10)&lt;br /&gt;
    stage:addChild(hiScoreText)&lt;br /&gt;
end&lt;br /&gt;
-- Update all scores&lt;br /&gt;
local function scoresUpdate()&lt;br /&gt;
    score = score + 1&lt;br /&gt;
    scoreText:setText(&amp;quot;Score: &amp;quot; .. score)&lt;br /&gt;
    if score &amp;gt; hiScore then&lt;br /&gt;
        hiScore = score&lt;br /&gt;
        hiScoreText:setText(&amp;quot;Hi Score: &amp;quot; .. hiScore)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Play tune&lt;br /&gt;
local function playTune()&lt;br /&gt;
    local gametune = Sound.new(&amp;quot;audio/DST-909Dreams.mp3&amp;quot;)&lt;br /&gt;
    gametune:play(0, true)&lt;br /&gt;
end&lt;br /&gt;
-- Play sound effects&lt;br /&gt;
local function playEffect()&lt;br /&gt;
    local explodefx = Sound.new(&amp;quot;audio/gameover.wav&amp;quot;)&lt;br /&gt;
    explodefx:play()&lt;br /&gt;
end&lt;br /&gt;
-- Player image touched function&lt;br /&gt;
local function imagetouch(playerImage, event)&lt;br /&gt;
    if not isGameRunning then&lt;br /&gt;
        return&lt;br /&gt;
    end&lt;br /&gt;
    -- Is the player touching the player sprite?&lt;br /&gt;
    if playerImage:hitTestPoint(event.touch.x, event.touch.y) then&lt;br /&gt;
        player.x = event.touch.x - (player.width / 2)&lt;br /&gt;
        player.y = event.touch.y - (player.height / 2)&lt;br /&gt;
        -- Make sure they don&amp;#039;t drag it offscreen&lt;br /&gt;
        if player.x &amp;gt; 286 then&lt;br /&gt;
            player.x = 286&lt;br /&gt;
        end&lt;br /&gt;
        if player.x &amp;lt; 0 then&lt;br /&gt;
            player.x = 0&lt;br /&gt;
        end&lt;br /&gt;
        if player.y &amp;lt; 0 then&lt;br /&gt;
            player.y = 0&lt;br /&gt;
        end&lt;br /&gt;
        if player.y &amp;gt; 446 then&lt;br /&gt;
            player.y = 446&lt;br /&gt;
        end&lt;br /&gt;
        player:setPosition(player.x, player.y)&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Set up the player sprite&lt;br /&gt;
local function initPlayer()&lt;br /&gt;
    -- Create the player object&lt;br /&gt;
    player = Bitmap.new(Texture.new(&amp;quot;images/player.png&amp;quot;))&lt;br /&gt;
    player.x, player.y = 160, 240&lt;br /&gt;
    player.width, player.height = 32, 32&lt;br /&gt;
    player:setPosition(player.x, player.y)&lt;br /&gt;
    stage:addChild(player)&lt;br /&gt;
    -- Make it touchable&lt;br /&gt;
    player:addEventListener(Event.TOUCHES_MOVE, imagetouch, player)&lt;br /&gt;
end&lt;br /&gt;
-- Set up the enemies&lt;br /&gt;
local function initEnemies()&lt;br /&gt;
    -- Create enemy objects&lt;br /&gt;
    local i&lt;br /&gt;
    for i = 1, MAXNUMBEROFENEMIES do&lt;br /&gt;
        enemyShape[i] = Shape.new()&lt;br /&gt;
        enemyShape[i]:setLineStyle(1, 0x000066, 0.25)&lt;br /&gt;
        enemyShape[i]:setFillStyle(Shape.SOLID, 0xaaaaff)&lt;br /&gt;
        enemyShape[i]:beginPath()&lt;br /&gt;
        enemyShape[i]:moveTo(1, 1)&lt;br /&gt;
        enemyShape[i]:lineTo(19, 1)&lt;br /&gt;
        enemyShape[i]:lineTo(19, 19)&lt;br /&gt;
        enemyShape[i]:lineTo(1, 19)&lt;br /&gt;
        enemyShape[i]:lineTo(1, 1)&lt;br /&gt;
        enemyShape[i]:endPath()&lt;br /&gt;
        enemyShape[i].width, enemyShape[i].height = 20, 20&lt;br /&gt;
        -- Set up enemy positions&lt;br /&gt;
        if i &amp;lt; MINNUMBEROFENEMIES then&lt;br /&gt;
            -- Add randomly to the screen&lt;br /&gt;
            local xRand, yRand = rnd(270) + 20, rnd(400) + 20&lt;br /&gt;
            -- Make sure enemies do not appear on top of player&lt;br /&gt;
            if xRand &amp;gt; 100 and xRand &amp;lt; 200 and yRand &amp;gt; 200 and yRand &amp;lt; 300 then&lt;br /&gt;
                xRand = xRand + 100&lt;br /&gt;
                yRand = yRand + 100&lt;br /&gt;
            end&lt;br /&gt;
            enemyShape[i].x, enemyShape[i].y = xRand, yRand&lt;br /&gt;
        else&lt;br /&gt;
            -- Hide extra enemies offscreen until needed&lt;br /&gt;
            enemyShape[i].x, enemyShape[i].y = -100, -100&lt;br /&gt;
        end&lt;br /&gt;
        enemyShape[i]:setPosition(enemyShape[i].x, enemyShape[i].y)&lt;br /&gt;
        stage:addChild(enemyShape[i])&lt;br /&gt;
        -- Pick a direction for the enemies to move&lt;br /&gt;
        xdir, ydir = rnd(2) - 1, rnd(2) - 1&lt;br /&gt;
        if xdir == 0 then&lt;br /&gt;
            xdir = -1&lt;br /&gt;
        end&lt;br /&gt;
        if ydir == 0 then&lt;br /&gt;
            ydir = -1&lt;br /&gt;
        end&lt;br /&gt;
        enemyShape[i].xdir, enemyShape[i].ydir = xdir, ydir&lt;br /&gt;
    end&lt;br /&gt;
    enemyCountdown = MAXCOUNTDOWN&lt;br /&gt;
end&lt;br /&gt;
-- Spawn a new enemy&lt;br /&gt;
local function spawnEnemy()&lt;br /&gt;
    local xRand, yRand = rnd(250) + 20, rnd(400) + 20&lt;br /&gt;
    -- Make sure enemies do not appear on top of player&lt;br /&gt;
    if xRand &amp;gt; player.x - 40 and xRand &amp;lt; player.x + 40 and yRand &amp;gt; player.y - 40 and yRand &amp;lt; player.y + 40 then&lt;br /&gt;
        xRand = xRand + 100&lt;br /&gt;
        yRand = yRand + 100&lt;br /&gt;
        if xRand &amp;gt; 270 then&lt;br /&gt;
            xRand = xRand - 200&lt;br /&gt;
        end&lt;br /&gt;
        if yRand &amp;gt; 420 then&lt;br /&gt;
            yRand = yRand - 200&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    numberOfEnemies = numberOfEnemies + 1&lt;br /&gt;
    enemyShape[numberOfEnemies].x, enemyShape[numberOfEnemies].y = xRand, yRand&lt;br /&gt;
    enemyShape[numberOfEnemies]:setPosition(enemyShape[numberOfEnemies].x, enemyShape[numberOfEnemies].y)&lt;br /&gt;
    enemyCountdown = MAXCOUNTDOWN&lt;br /&gt;
end&lt;br /&gt;
-- Update the enemies&lt;br /&gt;
local function enemiesUpdate()&lt;br /&gt;
    for i = 1, numberOfEnemies do&lt;br /&gt;
        enemyShape[i].x = enemyShape[i].x + enemyShape[i].xdir&lt;br /&gt;
        enemyShape[i].y = enemyShape[i].y + enemyShape[i].ydir&lt;br /&gt;
        -- Check if we hit a wall&lt;br /&gt;
        if enemyShape[i].x &amp;lt; 1 or enemyShape[i].x &amp;gt; 299 then&lt;br /&gt;
            enemyShape[i].xdir = -enemyShape[i].xdir&lt;br /&gt;
        end&lt;br /&gt;
        if enemyShape[i].y &amp;lt; 1 or enemyShape[i].y &amp;gt; 459 then&lt;br /&gt;
            enemyShape[i].ydir = -enemyShape[i].ydir&lt;br /&gt;
        end&lt;br /&gt;
        enemyShape[i]:setPosition(enemyShape[i].x, enemyShape[i].y)&lt;br /&gt;
    end&lt;br /&gt;
    -- Simple way of doing a timer before spawning more enemies&lt;br /&gt;
    enemyCountdown = enemyCountdown - 1&lt;br /&gt;
    if enemyCountdown == 0 then&lt;br /&gt;
        if numberOfEnemies &amp;lt; MAXNUMBEROFENEMIES then&lt;br /&gt;
            spawnEnemy()&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Simple collision test&lt;br /&gt;
function collisionTest(rectA, rectB)&lt;br /&gt;
    local collided = false&lt;br /&gt;
    x1, y1, w1, h1, x2, y2, w2, h2 =&lt;br /&gt;
        rectA.x,&lt;br /&gt;
        rectA.y,&lt;br /&gt;
        rectA.width,&lt;br /&gt;
        rectA.height,&lt;br /&gt;
        rectB.x,&lt;br /&gt;
        rectB.y,&lt;br /&gt;
        rectB.width,&lt;br /&gt;
        rectB.height&lt;br /&gt;
    if&lt;br /&gt;
        (y2 &amp;gt;= y1 and y1 + h1 &amp;gt;= y2) or (y2 + h2 &amp;gt;= y1 and y1 + h1 &amp;gt;= y2 + h2) or (y1 &amp;gt;= y2 and y2 + h2 &amp;gt;= y1) or&lt;br /&gt;
            (y1 + h1 &amp;gt;= y2 and y2 + h2 &amp;gt;= y1 + h1)&lt;br /&gt;
     then&lt;br /&gt;
        if x2 &amp;gt;= x1 and x1 + w1 &amp;gt;= x2 then&lt;br /&gt;
            collided = true&lt;br /&gt;
        end&lt;br /&gt;
        if x2 + w2 &amp;gt;= x1 and x1 + w1 &amp;gt;= x2 + w2 then&lt;br /&gt;
            collided = true&lt;br /&gt;
        end&lt;br /&gt;
        if x1 &amp;gt;= x2 and x2 + w2 &amp;gt;= x1 then&lt;br /&gt;
            collided = true&lt;br /&gt;
        end&lt;br /&gt;
        if x1 + w1 &amp;gt;= x2 and x2 + w2 &amp;gt;= x1 + w1 then&lt;br /&gt;
            collided = true&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
    return collided&lt;br /&gt;
end&lt;br /&gt;
-- Initialise the game&lt;br /&gt;
local function initGame()&lt;br /&gt;
    isGameRunning = true&lt;br /&gt;
    initEnemies()&lt;br /&gt;
    initPlayer()&lt;br /&gt;
    loadScore()&lt;br /&gt;
    initScores()&lt;br /&gt;
end&lt;br /&gt;
-- Start button touch handler&lt;br /&gt;
local function startTouch(startbuttonImage, event)&lt;br /&gt;
    -- See if the Game Over object was touched&lt;br /&gt;
    if startbuttonImage:hitTestPoint(event.touch.x, event.touch.y) then&lt;br /&gt;
        startbuttonImage:removeEventListener(Event.TOUCHES_END, startTouch)&lt;br /&gt;
        -- Clean up our objects&lt;br /&gt;
        stage:removeChild(startbuttonImage)&lt;br /&gt;
        startbuttonImage = nil&lt;br /&gt;
        initGame()&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Start game. Display START button and logo&lt;br /&gt;
local function startGame()&lt;br /&gt;
    -- Create a Game Over object and display it&lt;br /&gt;
    startbuttonImg = Bitmap.new(Texture.new(&amp;quot;images/squaredodge.png&amp;quot;))&lt;br /&gt;
    startbuttonImg.x, startbuttonImg.y = 0, 200&lt;br /&gt;
    startbuttonImg:setPosition(startbuttonImg.x, startbuttonImg.y)&lt;br /&gt;
    stage:addChild(startbuttonImg)&lt;br /&gt;
    -- Make the Game Over object touchable&lt;br /&gt;
    startbuttonImg:addEventListener(Event.TOUCHES_BEGIN, startTouch, startbuttonImg)&lt;br /&gt;
end&lt;br /&gt;
local function goTouch(gameOverImage, event)&lt;br /&gt;
    -- See if the Game Over object was touched&lt;br /&gt;
    if gameOverImage:hitTestPoint(event.touch.x, event.touch.y) then&lt;br /&gt;
        gameoverImg:removeEventListener(Event.TOUCHES_END, goTouch)&lt;br /&gt;
        -- Clean up our objects&lt;br /&gt;
        stage:removeChild(gameoverImg)&lt;br /&gt;
        gameoverImg = nil&lt;br /&gt;
        for i = 1, MAXNUMBEROFENEMIES do&lt;br /&gt;
            stage:removeChild(enemyShape[i])&lt;br /&gt;
            enemyShape[i] = nil&lt;br /&gt;
        end&lt;br /&gt;
        stage:removeChild(player)&lt;br /&gt;
        player = nil&lt;br /&gt;
        stage:removeChild(hiScoreText)&lt;br /&gt;
        hiScoreText = nil&lt;br /&gt;
        stage:removeChild(scoreText)&lt;br /&gt;
        scoreText = nil&lt;br /&gt;
        -- Restart the game&lt;br /&gt;
        startGame()&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Game over handling&lt;br /&gt;
local function gameOver()&lt;br /&gt;
    -- Save the current hiScore&lt;br /&gt;
    saveScore()&lt;br /&gt;
    -- Play explosion&lt;br /&gt;
    playEffect()&lt;br /&gt;
    -- Remove the listener from the player object&lt;br /&gt;
    player:removeEventListener(Event.TOUCHES_MOVE, imagetouch)&lt;br /&gt;
    -- Create a Game Over object and display it&lt;br /&gt;
    gameoverImg = Bitmap.new(Texture.new(&amp;quot;images/gameover.png&amp;quot;))&lt;br /&gt;
    gameoverImg.x, gameoverImg.y = 0, 200&lt;br /&gt;
    gameoverImg:setPosition(gameoverImg.x, gameoverImg.y)&lt;br /&gt;
    stage:addChild(gameoverImg)&lt;br /&gt;
    -- Make the Game Over object touchable&lt;br /&gt;
    gameoverImg:addEventListener(Event.TOUCHES_BEGIN, goTouch, gameoverImg)&lt;br /&gt;
end&lt;br /&gt;
-- See if any collisions occurred&lt;br /&gt;
local function checkCollisions()&lt;br /&gt;
    for i = 1, numberOfEnemies do&lt;br /&gt;
        if collisionTest(player, enemyShape[i]) == true then&lt;br /&gt;
            isGameRunning = false&lt;br /&gt;
            gameOver()&lt;br /&gt;
            return&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- Update everything&lt;br /&gt;
local function updateAll()&lt;br /&gt;
    -- Only update if the game is still going&lt;br /&gt;
    if not isGameRunning then&lt;br /&gt;
        return&lt;br /&gt;
    end&lt;br /&gt;
    scoresUpdate()&lt;br /&gt;
    enemiesUpdate()&lt;br /&gt;
    checkCollisions()&lt;br /&gt;
end&lt;br /&gt;
-- Start it all up!&lt;br /&gt;
playTune()&lt;br /&gt;
startGame()&lt;br /&gt;
-- This executes &amp;quot;updateAll&amp;quot; each frame (constantly)&lt;br /&gt;
stage:addEventListener(Event.ENTER_FRAME, updateAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Wow! That’s a lot of code!&amp;lt;br&amp;gt;&lt;br /&gt;
Here’s a screenshot of the game in action:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Jason-Oakley-Creating-Your-First-Game-Square-Dodge-screenshot.png|thumb|center]]&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let’s analyse our code.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the below code, we are assigning our variables as ‘local’ so they don’t use too much RAM by being global. This is a good practise for all of your apps, so start doing it now. ‘enemyShape’ is a table to hold all the enemy objects.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Define our variables and tables as local to save memory&lt;br /&gt;
local score&lt;br /&gt;
local hiScore&lt;br /&gt;
local enemyShape = {}&lt;br /&gt;
local player&lt;br /&gt;
local isGameRunning&lt;br /&gt;
local scoreText&lt;br /&gt;
local hiScoreText&lt;br /&gt;
local MINNUMBEROFENEMIES = 7&lt;br /&gt;
local MAXNUMBEROFENEMIES = 101&lt;br /&gt;
local numberOfEnemies = MINNUMBEROFENEMIES&lt;br /&gt;
local enemyCountdown&lt;br /&gt;
local MAXCOUNTDOWN = 500&lt;br /&gt;
local gameoverImg, startbuttonImg&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Assigning ‘math.random’ to ‘rnd’ will cache the function and make it faster to access. This is a standard in Lua, particularly for math functions.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Cache math.random to make access faster&lt;br /&gt;
local rnd = math.random&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is our code for loading and saving the hiScore variable between games. This way, whenever the player plays our game, they will see their highest score to beat.&amp;lt;br&amp;gt;&lt;br /&gt;
For loading, we first try to open the file. If it fails because it is the first time, we set the hiScore to ‘0’.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Load high score if it exists&lt;br /&gt;
local function loadScore()&lt;br /&gt;
	local file = io.open(&amp;quot;|D|settings.txt&amp;quot;,&amp;quot;r&amp;quot;)&lt;br /&gt;
	if not file then&lt;br /&gt;
		hiScore = 0&lt;br /&gt;
	else&lt;br /&gt;
		hiScore=tonumber(file:read(&amp;quot;*line&amp;quot;))&lt;br /&gt;
		file:close()&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the hiScore so we can later retrieve it.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Save high score&lt;br /&gt;
local function saveScore()&lt;br /&gt;
	local file=io.open(&amp;quot;|D|settings.txt&amp;quot;,&amp;quot;w+&amp;quot;)&lt;br /&gt;
	file:write(hiScore .. &amp;quot;\n&amp;quot;)&lt;br /&gt;
	file:close()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Initialise the score variable and set up the text at the top of the screen to display the score and hiScore.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Initialise scores and text&lt;br /&gt;
local function initScores()&lt;br /&gt;
	score = 0&lt;br /&gt;
	scoreText = TextField.new(nil, &amp;quot;Score: &amp;quot; .. score)&lt;br /&gt;
	scoreText:setPosition(10,10)&lt;br /&gt;
	stage:addChild(scoreText)&lt;br /&gt;
	hiScoreText = TextField.new(nil, &amp;quot;Hi Score: &amp;quot; .. hiScore)&lt;br /&gt;
	hiScoreText:setPosition(200,10)&lt;br /&gt;
	stage:addChild(hiScoreText)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Update the score. If ‘score’ is bigger than ‘hiScore’, make them the same.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Update all scores&lt;br /&gt;
local function scoresUpdate()&lt;br /&gt;
	score = score + 1&lt;br /&gt;
	scoreText:setText(&amp;quot;Score: &amp;quot; .. score)&lt;br /&gt;
	if score &amp;gt; hiScore then&lt;br /&gt;
		hiScore = score&lt;br /&gt;
		hiScoreText:setText(&amp;quot;Hi Score: &amp;quot; .. hiScore) &lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Load our tune and set it to repeat forever. Load the sound effect for Game Over and play that effect.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Play tune&lt;br /&gt;
local function playTune()&lt;br /&gt;
	local gametune = Sound.new(&amp;quot;audio/DST-909Dreams.mp3&amp;quot;)&lt;br /&gt;
	gametune:play(100,math.huge)&lt;br /&gt;
end&lt;br /&gt;
 &lt;br /&gt;
-- Play sound effects&lt;br /&gt;
local function playEffect()&lt;br /&gt;
	local explodefx = Sound.new(&amp;quot;audio/gameover.wav&amp;quot;)&lt;br /&gt;
	explodefx:play()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We need to set up a touch function so that when the player touches the player image, it will be draggable around the screen. We also ensure the image stays within the boundaries of the screen by limiting the ‘x’ and ‘y’ values.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Player image touched function&lt;br /&gt;
local function imagetouch(playerImage, event)&lt;br /&gt;
	if not isGameRunning then&lt;br /&gt;
	return&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Is the player touching the player object?&lt;br /&gt;
	if playerImage:hitTestPoint(event.touch.x, event.touch.y) then&lt;br /&gt;
		player.x = event.touch.x-(player.width/2)&lt;br /&gt;
		player.y = event.touch.y-(player.height/2)&lt;br /&gt;
&lt;br /&gt;
		-- Make sure they don&amp;#039;t drag it offscreen&lt;br /&gt;
		if player.x &amp;gt; 286 then&lt;br /&gt;
			player.x = 286&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if player.x &amp;lt; 0 then&lt;br /&gt;
			player.x = 0&lt;br /&gt;
		end &lt;br /&gt;
&lt;br /&gt;
		if player.y &amp;lt; 0 then&lt;br /&gt;
			player.y = 0&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if player.y &amp;gt; 446 then&lt;br /&gt;
			player.y = 446&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		player:setPosition(player.x, player.y)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Load the player image and set its initial ‘x’ and ‘y’ co-ordinates. Configure the Event Listener for when the player touches the image.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Set up the player object&lt;br /&gt;
local function initPlayer()&lt;br /&gt;
	-- Create the player object&lt;br /&gt;
	player = Bitmap.new(Texture.new(&amp;quot;images/player.png&amp;quot;))&lt;br /&gt;
	player.x, player.y = 160,240&lt;br /&gt;
	player.width, player.height = 32, 32&lt;br /&gt;
	player:setPosition(player.x, player.y)&lt;br /&gt;
	stage:addChild(player)&lt;br /&gt;
&lt;br /&gt;
	-- Make it touchable&lt;br /&gt;
	player:addEventListener(Event.TOUCHES_MOVE, imagetouch, player)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This one is quite long. We are creating all the enemies required, but we only add the first 6 to the active display. The rest are kept outside the display area until the timer adds them in. This way, the game slowly gets more difficult as more enemies appear.&amp;lt;br&amp;gt;&lt;br /&gt;
We also make sure the initial enemies do not appear too close to the player’s initial position in the middle of the screen, otherwise it’ll be Game Over too quickly.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Set up the enemies&lt;br /&gt;
local function initEnemies()&lt;br /&gt;
	-- Create enemy objects&lt;br /&gt;
	for i = 1,MAXNUMBEROFENEMIES do&lt;br /&gt;
		enemyShape[i] = Shape.new()&lt;br /&gt;
		enemyShape[i]:setLineStyle(1, 0x000066, 0.25)&lt;br /&gt;
		enemyShape[i]:setFillStyle(Shape.SOLID, 0xaaaaff)&lt;br /&gt;
		enemyShape[i]:beginPath()&lt;br /&gt;
		enemyShape[i]:moveTo(1,1)&lt;br /&gt;
		enemyShape[i]:lineTo(19,1)&lt;br /&gt;
		enemyShape[i]:lineTo(19,19)&lt;br /&gt;
		enemyShape[i]:lineTo(1,19)&lt;br /&gt;
		enemyShape[i]:lineTo(1,1)&lt;br /&gt;
		enemyShape[i]:endPath()&lt;br /&gt;
		enemyShape[i].width, enemyShape[i].height = 20, 20&lt;br /&gt;
		 &lt;br /&gt;
		-- Set up enemy positions&lt;br /&gt;
		local i&lt;br /&gt;
		if i &amp;lt; MINNUMBEROFENEMIES then&lt;br /&gt;
			-- Add randomly to the screen&lt;br /&gt;
			local xRand, yRand = rnd(270)+20,rnd(400)+20&lt;br /&gt;
			-- Make sure enemies do not appear on top of player&lt;br /&gt;
			if xRand &amp;gt; 100 and xRand &amp;lt; 200 and yRand &amp;gt; 200 and yRand &amp;lt; 300 then&lt;br /&gt;
				xRand = xRand + 100&lt;br /&gt;
				yRand = yRand + 100&lt;br /&gt;
			end&lt;br /&gt;
			enemyShape[i].x, enemyShape[i].y = xRand, yRand&lt;br /&gt;
		else&lt;br /&gt;
			-- Hide extra enemies offscreen until needed&lt;br /&gt;
			enemyShape[i].x, enemyShape[i].y = -100,-100&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		enemyShape[i]:setPosition(enemyShape[i].x,enemyShape[i].y)&lt;br /&gt;
		stage:addChild(enemyShape[i])&lt;br /&gt;
		 &lt;br /&gt;
		-- Pick a direction for the enemies to move&lt;br /&gt;
		local xdir, ydir = rnd(2)-1, rnd(2)-1&lt;br /&gt;
		if xdir == 0 then&lt;br /&gt;
			xdir = -1&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if ydir == 0 then&lt;br /&gt;
			ydir = -1&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		enemyShape[i].xdir, enemyShape[i].ydir = xdir, ydir&lt;br /&gt;
	end&lt;br /&gt;
		enemyCountdown=MAXCOUNTDOWN&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Every now and again, we bring one of the enemies hiding off-screen onto the active screen and set them bouncing around. We also make sure these don’t spawn too close to the player’s current position.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Spawn a new enemy&lt;br /&gt;
local function spawnEnemy()&lt;br /&gt;
	local xRand, yRand = rnd(250)+20,rnd(400)+20&lt;br /&gt;
	-- Make sure enemies do not appear on top of player&lt;br /&gt;
	if xRand &amp;gt; player.x-40 and xRand &amp;lt; player.x+40 and yRand &amp;gt; player.y-40 and yRand &amp;lt; player.y+40 then&lt;br /&gt;
		xRand = xRand + 100&lt;br /&gt;
		yRand = yRand + 100&lt;br /&gt;
		if xRand &amp;gt; 270 then &lt;br /&gt;
			xRand = xRand - 200 &lt;br /&gt;
		end&lt;br /&gt;
		if yRand &amp;gt; 420 then &lt;br /&gt;
			yRand = yRand - 200 &lt;br /&gt;
		end&lt;br /&gt;
	end &lt;br /&gt;
	numberOfEnemies = numberOfEnemies + 1&lt;br /&gt;
	enemyShape[numberOfEnemies].x, enemyShape[numberOfEnemies].y = xRand, yRand&lt;br /&gt;
	enemyShape[numberOfEnemies]:setPosition(enemyShape[numberOfEnemies].x, enemyShape[numberOfEnemies].y)&lt;br /&gt;
	enemyCountdown=MAXCOUNTDOWN&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This function will move the enemies on the active screen and bounce them around if they hit the borders of the screen. It decrements the counter and if it’s time, spawns new enemies.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Update the enemies&lt;br /&gt;
local function enemiesUpdate()&lt;br /&gt;
	local i&lt;br /&gt;
	for i=1,numberOfEnemies do&lt;br /&gt;
		enemyShape[i].x=enemyShape[i].x+enemyShape[i].xdir&lt;br /&gt;
		enemyShape[i].y=enemyShape[i].y+enemyShape[i].ydir&lt;br /&gt;
		 &lt;br /&gt;
		-- Check if we hit a wall&lt;br /&gt;
		if enemyShape[i].x &amp;lt; 1 or enemyShape[i].x &amp;gt; 299 then&lt;br /&gt;
			enemyShape[i].xdir = -enemyShape[i].xdir&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		if enemyShape[i].y &amp;lt; 1 or enemyShape[i].y &amp;gt; 459 then&lt;br /&gt;
			enemyShape[i].ydir = -enemyShape[i].ydir&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		enemyShape[i]:setPosition(enemyShape[i].x,enemyShape[i].y)&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- Simple way of doing a timer before spawning more enemies&lt;br /&gt;
	enemyCountdown = enemyCountdown - 1&lt;br /&gt;
	if enemyCountdown == 0 then&lt;br /&gt;
		if numberOfEnemies &amp;lt; MAXNUMBEROFENEMIES then&lt;br /&gt;
			spawnEnemy()&lt;br /&gt;
		end&lt;br /&gt;
	end &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a simple collision test function. You can find example code for this on the internet with a quick search. Basically, it checks the co-ordinates of the player object compared to the enemy object specified. If they overlap, it returns ‘true’.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Simple collision test&lt;br /&gt;
function collisionTest(rectA, rectB)&lt;br /&gt;
	local collided = false &lt;br /&gt;
	local x1,y1,w1,h1,x2,y2,w2,h2 = rectA.x, rectA.y, rectA.width, rectA.height, rectB.x, rectB.y, rectB.width, rectB.height&lt;br /&gt;
	if (y2 &amp;gt;= y1 and y1 + h1 &amp;gt;= y2) or (y2 + h2 &amp;gt;= y1 and y1 + h1 &amp;gt;= y2 + h2) or (y1 &amp;gt;= y2 and y2 + h2 &amp;gt;= y1) or (y1 + h1 &amp;gt;= y2 and y2 + h2 &amp;gt;= y1 + h1) then&lt;br /&gt;
		if x2 &amp;gt;= x1 and x1 + w1 &amp;gt;= x2 then&lt;br /&gt;
			collided = true&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if x2 + w2 &amp;gt;= x1 and x1 + w1 &amp;gt;= x2 + w2 then&lt;br /&gt;
			collided = true &lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if x1 &amp;gt;= x2 and x2 + w2 &amp;gt;= x1 then&lt;br /&gt;
			collided = true &lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		if x1 + w1 &amp;gt;= x2 and x2 + w2 &amp;gt;= x1 + w1 then&lt;br /&gt;
			collided = true&lt;br /&gt;
		end &lt;br /&gt;
	end&lt;br /&gt;
	return collided&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up the enemies and player object, load the score and set up the text.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Initialise the game&lt;br /&gt;
local function initGame()&lt;br /&gt;
	isGameRunning = true&lt;br /&gt;
	initEnemies()&lt;br /&gt;
	initPlayer()&lt;br /&gt;
	loadScore()&lt;br /&gt;
	initScores()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up the logo and game Start button to be touchable.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Start button touch handler&lt;br /&gt;
local function startTouch(startbuttonImage, event)&lt;br /&gt;
	-- See if the Game Start object was touched&lt;br /&gt;
	if startbuttonImage:hitTestPoint(event.touch.x, event.touch.y) then&lt;br /&gt;
		startbuttonImage:removeEventListener(Event.TOUCHES_END, startTouch)&lt;br /&gt;
		-- Clean up our objects&lt;br /&gt;
		stage:removeChild(startbuttonImage)&lt;br /&gt;
		startbuttonImage=nil&lt;br /&gt;
		initGame()&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a start button object and add it to the screen.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Start game. Display START button and logo&lt;br /&gt;
local function startGame()&lt;br /&gt;
	-- Create a Start Game object and display it&lt;br /&gt;
	startbuttonImg = Bitmap.new(Texture.new(&amp;quot;images/squaredodge.png&amp;quot;))&lt;br /&gt;
	startbuttonImg.x, startbuttonImg.y = 0,200&lt;br /&gt;
	startbuttonImg:setPosition(startbuttonImg.x, startbuttonImg.y)&lt;br /&gt;
	stage:addChild(startbuttonImg)&lt;br /&gt;
	-- Make the Game Over object touchable&lt;br /&gt;
	startbuttonImg:addEventListener(Event.TOUCHES_BEGIN, startTouch, startbuttonImg)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a Game Over object and make it touchable. Remove the player and enemy objects and text at the top of the screen.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local function goTouch(gameOverImage, event)&lt;br /&gt;
	-- See if the Game Over object was touched&lt;br /&gt;
	if gameOverImage:hitTestPoint(event.touch.x, event.touch.y) then&lt;br /&gt;
		gameoverImg:removeEventListener(Event.TOUCHES_END, goTouch)&lt;br /&gt;
		-- Clean up our objects&lt;br /&gt;
		stage:removeChild(gameoverImg)&lt;br /&gt;
		gameoverImg=nil&lt;br /&gt;
		local i&lt;br /&gt;
		for i = 1,MAXNUMBEROFENEMIES do&lt;br /&gt;
			stage:removeChild(enemyShape[i])&lt;br /&gt;
			enemyShape[i]=nil&lt;br /&gt;
		end&lt;br /&gt;
&lt;br /&gt;
		stage:removeChild(player)&lt;br /&gt;
		player=nil&lt;br /&gt;
		stage:removeChild(hiScoreText)&lt;br /&gt;
		hiScoreText=nil&lt;br /&gt;
		stage:removeChild(scoreText)&lt;br /&gt;
		scoreText=nil&lt;br /&gt;
		-- Restart the game&lt;br /&gt;
		startGame()&lt;br /&gt;
	end &lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When the player collides with an enemy object, this code is executed. Save the current hiScore, play the ‘game over’ sound effect and display the Game Over image.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Game over handling&lt;br /&gt;
local function gameOver()&lt;br /&gt;
	-- Save the current hiScore&lt;br /&gt;
	saveScore()&lt;br /&gt;
&lt;br /&gt;
	-- Play explosion&lt;br /&gt;
	playEffect()&lt;br /&gt;
&lt;br /&gt;
	-- Remove the listener from the player object&lt;br /&gt;
	player:removeEventListener(Event.TOUCHES_MOVE, imagetouch)&lt;br /&gt;
&lt;br /&gt;
	-- Create a Game Over object and display it&lt;br /&gt;
	gameoverImg = Bitmap.new(Texture.new(&amp;quot;images/gameover.png&amp;quot;))&lt;br /&gt;
	gameoverImg.x, gameoverImg.y = 0,200&lt;br /&gt;
	gameoverImg:setPosition(gameoverImg.x, gameoverImg.y)&lt;br /&gt;
	stage:addChild(gameoverImg)&lt;br /&gt;
&lt;br /&gt;
	-- Make the Game Over object touchable&lt;br /&gt;
	gameoverImg:addEventListener(Event.TOUCHES_BEGIN, goTouch, gameoverImg)&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Supply the player and enemy objects to test if any collided. If they did, go to the Game Over function.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- See if any collisions occurred&lt;br /&gt;
local function checkCollisions()&lt;br /&gt;
	local i&lt;br /&gt;
	for i=1,numberOfEnemies do&lt;br /&gt;
		if collisionTest (player, enemyShape[i]) == true then&lt;br /&gt;
			isGameRunning = false&lt;br /&gt;
			gameOver()&lt;br /&gt;
			return&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is the code to run every frame of the game. This means it constantly is run by the application. Sometimes, it’s good to check the game is actually running so they code does not accidentally get called elsewhere. It’s a fail-safe.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Update everything&lt;br /&gt;
local function updateAll()&lt;br /&gt;
	-- Only update if the game is still going&lt;br /&gt;
	if not isGameRunning then&lt;br /&gt;
		return&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	scoresUpdate()&lt;br /&gt;
	enemiesUpdate()&lt;br /&gt;
	checkCollisions()&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start the tune playing and start the game off.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- Start it all up!&lt;br /&gt;
playTune()&lt;br /&gt;
startGame()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells the application to call the ‘updateAll’ function constantly to keep things running.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
-- This executes &amp;quot;updateAll&amp;quot; each frame (constantly)&lt;br /&gt;
stage:addEventListener(Event.ENTER_FRAME, updateAll)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And that’s how you can make a simple game. You’ve learned enough to get out there and get something started.&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we’ll go into more complex programming and explore some third-party applications to help make your game developing easier.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Note:&amp;#039;&amp;#039;&amp;#039; This tutorial was written by [http://bluebilby.com/author/waulokadmin/ Jason Oakley] and was originally available here: http://bluebilby.com/2013/05/08/gideros-mobile-tutorial-creating-your-first-game/.&lt;/div&gt;</summary>
		<author><name>Plicatibu</name></author>
	</entry>
</feed>