<?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>Games &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/games/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Mon, 08 Sep 2025 17:57:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Year of Code 2025: September Project, Games</title>
		<link>https://blog.xojo.com/2025/09/08/year-of-code-2025-september-project-games/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 08 Sep 2025 17:57:38 +0000</pubDate>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[#YearofCode]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[GitLab]]></category>
		<category><![CDATA[Year of Code]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=15311</guid>

					<description><![CDATA[I&#8217;m a bit of a retro computing and gaming guy and I enjoy making versions of retro games using Xojo. Although Xojo is not really&#8230;]]></description>
										<content:encoded><![CDATA[
<p>I&#8217;m a bit of a <a href="https://www.goto10retro.com">retro computing and gaming guy</a> and I enjoy making versions of retro games using Xojo. Although Xojo is not really designed for making games, its <a href="https://documentation.xojo.com/api/user_interface/desktop/desktopcanvas.html#desktopcanvas">Canvas</a> class works well for many kinds of simple games. That means our theme for the Year of Code for September is Games!</p>



<p>One of the first games I made using Xojo was a clone of Atari Tank (based on the version included with the Combat Atari 2600 cartridge).</p>



<p>The core of Tank served as the basis for the <a href="https://github.com/xojo/XojoWars">XojoWars game contest</a>, where it was re-imagined as a space battle.</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="400" height="308" src="https://blog.xojo.com/wp-content/uploads/2025/08/image-1.png" alt="" class="wp-image-15314" srcset="https://blog.xojo.com/wp-content/uploads/2025/08/image-1.png 400w, https://blog.xojo.com/wp-content/uploads/2025/08/image-1-300x231.png 300w" sizes="(max-width: 400px) 100vw, 400px" /></figure>



<p>Tank is a rather simple game and really needs to be two-players, which is why I added the ability for two people to play it over the network using UDPSocket. This version, which I called <a href="https://blog.xojo.com/2018/08/24/justcode-challenge-week-10-nettank/">NetTank</a>, is <a href="https://gitlab.com/xojo/NetTank">available on GitLab</a>.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="367" src="https://blog.xojo.com/wp-content/uploads/2025/08/image-1024x367.png" alt="" class="wp-image-15313" srcset="https://blog.xojo.com/wp-content/uploads/2025/08/image-1024x367.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/08/image-300x107.png 300w, https://blog.xojo.com/wp-content/uploads/2025/08/image-768x275.png 768w, https://blog.xojo.com/wp-content/uploads/2025/08/image.png 1220w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>On the mobile side, I&#8217;ve made a 2048 sliding-tiles game and Turtle, which I suppose is kind of an infinite version of Frogger.</p>



<p>However, I&#8217;ve had the most fun making clones of Asteroids and Space Invaders. I wrote some about Invaders in <a href="https://www.xdevmag.com">xDev Magazine</a> last year, but at some point I&#8217;ll get it enhanced enough to share in a blog post.</p>



<p>With that lengthy pre-amble I can now share my game for this month&#8217;s project, which is a clone of Asteroids that I uncreatively call Space Rocks. Although an older version of this game has been included with the Xojo examples for several years, this is an updated version with some new features:</p>



<ul class="wp-block-list">
<li>Smaller ship to better match proportions of the rocks.</li>



<li>Improved &#8216;heartbeat&#8217; sound.</li>



<li>High Score is saved and restored.</li>



<li>Level increases as you clear all the rocks, which adds even more rocks that also move faster.</li>



<li>Command or Shift key now work for firing missiles.</li>
</ul>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="850" src="https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.21.38@2x-1024x850.png" alt="" class="wp-image-15316" srcset="https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.21.38@2x-1024x850.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.21.38@2x-300x249.png 300w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.21.38@2x-768x637.png 768w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.21.38@2x-1536x1275.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.21.38@2x.png 2024w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="850" src="https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.23.20@2x-1024x850.png" alt="" class="wp-image-15315" srcset="https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.23.20@2x-1024x850.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.23.20@2x-300x249.png 300w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.23.20@2x-768x637.png 768w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.23.20@2x-1536x1275.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/08/CleanShot-2025-08-25-at-14.23.20@2x.png 2024w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Yes, 14340 is my high score. So far. I dare you to beat it!</p>



<p>The full project is on GitHub: <a href="https://github.com/paullefebvre/SpaceRocks">https://github.com/paullefebvre/SpaceRocks</a></p>



<p>Keep in mind that you don&#8217;t have to make an arcade-style game. Strategy and turn-based games are a lot of fun and also  great candidates for Xojo. For reference, take a look at the <a href="https://blog.xojo.com/2024/09/17/cosmic-trader-a-game-built-with-xojo-web/">web-based Cosmic Trader game</a> that Ricardo made last year. A platform-style or maze game might also be interesting. I can&#8217;t wait to see (and play) what you make!</p>



<p><em>Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at <a href="https://goto10.substack.com" target="_blank" rel="noreferrer noopener">Goto 10</a> and </em>on Mastodon @lefebvre@hachyderm.io.</p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>



<p><strong>Year of Code Project</strong></p>



<ul class="wp-block-list">
<li><a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/">Year of Code: Kickoff</a></li>



<li><a href="https://blog.xojo.com/2025/01/15/year-of-code-2025-january-project/" target="_blank" rel="noreferrer noopener">January Project: Desktop Apps</a>&nbsp;|&nbsp;<a href="https://forum.xojo.com/t/year-of-code-2025-january-project-sharing/83927" target="_blank" rel="noreferrer noopener">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/02/11/year-of-code-2025-february-project/">February Project: Database Apps</a>&nbsp;|&nbsp;<a href="https://forum.xojo.com/t/2025-year-of-code-february" target="_blank" rel="noreferrer noopener">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/03/05/year-of-code-2025-march-project-web-apps/">March Project: Web Apps</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-march/84474?u=alyssa_foley">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/04/08/year-of-code-2025-april-project-user-interface/">April Project: User Interface</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-april-user-interface/84926">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/05/07/year-of-code-2025-may-project-mobile-apps/">May Project: Mobile Apps</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-may-is-mobile/85272">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/06/10/year-of-code-2025-june-project-cross-platform-code-class/">June Project: Code Sharing</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-june-is-code-sharing/85612">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/07/10/year-of-code-2025-july-project-charting/">July Project: Charting</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-july-is-charting/85896">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/08/07/year-of-code-2025-august-project-console-apps/">August Project: Console Apps</a> | <a href="https://forum.xojo.com/t/august-2025-year-of-code-console-apps/86203">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/09/08/year-of-code-2025-september-project-games/">September Project: Games</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-septgamer">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/10/13/year-of-code-2025-october-project-multi-platform-communication/">October Project: Multi-Platform</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-october-multi-platform-communication/86717">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/11/10/year-of-code-2025-november-project-pdf-postcard-generator/">November Project: PDF</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-november-pdf/86969">Forum Discussion</a></li>
</ul>



<p><strong>How to Play:</strong></p>



<p>Each month we&#8217;ll announce a new theme and share an example project of our own. Share your projects to the Xojo Forum thread for that month via GitHub (all the links you need are posted above ↑ ). Learn how to use <a href="https://blog.xojo.com/2024/04/02/using-xojo-and-github/">Xojo and GitHub</a>.</p>



<p><strong>The Prizes:</strong></p>



<p>Monthly winners get $100 at the Xojo store. Every month you submit a project is another chance to win the grand prize. The grand prize is $250 cash plus a Xojo Pro license and a year of GraffitiSuite and will be announce in December. Learn more about the <a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/#prizes">prizes</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Year of Code 2025: March Project, Web Apps</title>
		<link>https://blog.xojo.com/2025/03/05/year-of-code-2025-march-project-web-apps/</link>
		
		<dc:creator><![CDATA[Gabriel Ludosanu]]></dc:creator>
		<pubDate>Wed, 05 Mar 2025 15:04:00 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Year of Code]]></category>
		<category><![CDATA[#YearofCode]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[webdev]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=14588</guid>

					<description><![CDATA[March’s topic is Web Apps and I’m excited to introduce my project: Quiziverse, a complete quiz and trivia web application. Quiziverse is designed to engage&#8230;]]></description>
										<content:encoded><![CDATA[
<p>March’s topic is Web Apps and I’m excited to introduce my project: Quiziverse, a complete quiz and trivia web application.</p>



<p>Quiziverse is designed to engage users with time-limited questions across various categories, making it a fun and interactive way to test knowledge. The application leverages a SQLite database as the backend for all data storage.</p>



<p>Here are some of the key features of Quiziverse:</p>



<ul class="wp-block-list">
<li><strong>Admin Area:</strong> The app includes a secure admin area, allowing administrators to manage categories and questions easily. Admins can add, edit, or delete questions and categories to keep the trivia fresh and exciting.</li>



<li><strong>Scoreboard:</strong> A dynamic scoreboard keeps track of player scores in real-time, fostering a competitive spirit among users. Players can see how they stack up against others, adding an element of fun to the experience.</li>



<li><strong>Time-Limited Questions:</strong> Each question comes with a timer, challenging players to think quickly and answer before time runs out. This feature adds to the intensity of the game and keeps players on their toes.</li>



<li><strong>Import JSON Files:</strong> To make it easy for admins to add new content, Quiziverse includes a function to import JSON files containing new categories and questions. This feature simplifies content management and allows for quick updates.</li>



<li><strong>Mobile Optimized Design:</strong> Understanding the importance of accessibility, Quiziverse is designed to be mobile-friendly. Players can join the trivia challenge from their smartphones or tablets for a seamless experience.</li>
</ul>



<p>Here’s a sneak peek of the Quiziverse interface:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="487" src="https://blog.xojo.com/wp-content/uploads/2025/03/image-1-1024x487.png" alt="Quiziverse Start Page" class="wp-image-14593" srcset="https://blog.xojo.com/wp-content/uploads/2025/03/image-1-1024x487.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/03/image-1-300x143.png 300w, https://blog.xojo.com/wp-content/uploads/2025/03/image-1-768x365.png 768w, https://blog.xojo.com/wp-content/uploads/2025/03/image-1-1536x731.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/03/image-1.png 1583w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="479" src="https://blog.xojo.com/wp-content/uploads/2025/03/image-1024x479.png" alt="Quiziverse Trivia Page" class="wp-image-14592" srcset="https://blog.xojo.com/wp-content/uploads/2025/03/image-1024x479.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/03/image-300x140.png 300w, https://blog.xojo.com/wp-content/uploads/2025/03/image-768x359.png 768w, https://blog.xojo.com/wp-content/uploads/2025/03/image-1536x719.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/03/image.png 1599w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="485" src="https://blog.xojo.com/wp-content/uploads/2025/03/image-2-1024x485.png" alt="Quiziverse Admin General Settings" class="wp-image-14594" srcset="https://blog.xojo.com/wp-content/uploads/2025/03/image-2-1024x485.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/03/image-2-300x142.png 300w, https://blog.xojo.com/wp-content/uploads/2025/03/image-2-768x364.png 768w, https://blog.xojo.com/wp-content/uploads/2025/03/image-2-1536x727.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/03/image-2.png 1588w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="483" src="https://blog.xojo.com/wp-content/uploads/2025/03/image-3-1024x483.png" alt="Quiziverse Admin Categories" class="wp-image-14595" srcset="https://blog.xojo.com/wp-content/uploads/2025/03/image-3-1024x483.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/03/image-3-300x141.png 300w, https://blog.xojo.com/wp-content/uploads/2025/03/image-3-768x362.png 768w, https://blog.xojo.com/wp-content/uploads/2025/03/image-3-1536x724.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/03/image-3.png 1580w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="483" src="https://blog.xojo.com/wp-content/uploads/2025/03/image-4-1024x483.png" alt="Quiziverse Admin Questions" class="wp-image-14596" srcset="https://blog.xojo.com/wp-content/uploads/2025/03/image-4-1024x483.png 1024w, https://blog.xojo.com/wp-content/uploads/2025/03/image-4-300x141.png 300w, https://blog.xojo.com/wp-content/uploads/2025/03/image-4-768x362.png 768w, https://blog.xojo.com/wp-content/uploads/2025/03/image-4-1536x724.png 1536w, https://blog.xojo.com/wp-content/uploads/2025/03/image-4.png 1584w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>You can find the complete source code for <a href="https://github.com/xolabsro/Quiziverse" data-type="link" data-id="https://github.com/xolabsro/Quiziverse" target="_blank" rel="noreferrer noopener">Quiziverse on GitHub</a>, along with detailed documentation to help you get started.</p>



<p>Stay tuned for more exciting projects as we continue our Year of Code 2025 journey!</p>



<p><em>Gabriel is a digital marketing enthusiast who loves coding with Xojo to create cool software tools for any platform. He is always eager to learn and share new ideas!</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>



<p><strong>Year of Code Project</strong></p>



<ul class="wp-block-list">
<li><a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/">Year of Code: Kickoff</a></li>



<li><a href="https://blog.xojo.com/2025/01/15/year-of-code-2025-january-project/" target="_blank" rel="noreferrer noopener">January Project: Desktop Apps</a>&nbsp;|&nbsp;<a href="https://forum.xojo.com/t/year-of-code-2025-january-project-sharing/83927" target="_blank" rel="noreferrer noopener">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/02/11/year-of-code-2025-february-project/">February Project: Database Apps</a>&nbsp;|&nbsp;<a href="https://forum.xojo.com/t/2025-year-of-code-february" target="_blank" rel="noreferrer noopener">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/03/05/year-of-code-2025-march-project-web-apps/">March Project: Web Apps</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-march/84474?u=alyssa_foley">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/04/08/year-of-code-2025-april-project-user-interface/">April Project: User Interface</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-april-user-interface/84926">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/05/07/year-of-code-2025-may-project-mobile-apps/">May Project: Mobile Apps</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-may-is-mobile/85272">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/06/10/year-of-code-2025-june-project-cross-platform-code-class/">June Project: Code Sharing</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-june-is-code-sharing/85612">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/07/10/year-of-code-2025-july-project-charting/">July Project: Charting</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-july-is-charting/85896">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/08/07/year-of-code-2025-august-project-console-apps/">August Project: Console Apps</a> | <a href="https://forum.xojo.com/t/august-2025-year-of-code-console-apps/86203">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/09/08/year-of-code-2025-september-project-games/">September Project: Games</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-septgamer">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/10/13/year-of-code-2025-october-project-multi-platform-communication/">October Project: Multi-Platform</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-october-multi-platform-communication/86717">Forum Discussion</a></li>



<li><a href="https://blog.xojo.com/2025/11/10/year-of-code-2025-november-project-pdf-postcard-generator/">November Project: PDF</a> | <a href="https://forum.xojo.com/t/2025-year-of-code-november-pdf/86969">Forum Discussion</a></li>
</ul>



<p><strong>How to Play:</strong></p>



<p>Each month we&#8217;ll announce a new theme and share an example project of our own. Share your projects to the Xojo Forum thread for that month via GitHub (all the links you need are posted above ↑ ). Learn how to use <a href="https://blog.xojo.com/2024/04/02/using-xojo-and-github/">Xojo and GitHub</a>.</p>



<p><strong>The Prizes:</strong></p>



<p>Monthly winners get $100 at the Xojo store. Every month you submit a project is another chance to win the grand prize. The grand prize is $250 cash plus a Xojo Pro license and a year of GraffitiSuite and will be announce in December. Learn more about the <a href="https://blog.xojo.com/2025/01/09/year-of-code-2025-kickoff/#prizes">prizes</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Create a Tic-Tac-Toe Game in Xojo &#8211; Step-by-Step Tutorial</title>
		<link>https://blog.xojo.com/2024/12/05/create-a-tic-tac-toe-game-in-xojo-step-by-step-tutorial/</link>
		
		<dc:creator><![CDATA[Gabriel Ludosanu]]></dc:creator>
		<pubDate>Thu, 05 Dec 2024 15:30:00 +0000</pubDate>
				<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[DesktopCanvas]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=13994</guid>

					<description><![CDATA[Tic-tac-toe, a classic two-player strategy game where players take turns marking spaces in a 3&#215;3 grid. The objective is simple: be the first to get&#8230;]]></description>
										<content:encoded><![CDATA[
<p>Tic-tac-toe, a classic two-player strategy game where players take turns marking spaces in a 3&#215;3 grid. The objective is simple: be the first to get three of your symbols (X or O) in a row, either horizontally, vertically, or diagonally.</p>



<p>By the end of this tutorial, you will learn how to:</p>



<ul class="wp-block-list">
<li>Create a desktop game application in Xojo</li>



<li>Use DesktopCanvas for game board rendering</li>



<li>Implement game logic and state management</li>



<li>Handle user interactions</li>



<li>Add visual effects and animations</li>
</ul>


<div class="wp-block-image is-style-default">
<figure class="aligncenter is-resized"><img decoding="async" src="https://storage.googleapis.com/co-writer/images/HRIwK4xjWLXvNRyAbzXbq5t8wJF3/-1731493084073.webp" alt="Modern TicTacToe game in Xojo" style="width:482px;height:auto"/></figure>
</div>


<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Setting Up the Project</h2>



<h3 class="wp-block-heading">Launch Xojo and Create a New Project</h3>



<ul class="wp-block-list">
<li>Open Xojo IDE</li>



<li>Select &#8220;Desktop&#8221; project type</li>



<li>Set an Application Name (e.g., &#8220;TicTacToe&#8221;)</li>



<li>Click &#8220;Create&#8221;</li>
</ul>



<h3 class="wp-block-heading">Creating the TicTacToeGame Custom Control</h3>



<p>To have a clear and modular code structure, the game logic and user interface will be implemented in a subclassed DesktopCanvas control.</p>



<p>Here are several key advantages for this approach:</p>



<ul class="wp-block-list">
<li><strong>Encapsulation:</strong> It neatly bundles all the game&#8217;s logic (like checking for wins or handling player turns) and visual elements (drawing the board, animating moves) into a single, self-contained unit. This makes your code cleaner, easier to understand, and simpler to maintain. You can reuse this control in other projects without rewriting everything.</li>



<li><strong>Organization:</strong> A custom control promotes better code organization by separating the game&#8217;s functionality from the rest of your application&#8217;s code. This reduces complexity, especially if your application grows larger and includes other features.</li>



<li><strong>Reusability:</strong> Once you&#8217;ve created the TicTacToeGame control, you can easily reuse it in other Xojo projects. Just drag and drop it onto a window!</li>



<li><strong>Abstraction:</strong> The custom control provides an abstraction layer. The rest of your application doesn&#8217;t need to know the internal workings of the TicTacToe game; it only needs to interact with the control&#8217;s interface (like starting a new game or getting the current score). This makes it easier to modify or update the game logic without affecting other parts of your application.</li>
</ul>



<p>Now, here are the steps to create this custom control based on DesktopCanvas:</p>



<ol class="wp-block-list">
<li>Click the &#8220;Insert&#8221; menu</li>



<li>Select &#8220;Class&#8221;</li>



<li>Name the class &#8220;TicTacToeGame&#8221;</li>



<li>Set the &#8220;Super&#8221; to &#8220;DesktopCanvas&#8221;</li>
</ol>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="618" height="342" src="https://blog.xojo.com/wp-content/uploads/2024/11/image.png" alt="" class="wp-image-13998" srcset="https://blog.xojo.com/wp-content/uploads/2024/11/image.png 618w, https://blog.xojo.com/wp-content/uploads/2024/11/image-300x166.png 300w" sizes="auto, (max-width: 618px) 100vw, 618px" /></figure>
</div>



<div class="wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="596" height="236" src="https://blog.xojo.com/wp-content/uploads/2024/11/image-1.png" alt="" class="wp-image-13999" srcset="https://blog.xojo.com/wp-content/uploads/2024/11/image-1.png 596w, https://blog.xojo.com/wp-content/uploads/2024/11/image-1-300x119.png 300w" sizes="auto, (max-width: 596px) 100vw, 596px" /></figure>
</div>
</div>



<h2 class="wp-block-heading">TicTacToeGame Class Structure</h2>


<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img loading="lazy" decoding="async" width="554" height="950" src="https://blog.xojo.com/wp-content/uploads/2024/11/image-2.png" alt="" class="wp-image-14001" style="width:263px;height:auto" srcset="https://blog.xojo.com/wp-content/uploads/2024/11/image-2.png 554w, https://blog.xojo.com/wp-content/uploads/2024/11/image-2-175x300.png 175w" sizes="auto, (max-width: 554px) 100vw, 554px" /></figure>
</div>


<p>First, we start by defining some important constants and properties that will be used by the game class.</p>



<h3 class="wp-block-heading">Constants</h3>



<ol class="wp-block-list">
<li><code>Private Const kBoardSize as Number = 3</code>
<ul class="wp-block-list">
<li>Defines the grid dimensions (3&#215;3)</li>



<li>Used for iterating through board cells</li>



<li>Provides flexibility for potential future grid size changes</li>
</ul>
</li>



<li><code>Private Const kCellsPadding as Number = 40</code>
<ul class="wp-block-list">
<li>Controls spacing around X and O symbols</li>



<li>Ensures symbols don&#8217;t touch cell borders</li>



<li>Provides visual breathing room in cell drawings</li>
</ul>
</li>
</ol>



<h3 class="wp-block-heading">Properties</h3>



<h4 class="wp-block-heading">Game State Properties</h4>



<ol class="wp-block-list">
<li><code>Public Property boardState(2,2) As Integer</code>
<ul class="wp-block-list">
<li>2D array representing game board</li>



<li>Values:
<ul class="wp-block-list">
<li>0 = Empty cell</li>



<li>1 = Player X</li>



<li>2 = Player O</li>
</ul>
</li>
</ul>
</li>



<li><code>Public Property currentPlayer As Integer = 1</code>
<ul class="wp-block-list">
<li>Tracks current turn</li>



<li>1 = Player X</li>



<li>2 = Player O</li>
</ul>
</li>



<li><code>Public Property isGameOver As Boolean = False</code>
<ul class="wp-block-list">
<li>Indicates game completion status</li>



<li>Prevents further moves after game ends</li>
</ul>
</li>
</ol>



<h4 class="wp-block-heading">Rendering Properties</h4>



<pre class="wp-block-code"><code>Public Property CellHeight As Integer
Get
  Return Height / 3
End Get

Set
  
End Set
End Property

Public Property CellWidth As Integer
Get
  Return Width / 3
End Get

Set
  
End Set
End Property</code></pre>



<ol class="wp-block-list">
<li><code>CellHeight</code>, <code>CellWidth As Integer</code>
<ul class="wp-block-list">
<li>Computed properties</li>



<li>Dynamically calculate cell dimensions based on canvas size</li>



<li>Divide width/height by 3 for equal grid cells</li>
</ul>
</li>



<li><code>ColorBoard</code>, <code>ColorX</code>, <code>ColorO</code><code>As Color</code>
<ul class="wp-block-list">
<li>Store color schemes for board elements</li>



<li>Support dark/light mode themes</li>
</ul>
</li>
</ol>



<h4 class="wp-block-heading">Animation Properties</h4>



<ol class="wp-block-list">
<li><code>Public Property animationProgress As Double</code>
<ul class="wp-block-list">
<li>Tracks symbol drawing animation</li>



<li>Ranges from 0 to 1</li>



<li>Controls symbol scaling during placement</li>
</ul>
</li>



<li><code>Public Property animationTimer As Timer</code>
<ul class="wp-block-list">
<li>Manages animation timing</li>



<li>Triggers smooth symbol rendering</li>
</ul>
</li>
</ol>



<h4 class="wp-block-heading">Interaction Tracking</h4>



<ol class="wp-block-list">
<li><code>Public Property HoverCol As Integer = -1</code>and <code>Public Property HoverCol As Integer = -1</code>
<ul class="wp-block-list">
<li>Track mouse position over grid</li>



<li>Enable hover effect on empty cells</li>



<li>Provide visual feedback during gameplay</li>
</ul>
</li>
</ol>



<h4 class="wp-block-heading">Scoring Properties</h4>



<ol class="wp-block-list">
<li><code>scoreX</code> and <code>scoreO</code><code>As Integer</code>
<ul class="wp-block-list">
<li>Track win counts for each player</li>



<li>Updated after each game</li>
</ul>
</li>
</ol>



<p>The constants and properties defined above will be crucial in the next steps, allowing us to implement the key features: encapsulation of game logic and rendering, flexible customization, responsive dynamic sizing and interactions, and an enhanced user experience through animations and hover effects.</p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Event Definitions</h2>


<div class="wp-block-image">
<figure class="alignright size-full is-resized"><img loading="lazy" decoding="async" width="552" height="236" src="https://blog.xojo.com/wp-content/uploads/2024/11/image-3.png" alt="" class="wp-image-14003" style="width:263px;height:auto" srcset="https://blog.xojo.com/wp-content/uploads/2024/11/image-3.png 552w, https://blog.xojo.com/wp-content/uploads/2024/11/image-3-300x128.png 300w" sizes="auto, (max-width: 552px) 100vw, 552px" /></figure>
</div>


<p>To make sure our game class is complete, we will create two custom event definitions that will be used later throughout the game.</p>



<h3 class="wp-block-heading">GameStatus Event</h3>



<pre class="wp-block-code"><code>Event GameStatus(info As String, playerTurn As String = "", scoreX As Integer, scoreO As Integer)</code></pre>



<ul class="wp-block-list">
<li>Purpose: Tracks and communicates the current state of the game</li>



<li>Parameters:
<ol class="wp-block-list">
<li><code>info</code>: A string describing the current game status</li>



<li><code>playerTurn</code>: Optional parameter indicating which player&#8217;s turn it is</li>



<li><code>scoreX</code>: Current score for Player X</li>



<li><code>scoreO</code>: Current score for Player O</li>
</ol>
</li>
</ul>



<h3 class="wp-block-heading">GameOver Event</h3>



<pre class="wp-block-code"><code>Event GameOver(result As String, scoreX As Integer, scoreO As Integer)</code></pre>



<ul class="wp-block-list">
<li>Purpose: Signals the conclusion of the game with a winner or draw</li>



<li>Parameters:
<ol class="wp-block-list">
<li><code>result</code>: A string describing the game&#8217;s final outcome (e.g., &#8220;X Wins&#8221;, &#8220;O Wins&#8221;, &#8220;Draw&#8221;)</li>



<li><code>scoreX</code>: Final score for Player X</li>



<li><code>scoreO</code>: Final score for Player O</li>
</ol>
</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Event Handlers in Tic-Tac-Toe Game</h2>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="542" height="458" src="https://blog.xojo.com/wp-content/uploads/2024/11/image-4.png" alt="" class="wp-image-14005" style="width:222px;height:auto" srcset="https://blog.xojo.com/wp-content/uploads/2024/11/image-4.png 542w, https://blog.xojo.com/wp-content/uploads/2024/11/image-4-300x254.png 300w" sizes="auto, (max-width: 542px) 100vw, 542px" /></figure>



<h3 class="wp-block-heading">Closing Event</h3>



<pre class="wp-block-code"><code>Sub Closing() Handles Closing
  // This event ensures that the animation timer is properly disabled and its handler is removed to prevent memory leaks or unexpected behavior.
  // Clean up the animation timer when the control is closing
  If animationTimer &lt;&gt; Nil Then
    animationTimer.Enabled = False
    RemoveHandler animationTimer.Action, AddressOf AnimationStep
    animationTimer = Nil
  End If
End Sub</code></pre>



<ul class="wp-block-list">
<li>Ensures clean resource management</li>



<li>Disables and removes timer to prevent memory leaks</li>



<li>Called when the control is being destroyed</li>
</ul>



<h3 class="wp-block-heading">MouseDown Event</h3>



<pre class="wp-block-code"><code>Function MouseDown(x As Integer, y As Integer) Handles MouseDown as Boolean
  // This event handles mouse click actions on the game board.
  // It checks if the game is over; if not, it calculates the row and column of the click.
  // If the clicked cell is empty, it records the player's move, checks for a winner, and toggles the current player.
  
  // Handle mouse clicks on the game board
  If isGameOver Then
    Return True
  End If
  
  // Calculate the row and column based on the click position
  Var row As Integer = y \ CellHeight
  Var col As Integer = x \ CellWidth
  
  // If the clicked cell is empty, make a move
  If boardState(row, col) = 0 Then
    boardState(row, col) = currentPlayer
    StartAnimation(row, col)
    
    // Reset hover position after a move
    hoverRow = -1
    hoverCol = -1
    
    // Refresh only the affected cell
    Refresh(col * CellWidth, row * CellHeight, CellWidth, CellHeight)
    
    // Check for a winner or a draw
    Var winner As Integer = CheckWinner()
    If winner &gt; 0 Then
      UpdateScore(winner)
      GameStatus("Player " + PlayerSymbol(winner) + " wins!", scoreX, scoreO)
      isGameOver = True
      GameOver("Player " + PlayerSymbol(winner) + " wins!", scoreX, scoreO)
      
      // Refresh the entire board to show the winning line
      Refresh(True)
    ElseIf Me.IsBoardFull() Then
      GameStatus("It's a draw!", scoreX, scoreO)
      isGameOver = True
      GameOver("Draw", scoreX, scoreO)
    Else
      // Switch to the other player
      currentPlayer = If(currentPlayer = 1, 2, 1)
      GameStatus("Player " + PlayerSymbol(currentPlayer) + "'s turn", PlayerSymbol(currentPlayer), scoreX, scoreO)
    End If
  End If
  
  Return True
End Function</code></pre>



<ul class="wp-block-list">
<li>Handles player moves</li>



<li>Validates move legality</li>



<li>Checks for win/draw conditions</li>



<li>Switches players</li>
</ul>



<h3 class="wp-block-heading">MouseExit and MouseMove Events</h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<pre class="wp-block-code"><code>Sub MouseExit() Handles MouseExit
  // This event is triggered when the mouse cursor exits the game board area.
  // It clears the hover effect to avoid leaving any visual artifacts on the board when the mouse is moved away.
  
  If hoverRow &gt;= 0 And hoverRow &lt; kBoardSize And hoverCol &gt;= 0 And hoverCol &lt; kBoardSize Then
    Var oldHoverRow As Integer = hoverRow
    Var oldHoverCol As Integer = hoverCol
    
    hoverRow = -1
    hoverCol = -1
    
    // Refresh only the cell that was previously hovered
    Refresh(oldHoverCol * CellWidth, oldHoverRow * CellHeight, CellWidth, CellHeight)
  End If
End Sub</code></pre>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<pre class="wp-block-code"><code>Sub MouseMove(x As Integer, y As Integer) Handles MouseMove
  // This event handles mouse movement over the game board.
  // It updates the hover effect when the mouse moves to a new cell, providing visual feedback.
  
  If Not isGameOver Then
    Var newHoverRow As Integer = y \ CellHeight
    Var newHoverCol As Integer = x \ CellWidth
    
    If newHoverRow &lt;&gt; hoverRow Or newHoverCol &lt;&gt; hoverCol Then
      Var oldHoverRow As Integer = hoverRow
      Var oldHoverCol As Integer = hoverCol
      
      hoverRow = newHoverRow
      hoverCol = newHoverCol
      
      // Refresh the old hover cell (if it was valid)
      If oldHoverRow &gt;= 0 And oldHoverRow &lt; 3 And oldHoverCol &gt;= 0 And oldHoverCol &lt; 3 Then
        Refresh(oldHoverCol * CellWidth, oldHoverRow * CellHeight, CellWidth, CellHeight)
      End If
      
      // Refresh the new hover cell
      Refresh(hoverCol * CellWidth, hoverRow * CellHeight, CellWidth, CellHeight)
    End If
  End If
End Sub</code></pre>
</div>
</div>



<ul class="wp-block-list">
<li>Provides visual hover feedback</li>



<li>Tracks mouse movement across grid</li>



<li>Refreshes only changed cells</li>
</ul>



<h3 class="wp-block-heading">Opening Event</h3>



<pre class="wp-block-code"><code>Sub Opening() Handles Opening
  // This event initializes the board colors based on the current system theme (dark mode or light mode) and starts a new game.
  
  // Set up colors of the board lines, for the X's and O's
  If Color.IsDarkMode = True Then
    ColorBoard = Color.RGB(178, 161, 149)
    ColorX = Color.RGB(228, 182, 88)
    ColorO = Color.RGB(253, 161, 97)
  Else
    ColorBoard = Color.RGB(130, 110, 92)
    ColorX = Color.RGB(228, 182, 88)
    ColorO = Color.RGB(253, 161, 97)
  End If
  
  NewGame()
End Sub</code></pre>



<ul class="wp-block-list">
<li>Initializes color theme</li>



<li>Supports dark and light modes</li>



<li>Starts a new game automatically</li>
</ul>



<h3 class="wp-block-heading">Paint Event</h3>



<pre class="wp-block-code"><code>Sub Paint(g As Graphics, areas() As Rect) Handles Paint
  // This event is responsible for drawing the game board, hover effects, player symbols (X's and O's), and the winning line.
  // It is called whenever the game board needs to be redrawn.
  
  // Draw the board
  g.DrawingColor = ColorBoard
  g.DrawLine(Width/3, 0, Width/3, Height)
  g.DrawLine(2*Width/3, 0, 2*Width/3, Height)
  g.DrawLine(0, Height/3, Width, Height/3)
  g.DrawLine(0, 2*Height/3, Width, 2*Height/3)
  
  // Draw hover effect
  DrawHoverEffect(g)
  
  // Draw X's and O's
  g.PenSize = 8
  For row As Integer = 0 To 2
    For col As Integer = 0 To 2
      If boardState(row, col) = 1 Then
        DrawX(g, row, col)
      ElseIf boardState(row, col) = 2 Then
        DrawO(g, row, col)
      End If
    Next
  Next
  
  // Draw winning line if the game is over
  If isGameOver Then
    DrawWinningLine(g)
  End If
End Sub</code></pre>



<ul class="wp-block-list">
<li>Renders game board</li>



<li>Draws grid lines</li>



<li>Manages visual game state</li>



<li>Supports dynamic rendering</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Animation and Drawing Methods</h2>



<h3 class="wp-block-heading">1. AnimationStep</h3>



<pre class="wp-block-code"><code>Public Sub AnimationStep(sender As Timer)
  // This method is called by the animation timer (animationTimer property) to progress the animation of a newly placed symbol.
  // It increments the animation progress and stops the timer once the animation is complete.
  
  // Progress the animation
  animationProgress = animationProgress + 0.1
  If animationProgress &gt;= 1 Then
    animationTimer.Enabled = False
    animationProgress = 1
  End If
  
  // Refresh only the cell being animated
  Refresh(lastPlayedCol * CellWidth, lastPlayedRow * CellHeight, CellWidth, CellHeight)
  
  // If the animation is complete, stop the timer
  If animationProgress &gt;= 1 Then
    animationTimer.Enabled = False
  End If
End Sub</code></pre>



<ul class="wp-block-list">
<li>Manages symbol placement animation</li>



<li>Gradually scales symbol from 0 to 1</li>



<li>Updates only the recently played cell</li>
</ul>



<h3 class="wp-block-heading">2. DrawX and DrawO</h3>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<pre class="wp-block-code"><code>Sub MouseExit() Handles MouseExit
  // This event is triggered when the mouse cursor exits the game board area.
  // It clears the hover effect to avoid leaving any visual artifacts on the board when the mouse is moved away.
  
  If hoverRow &gt;= 0 And hoverRow &lt; kBoardSize And hoverCol &gt;= 0 And hoverCol &lt; kBoardSize Then
    Var oldHoverRow As Integer = hoverRow
    Var oldHoverCol As Integer = hoverCol
    
    hoverRow = -1
    hoverCol = -1
    
    // Refresh only the cell that was previously hovered
    Refresh(oldHoverCol * CellWidth, oldHoverRow * CellHeight, CellWidth, CellHeight)
  End If
End Sub</code></pre>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<pre class="wp-block-code"><code>Sub MouseMove(x As Integer, y As Integer) Handles MouseMove
  // This event handles mouse movement over the game board.
  // It updates the hover effect when the mouse moves to a new cell, providing visual feedback.
  
  If Not isGameOver Then
    Var newHoverRow As Integer = y \ CellHeight
    Var newHoverCol As Integer = x \ CellWidth
    
    If newHoverRow &lt;&gt; hoverRow Or newHoverCol &lt;&gt; hoverCol Then
      Var oldHoverRow As Integer = hoverRow
      Var oldHoverCol As Integer = hoverCol
      
      hoverRow = newHoverRow
      hoverCol = newHoverCol
      
      // Refresh the old hover cell (if it was valid)
      If oldHoverRow &gt;= 0 And oldHoverRow &lt; 3 And oldHoverCol &gt;= 0 And oldHoverCol &lt; 3 Then
        Refresh(oldHoverCol * CellWidth, oldHoverRow * CellHeight, CellWidth, CellHeight)
      End If
      
      // Refresh the new hover cell
      Refresh(hoverCol * CellWidth, hoverRow * CellHeight, CellWidth, CellHeight)
    End If
  End If
End Sub</code></pre>
</div>
</div>



<ul class="wp-block-list">
<li>Draws X and O symbols with animation</li>



<li>Centers symbol in cell</li>



<li>Scales symbol based on animation progress</li>
</ul>



<h3 class="wp-block-heading">3. DrawHoverEffect</h3>



<pre class="wp-block-code"><code>Public Sub DrawHoverEffect(g As Graphics)
  // This method draws a semi-transparent hover effect over the cell that the mouse is currently hovering over.
  // It only draws the effect if the game is not over and the hovered cell is empty.
  
  If Not isGameOver And hoverRow &gt;= 0 And hoverRow &lt; 3 And hoverCol &gt;= 0 And hoverCol &lt; 3 Then
    If boardState(hoverRow, hoverCol) = 0 Then
      g.DrawingColor = Color.RGB(255, 255, 255, 250) // Semi-transparent white
      g.FillRectangle(hoverCol * CellWidth, hoverRow * CellHeight, CellWidth, CellHeight)
    End If
  End If
End Sub</code></pre>



<ul class="wp-block-list">
<li>Provides visual feedback on hoverable cells</li>



<li>Applies semi-transparent white overlay</li>



<li>Only affects empty, unplayed cells</li>
</ul>



<h3 class="wp-block-heading">4. DrawWinningLine</h3>



<pre class="wp-block-code"><code>Public Sub DrawWinningLine(g As Graphics)
  // This method draws a semi-transparent green line over the winning combination on the board if a player has won.
  
  // Draw the winning line if there is a winner
  If winningLine.Count = 6 Then
    g.DrawingColor = Color.RGB(0, 255, 0, 128) // Semi-transparent green
    g.PenSize = 2
    
    Var startX As Integer = winningLine(1) * cellWidth + cellWidth / 2
    Var startY As Integer = winningLine(0) * cellHeight + cellHeight / 2
    Var endX As Integer = winningLine(5) * cellWidth + cellWidth / 2
    Var endY As Integer = winningLine(4) * cellHeight + cellHeight / 2
    
    g.DrawLine(startX, startY, endX, endY)
  End If
End Sub</code></pre>



<ul class="wp-block-list">
<li>Draws a semi-transparent green line</li>



<li>Highlights the winning combination</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Game Logic Methods</h2>



<h3 class="wp-block-heading">1. CheckWinner</h3>



<pre class="wp-block-code"><code>Public Function CheckWinner() As Integer
  // This method checks the board for a winner by evaluating rows, columns, and diagonals.
  // It returns the winning player (1 or 2) or 0 if there is no winner.
  
  
  // Check rows
  For i As Integer = 0 To kBoardSize - 1
    If boardState(i, 0) &lt;&gt; 0 And boardState(i, 0) = boardState(i, 1) And boardState(i, 1) = boardState(i, 2) Then
      winningLine = Array(i, 0, i, 1, i, 2)
      Return boardState(i, 0)
    End If
  Next
  
  // Check columns
  For j As Integer = 0 To 2
    If boardState(0, j) &lt;&gt; 0 And boardState(0, j) = boardState(1, j) And boardState(1, j) = boardState(2, j) Then
      winningLine = Array(0, j, 1, j, 2, j)
      Return boardState(0, j)
    End If
  Next
  
  // Check diagonals
  If boardState(0, 0) &lt;&gt; 0 And boardState(0, 0) = boardState(1, 1) And boardState(1, 1) = boardState(2, 2) Then
    winningLine = Array(0, 0, 1, 1, 2, 2)
    Return boardState(0, 0)
  End If
  
  If boardState(0, 2) &lt;&gt; 0 And boardState(0, 2) = boardState(1, 1) And boardState(1, 1) = boardState(2, 0) Then
    winningLine = Array(0, 2, 1, 1, 2, 0)
    Return boardState(0, 2)
  End If
  
  winningLine.ResizeTo(-1)
  Return 0 // No winner yet
End Function</code></pre>



<ul class="wp-block-list">
<li>Scans board for winning combinations</li>



<li>Returns winning player or 0</li>



<li>Stores winning line coordinates</li>
</ul>



<h3 class="wp-block-heading">2. IsBoardFull</h3>



<pre class="wp-block-code"><code>Public Function IsBoardFull() As Boolean
  // This method checks if the board is completely filled with no empty cells.
  // It returns true if the board is full, otherwise false.
  
  // Check if the board is full (no empty cells)
  For i As Integer = 0 To kBoardSize - 1
    For j As Integer = 0 To kBoardSize - 1
      If boardState(i, j) = 0 Then
        Return False
      End If
    Next
  Next
  Return True
End Function</code></pre>



<ul class="wp-block-list">
<li>Checks if all cells are occupied</li>



<li>Determines if game is a draw</li>
</ul>



<h3 class="wp-block-heading">3. NewGame</h3>



<pre class="wp-block-code"><code>Public Sub NewGame()
  // This method resets the game state to start a new game.
  // It clears the board, resets the current player to Player 1, and updates the game status.
  
  // Reset the game state for a new game
  For i As Integer = 0 To 8
    boardState(i \ 3, i Mod 3) = 0
  Next
  currentPlayer = 1
  isGameOver = False
  animationProgress = 1
  If animationTimer &lt;&gt; Nil Then
    animationTimer.Enabled = False
  End If
  GameStatus("Player " + PlayerSymbol(currentPlayer) + "'s turn", scoreX, scoreO)
  winningLine.ResizeTo(-1)
  Refresh()
End Sub</code></pre>



<ul class="wp-block-list">
<li>Resets game to initial state</li>



<li>Clears board</li>



<li>Resets player turn</li>
</ul>



<h3 class="wp-block-heading">4. UpdateScore</h3>



<pre class="wp-block-code"><code>Public Sub UpdateScore(winner As Integer)
  // This method updates the score for the winning player by incrementing the respective score counter.
  
  // Update the score for the winning player
  If winner = 1 Then
    scoreX = scoreX + 1
  ElseIf winner = 2 Then
    scoreO = scoreO + 1
  End If
End Sub</code></pre>



<ul class="wp-block-list">
<li>Increments score for winning player</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Utility Methods</h2>



<h3 class="wp-block-heading">1. PlayerSymbol</h3>



<pre class="wp-block-code"><code>Public Function PlayerSymbol(player As Integer) As String
  // This method returns the symbol ('X' or 'O') corresponding to the player number (1 or 2).
  Return If(player = 1, "X", "O")
End Function</code></pre>



<ul class="wp-block-list">
<li>Converts player number to symbol</li>
</ul>



<h3 class="wp-block-heading">2. StartAnimation</h3>



<pre class="wp-block-code"><code>Public Sub StartAnimation(row As Integer, col As Integer)
  // This method initializes and starts the animation for a newly placed symbol,
  // by setting the target cell and resetting the animation progress.
  
  // Start the animation for a newly placed symbol
  lastPlayedRow = row
  lastPlayedCol = col
  animationProgress = 0
  
  If animationTimer = Nil Then
    animationTimer = New Timer
    animationTimer.Period = 16 // equivalent of 60 FPS
    AddHandler animationTimer.Action, AddressOf AnimationStep
  End If
  
  animationTimer.Enabled = True
  animationTimer.RunMode = Timer.RunModes.Multiple
End Sub</code></pre>



<ul class="wp-block-list">
<li>Initializes symbol animation</li>



<li>Sets up timer for smooth rendering</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<h2 class="wp-block-heading">Usage Instructions</h2>



<p>To use the <code>TicTacToeGame</code> control in your Xojo project:</p>



<ol class="wp-block-list">
<li><strong>Drag and Drop:</strong> Drag the <code>TicTacToeGame</code> icon (it should look like a small canvas) from the Navigator (the left side of the IDE) onto your <code>Window1</code> or any other window you want to use.
<ul class="wp-block-list">
<li>A <code>TicTacToeGame</code> instance will appear on the window. You can resize and position it as needed.</li>
</ul>
</li>



<li><strong>Initialize:</strong> While not strictly required, you might want to initialize the game in the <code>Window1.Open</code> event handler. This ensures the game is ready to play as soon as the window opens. You can do this by adding the following code to the <code>Window1.Open</code> event:<br><code>// Assuming 'TicTacToeGame1' is the name of your control instance on the window</code><br><code>TicTacToeGame1.NewGame</code><br>This will call the <code>NewGame</code> method of your custom control, setting up the board and starting a new game.</li>



<li><strong>Run the Project:</strong> Run your Xojo project. You should see the TicTacToe board on your window, ready to play!</li>
</ol>



<p>I highly suggest downloading the complete TicTacToe Xojo project for the game. If you find anything unclear, refer to this tutorial for explanations. <a href="https://files.xojo.com/BlogExamples/Tic-Tac-Toe Game.xojo_binary_project">Download the Xojo project</a>.</p>



<h2 class="wp-block-heading">Next Steps:</h2>



<p>Congratulations! You&#8217;ve successfully built a fully functional, modern tic-tac-toe game in Xojo. This project is a great foundation for exploring more advanced game development concepts, animations and how to make custom UI elements based on Xojo&#8217;s powerful <a href="https://documentation.xojo.com/api/user_interface/desktop/desktopcanvas.html#desktopcanvas" data-type="link" data-id="https://documentation.xojo.com/api/user_interface/desktop/desktopcanvas.html#desktopcanvas" target="_blank" rel="noreferrer noopener">DesktopCanvas</a> control.</p>



<p>Now that you understand the basics, here are some ideas to take your TicTacToe game to the next level:</p>



<ul class="wp-block-list">
<li><strong>Artificial Intelligence (AI):</strong> Implement a simple AI opponent so players can play against the computer. You could start with a random move generator and then explore more sophisticated algorithms like Minimax. Xojo already provides fully working AI integration examples.</li>



<li><strong>Different Game Modes:</strong> Add options for different board sizes (e.g., 4&#215;4, 5&#215;5) or variations of tic-tac-toe.</li>



<li><strong>Online Multiplayer:</strong> Enable players to challenge each other online using Xojo&#8217;s networking capabilities.</li>



<li><strong>Enhanced UI/UX:</strong> Improve the user interface with custom graphics, sound effects, and a more polished look and feel. Consider adding a timer.</li>



<li><strong>Go Multiplatform</strong>: Port the TicTacToeGame class to Mobile and Web projects.</li>
</ul>



<p>We encourage you to experiment, get creative, and explore these possibilities. Share your creations and connect with other Xojo developers in <a target="_blank" rel="noreferrer noopener" href="https://forum.xojo.com/">the forums</a> to learn and grow together. Happy coding!</p>



<p><em>Gabriel is a digital marketing enthusiast who loves coding with Xojo to create cool software tools for any platform. He is always eager to learn and share new ideas!</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Cosmic Trader: A Game Built with Xojo Web</title>
		<link>https://blog.xojo.com/2024/09/17/cosmic-trader-a-game-built-with-xojo-web/</link>
		
		<dc:creator><![CDATA[Ricardo Cruz]]></dc:creator>
		<pubDate>Tue, 17 Sep 2024 20:09:12 +0000</pubDate>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[AI]]></category>
		<category><![CDATA[Container]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[WebListBox]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=13618</guid>

					<description><![CDATA[I truly enjoy creating things with Xojo. This time, I built a little game with Xojo Web just to see if it was possible. In&#8230;]]></description>
										<content:encoded><![CDATA[
<p>I truly enjoy creating things with Xojo. This time, I built a little game with Xojo Web just to see if it was possible. In this post, I will talk about what I liked and what I had difficulties with while programming it.</p>



<p>The reason to create this kind of project, as the maintainer of the Xojo Web framework, is to find pain points and bugs in larger projects, as the issue reports I normally work with are very specific sample projects demonstrating a bug. The next Xojo release, 2024r3, will come with some bug fixes I found while building Cosmic Trader.</p>



<h2 class="wp-block-heading">Final Result</h2>



<p>Let&#8217;s begin at the end. Give the game a try and then come back to this blog post. It&#8217;s a very simple space trading game, don&#8217;t expect too much from it, but I hope you enjoy it.</p>



<p>It can be played from the following URL:<br><a href="https://cosmictrader.rcruz.es" target="_blank" rel="noreferrer noopener nofollow">https://cosmictrader.rcruz.es</a></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="625" src="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.16-1024x625.png" alt="" class="wp-image-13619" srcset="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.16-1024x625.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.16-300x183.png 300w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.16-768x469.png 768w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.16.png 1252w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="625" src="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.32-1024x625.png" alt="" class="wp-image-13620" srcset="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.32-1024x625.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.32-300x183.png 300w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.32-768x469.png 768w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-8.53.32.png 1252w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">The Challenge</h2>



<p>Create a simple game using Xojo Web, without writing a line of JavaScript, or even using the Web SDK.</p>



<p>In addition, while all this could be just a couple of WebListBox and WebButton controls, I really wanted this game to look like an actual game. As you can see in the screenshots, unless you check the code, nobody will notice (or care!) it&#8217;s a Xojo Web application.</p>



<p>As you can imagine, Xojo Web was not created with the idea of building web based games. In order to make it easier for the developer, everything is processed server side: When you press a button, the browser will send a notification to the server, your code written in Xojo will be executed and, finally, the response will be sent back to the browser.</p>



<p>That&#8217;s the known knowns. I knew the latency would be a problem, but I&#8217;ve found more.</p>



<h2 class="wp-block-heading">What I&#8217;ve Enjoyed</h2>



<p>Implementing the first prototype was really easy using the tools Xojo Web offers. For example, in the prototype, instead of the custom popover I ended up building for buying and selling, I just used some contextual menus:</p>



<figure class="wp-block-video"><video height="732" style="aspect-ratio: 1072 / 732;" width="1072" controls src="https://blog.xojo.com/wp-content/uploads/2024/09/cosmic-trader-early-prototype.mp4"></video></figure>



<p>You can go very far and prototype your idea very quickly this way. This helped me to deploy and share the game with a few friends and gather some initial feedback.</p>



<p>Once you have the game mechanics, you can iterate as much as you want until the game is ready. The welcome screen with the game logo wasn&#8217;t added until very late. Just so you can compare, this is how the current version looks:</p>



<figure class="wp-block-video"><video height="598" style="aspect-ratio: 946 / 598;" width="946" controls src="https://blog.xojo.com/wp-content/uploads/2024/09/cosmic-trader-current-version.mp4"></video></figure>



<p>Much better! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f60e.png" alt="😎" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>I&#8217;ve really enjoyed being able to use Containers for building custom controls and reusing them. Also, being able to just drop some images into the IDE and assign them to image viewers is very pleasant.</p>



<p>From the IDE preview, it&#8217;s deadly easy to identify where my ship entity is, click on it, then edit the code if needed:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="720" src="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-9.32.10-1024x720.png" alt="" class="wp-image-13624" srcset="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-9.32.10-1024x720.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-9.32.10-300x211.png 300w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-9.32.10-768x540.png 768w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-9.32.10-1536x1080.png 1536w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-9.32.10-2048x1440.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>Navigating through the project is a joy compared to jumping through piles of code in plain text files.</p>



<p>I&#8217;ve also found having Control Sets useful, allowing me to implement the Pressed event just once for all the planets, for example.</p>



<h2 class="wp-block-heading">Roadblocks and How I Handled Them</h2>



<p>That said, I found some difficulties. All of them were due the nature of web projects. When you travel from one planet to another, you will hear an engine sound. It would be much (much!) easier to know when I should stop the sound in a Desktop or a Mobile project.</p>



<p>Having to deal with latency means I had to use a timer and guess more or less how many milliseconds is reasonable before stopping the sound. Using the same amount of time as the animation would cause the sound to continue playing after the ship had arrived at its destination, again due the latency.</p>



<p>Where I spent most of the time was optimizing the images. Specifically, delivering the images. When you play the game locally, everything works pretty fast. I found this flickering issue once I deployed the game for the first time using the custom popovers:</p>



<figure class="wp-block-video"><video height="670" style="aspect-ratio: 1276 / 670;" width="1276" controls src="https://blog.xojo.com/wp-content/uploads/2024/09/cosmic-trader-flickering-issue.mp4"></video></figure>



<p>This is something that you just don&#8217;t need to think about with the typical database application you normally build with Xojo Web. But if you build a lot of images on the fly, it will mean the browser will have to download them again and again.</p>



<p>In order to optimize it, instead of using a WebImageViewer.Image property, you could store WebImage instances. Using WebImageViewer.URL pointing to the WebImage.URL property of those instances will make the browser first check if it has downloaded that URL before. If so, bingo! It will reuse the image without having to re-download it again.</p>



<p>If you go back to the game, cache is the reason behind the &#8220;New Game&#8221; button, from the welcome screen, and the &#8220;Sell Everything&#8221; button having the same width. It wasn&#8217;t a coincidence, that means a browser cache hit.</p>



<p>Last but not least, when I shared the URL with some friends, they told me it didn&#8217;t look great on mobile. So I had to change the stats a bit so they fit in a mobile screen. While in this case it wasn&#8217;t a big deal, at Xojo we know making responsive web applications must be easier, and we will improve the workflow in future releases.</p>



<p>It would be much easier to use the Web SDK for some of those controls. If I was creating a game seriously, I&#8217;d 100% personally prefer creating some custom controls to allow some code to run on the browser side, using the Web SDK with JavaScript or TypeScript, to avoid dealing with latency or round-trips.</p>



<h2 class="wp-block-heading">Using AI for Creativity</h2>



<p>I personally don&#8217;t find any joy using AI for coding. I always end up frustrated by how it hallucinates and keep proposing, very confidently, things that just don&#8217;t exist. I understand some might like it but, in the end, I just like coding.</p>



<p>But for a second brain and helping me with (my lack of) creativity&#8230; oh boy, that&#8217;s another story. The game idea came from a conversation with Claude AI. Initially, it came up with tons of features and ideas that would require me (and a team of another 100 people) to work on it for several years. I kept asking it to simplify it until I felt it was approachable:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="415" src="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-10.19.09-1024x415.png" alt="" class="wp-image-13625" srcset="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-10.19.09-1024x415.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-10.19.09-300x121.png 300w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-10.19.09-768x311.png 768w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-10.19.09-1536x622.png 1536w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-09-16-a-las-10.19.09.png 1768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>After implementing the game mechanics, I felt the game didn&#8217;t make any sense. I mean, why 30 turns exactly? Why 5 planets? Why can&#8217;t I go somewhere else to trade? Why do I have to trade at all?&#8230; While it is still fiction, the AI wrote a reasonable background story that added some depth to the game. That&#8217;s what you will be reading when playing Cosmic Trader.</p>



<p>No spoilers, but there are still a few features and game mechanics, recommended by the AI, that I left for future releases.</p>



<p>While working on this game, I even had a little ant invasion at home. The AI came up with a multiplayer ant colony simulator game idea that I will probably never implement, but who knows!</p>



<p>For the logo, I had some spare credits to use with DreamStudio. I had to retouch it using Affinity Photo, but that&#8217;s it:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="256" src="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-07-30-a-las-12.32.26-1024x256.png" alt="" class="wp-image-13626" srcset="https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-07-30-a-las-12.32.26-1024x256.png 1024w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-07-30-a-las-12.32.26-300x75.png 300w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-07-30-a-las-12.32.26-768x192.png 768w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-07-30-a-las-12.32.26-1536x385.png 1536w, https://blog.xojo.com/wp-content/uploads/2024/09/Captura-de-pantalla-2024-07-30-a-las-12.32.26-2048x513.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>All in all, and while a team of real humans will always be much better, I reckon AI helped me a lot with this experiment.</p>



<h2 class="wp-block-heading">Credits and Acknowledgements</h2>



<p>I could focus on building the game thanks to using the <a href="https://kenney.nl" target="_blank" rel="noreferrer noopener nofollow">Kenney game assets</a>. The background music author is <a href="https://pixabay.com/users/the_mountain-3616498/" target="_blank" rel="noreferrer noopener nofollow">Dmitrii Kolesnikov</a>, make sure to check his profile.</p>



<p>Thanks to Claude for being my second brain for this project. And, of course, thanks to Xojo. It wouldn&#8217;t be as fun without it.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>I enjoyed building this project a lot. I learned things, and I fixed some bugs I found. Did you know you couldn&#8217;t add a WebStyle CSS transition without adding other styles? Me neither, but it will be fixed in Xojo 2024r3.</p>



<p>Happy coding!</p>



<p><em>Ricardo has always been curious about how things work. Growing up surrounded by computers</em> he became interested in <em>web technologies in the dial-up connections era. Xojo has been his secret weapon and language of preference since 2018. When he’s not online, chances are he will be scuba diving … or crocheting amigurumis. Find Ricardo on Twitter <a href="https://web.archive.org/web/20220805000833/https://www.twitter.com/piradoiv" target="_blank" rel="noreferrer noopener">@piradoiv</a>.</em></p>
]]></content:encoded>
					
		
		<enclosure url="https://blog.xojo.com/wp-content/uploads/2024/09/cosmic-trader-early-prototype.mp4" length="970692" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2024/09/cosmic-trader-current-version.mp4" length="776410" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2024/09/cosmic-trader-flickering-issue.mp4" length="295405" type="video/mp4" />

			</item>
		<item>
		<title>Conway&#8217;s Game of Life</title>
		<link>https://blog.xojo.com/2022/05/11/conways-game-of-life/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 11 May 2022 17:22:52 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=10328</guid>

					<description><![CDATA[The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. You've probably seen this around in some form or another, but I ran across it again recently and thought it would be fun to implement in Xojo.]]></description>
										<content:encoded><![CDATA[
<p>The <a href="https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life">Game of Life</a>, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970. You&#8217;ve probably seen this around in some form or another, but I ran across it again recently and thought it would be fun to implement in Xojo.</p>



<p>The way it works is that you have a grid of cells. The cells can turn from alive (on) to dead (off) depending on some simple rules:</p>



<ol class="wp-block-list"><li>Any live cell with two or three live neighbors survives.</li><li>Any dead cell with three live neighbors becomes a live cell.</li><li>All other live cells die in the next generation. Similarly, all other dead cells stay dead.</li></ol>



<p>You start a game of life with your seed pattern and then see how it progress through multiple generations. Here is how the pattern &#8220;The R-pentomino&#8221; looks:</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="800" height="502" src="https://blog.xojo.com/wp-content/uploads/2022/04/CleanShot-2022-04-27-at-16.22.32.gif" alt="" class="wp-image-10329"/></figure>



<p>To use Life, draw a pattern in the grid using the mouse. There are several sample patterns on the <a href="https://en.wikipedia.org/wiki/Conway's_Game_of_Life">Game of Life Wikipedia page</a>. After drawing the pattern, click Start.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://blog.xojo.com/wp-content/uploads/2022/05/CleanShot-2022-05-02-at-14.25.12@2x-1024x924.png" alt="" class="wp-image-10336" width="665" height="599" srcset="https://blog.xojo.com/wp-content/uploads/2022/05/CleanShot-2022-05-02-at-14.25.12@2x-1024x924.png 1024w, https://blog.xojo.com/wp-content/uploads/2022/05/CleanShot-2022-05-02-at-14.25.12@2x-300x271.png 300w, https://blog.xojo.com/wp-content/uploads/2022/05/CleanShot-2022-05-02-at-14.25.12@2x-768x693.png 768w, https://blog.xojo.com/wp-content/uploads/2022/05/CleanShot-2022-05-02-at-14.25.12@2x.png 1418w" sizes="auto, (max-width: 665px) 100vw, 665px" /></figure>



<p>The Xojo project tracks the cells in a two-dimensional array and applies the rules to the array, creating a new array that is then drawn in a Canvas.</p>



<p>The primary method is called Life() and looks like this:</p>



<pre class="wp-block-preformatted">Public Sub Life()
  // Loop through all the cells and apply these rules.
  
  // https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
  
  // 1. Any live cell With two Or three live neighbours survives.
  // 2. Any dead cell With three live neighbours becomes a live cell.
  // 3. All other live cells die In the Next generation. Similarly, 
  //    all other dead cells stay dead.
  
  // Start with a new blank cell grid and apply rules to it
  // based on the existing cell grid
  
  Var newCells(1, 1) As Boolean
  
  Var xMax As Integer = Cells.LastIndex(1)
  Var yMax As Integer = Cells.LastIndex(2)
  
  newCells.ResizeTo(xMax, yMax)
  
  For x As Integer = 0 To Cells.LastIndex(1)
    For y As Integer = 0 To Cells.LastIndex(2)
      Var neighborCount As Integer = CountNeighbors(x, y)
      
      If Cells(x, y) = True And (neighborCount = 2 Or neighborCount = 3) Then
        newCells(x, y) = True
      ElseIf Cells(x, y) = False And neighborCount = 3 Then
        newCells(x, y) = True
      End If
    Next
  Next
  
  GenerationCount = GenerationCount + 1
  Cells = newCells
  
End Sub</pre>



<p>You can download the project here:</p>



<p><a href="https://files.xojo.com/BlogExamples/Life.xojo_binary_project">Life</a></p>



<p>Although this is a desktop project, it should be easily adaptable to other targets. I love to see what improvements the clever folks in the Xojo community can do. Some ideas include: use lots of colors for drawing, save a drawing to a file, reload a drawing from a file as a staring point. What enhancements would you like?</p>



<p>Share your modifications in the <a href="https://forum.xojo.com">forum</a>!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>A Web App to Calculate Combat Rolls in Twilight Imperium</title>
		<link>https://blog.xojo.com/2022/03/03/a-web-app-to-calculate-combat-rolls-in-twilight-imperium/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Thu, 03 Mar 2022 14:00:00 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=10055</guid>

					<description><![CDATA[Every few weeks my son Lucas gets together with his friends for board game day. Last week's game was Twilight Imperium. One part of the game includes rolling a 10-sided die to calculate whether one of your ships successfully registers a hit on your opponent. Apparently this is something that can take a while to do as each player amasses more and more ships. This was ripe for automation!]]></description>
										<content:encoded><![CDATA[
<p>Every few weeks my son, Lucas, gets together with some of his friends for board game day. This is a day-long event where they play some board game that I&#8217;ve never heard of. Last week&#8217;s game was <a href="https://en.wikipedia.org/wiki/Twilight_Imperium">Twilight Imperium</a> (4th edition, I was told to mention). I don&#8217;t know much about this game, except that it takes a long time to play (6+ hours) and is some sort of space-themed game that I imagine is like Risk but significantly more complex.</p>



<p>Anyway, one part of the game is that you have to roll a 10-sided die to calculate whether one of your ships successfully registers a hit on your opponent. Apparently this is something that can take a while to do as each player amasses more and more ships. Lucas realized this was ripe for automation and the day before the event brought his iPad over to show me a Numbers spreadsheet he had made that used random numbers to calculate combat rolls. Essentially you enter the number of ships at each combat level and does the appropriate number of rolls and tells you how many hits you registered.</p>



<p>It was a pretty clever bit of work, but not really appropriate for a spreadsheet. If you&#8217;ve even done consulting, you&#8217;re probably aware of the adage, &#8220;Excel is not a database&#8221;, because there is often a lot of work you can get converting creaky, error-prone Excel spreadsheets into full-featured apps. They same thing sort of applied here and I told Lucas that this was an impressive bit of work, but might be better suited as a Xojo app.</p>



<p>We then sat down together with my laptop and quickly put together a Xojo desktop app to calculate combat rolls. We decided to go with a Container that has controls to show the combat level, a field to enter the number of ships at that level and rolls results to verify accuracy.</p>



<p>Apparently, a roll counts as a hit if it matches or exceed the ship&#8217;s combat level. So a ship at level 10 only gets a hit if you roll a 10, but a ship at level 2 gets a hit if you roll a 2 or higher. We accomplished this with two methods:</p>



<pre class="wp-block-preformatted">Public Function Calculate() As Integer
  Var ships As Integer = ShipCountField.Text.ToInteger
  
  Var hits As Integer
  Rolls.RemoveAll
  
  For i As Integer = 1 To ships
    If DidItHit Then
      hits = hits + 1
    End If
  Next i
  
  DiceRollsLabel.Text = String.FromArray(Rolls, ",")
  
  Return hits
End Function</pre>



<pre class="wp-block-preformatted">Private Function DidItHit() As Boolean
  Var diceRoll As Integer
  diceRoll = System.Random.InRange(1, 10)
  
  Rolls.Add(diceRoll.ToString)
  
  If diceRoll &gt;= CombatLevel Then
    Return True
  Else
    Return False
  End If
End Function</pre>



<p>Once we had it working, we realized a desktop app was not going to be useful because he was only going to bring his iPad to board game day. Unfortunately, being a school iPad, we cannot install apps on it so making an iOS app was out. Plus, other kids would want to use the app as well. Fortunately Xojo has lots of options. We decided to convert the desktop app to a web app instead, which would work in Safari on his iPad.</p>



<p>I quickly re-created the UI in a web project, copied over the code and it worked right away. I had him do some testing and when we were confident everything looked good, I set up a port forward on my eero so that he could access the web app when outside our wifi network.</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://blog.xojo.com/wp-content/uploads/2022/02/CleanShot-2022-02-28-at-11.28.11@2x-1002x1024.png" alt="" class="wp-image-10056" width="915" height="935" srcset="https://blog.xojo.com/wp-content/uploads/2022/02/CleanShot-2022-02-28-at-11.28.11@2x-1002x1024.png 1002w, https://blog.xojo.com/wp-content/uploads/2022/02/CleanShot-2022-02-28-at-11.28.11@2x-294x300.png 294w, https://blog.xojo.com/wp-content/uploads/2022/02/CleanShot-2022-02-28-at-11.28.11@2x-768x784.png 768w, https://blog.xojo.com/wp-content/uploads/2022/02/CleanShot-2022-02-28-at-11.28.11@2x.png 1490w" sizes="auto, (max-width: 915px) 100vw, 915px" /><figcaption>Twilight Imperium Combat Roll Calculator</figcaption></figure>



<p>All together, start to finish, this took us maybe an hour to do.</p>



<p>He told me they used it the entire day and it worked great. And the results? Lucas and another player tied for the win.</p>



<p>He did also offer a suggestion to add buttons to increase/decrease the number of ships as it was a bit tedious to type the numbers using the iPad. I&#8217;ll probably have him do that.</p>



<p><a href="http://files.xojo.com/BlogExamples/CombatCalculatorWeb.xojo_binary_project">Download the project</a>, if you&#8217;re interested.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Find The Number: A tutorial for absolute Xojo programming newbies</title>
		<link>https://blog.xojo.com/2021/04/15/find-the-number-a-tutorial-for-absolute-xojo-programming-newbies/</link>
		
		<dc:creator><![CDATA[Stefanie Juchmes]]></dc:creator>
		<pubDate>Thu, 15 Apr 2021 10:00:00 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Guest Post]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=8230</guid>

					<description><![CDATA[Learn to program a simple but entertaining game as an introduction to the Xojo programming language. In this game the computer calculates a random number between 1 and 100 and we have to guess it. Follow this tutorial...]]></description>
										<content:encoded><![CDATA[
<p>I would like to show you how to program a simple but entertaining game that will introduce you to the Xojo programming language. In this game the computer calculates a random number between 1 and 100 and we have to guess it.</p>



<p>Let’s start with the programming. For that we open Xojo and create a new desktop project.&nbsp;</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="625" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-1-1024x625.png" alt="" class="wp-image-8231" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-1-1024x625.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-1-300x183.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-1-768x468.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-1-1536x937.png 1536w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-1.png 1764w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><strong><em>Start a new project in the Project Chooser Window</em></strong></figcaption></figure>



<p>To do this we click on the Desktop tab. In the Application Name field we set the name of our application. If you have a Company you can set its name in the Company field. If we click on OK, the development environment appears.&nbsp;The window is divided into several sections.&nbsp;</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="654" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-2-1024x654.png" alt="" class="wp-image-8232" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-2-1024x654.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-2-300x192.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-2-768x490.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-2-1536x981.png 1536w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-2-2048x1308.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><strong><em>The Xojo Integrated Development Environment, aka the Xojo IDE</em></strong></figcaption></figure>



<p>On the left we see a list of all Windows, Control elements, methods and properties that are include in our project. By default, a program window named Window1 is created. In the middle we see this window. At the moment it is still empty. The middle part is our working area where we will write the code. On the right side there is another menu. It contains the controls that can be easily selected with the mouse, dragged into the window and positioned there. If you don&#8217;t want to see them, you have to click on the &#8220;Library&#8221; button in the upper menu bar first.</p>



<p>By default, the icons are sorted by category. Let’s try it and drag a Generic Button into the window (Buttons section, 1st row of 3rd from left). If you don&#8217;t know which element you are currently looking at in the library, the window at the bottom right will help you. If you move the mouse over the individual controls in the library, you get a short explanation of the control in this window. If you do not see the window, go to the end of the library and move the grey bar a little bit upwards.</p>



<p>Now we take a look at the button that we have dropped into the window. We can position and adjust it. If we move the mouse over the button, a pencil appears in the lower right edge. If you click on that symbol you can change the title of the button.&nbsp;</p>



<p>Above the library you will find two buttons in the menu. One is the Library button and the other is the Inspector button. If you click on the Inspector, you will see the properties for the element that we have selected in the main window where the library with the controls was before. We can view and change the properties here. For example, we can give the button in our window the caption „Hello World&#8221;. Here we can also use coordinates to determine where the button is located in the window and how big it is. You can switch between the Library and the Inspector by clicking on the corresponding button.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="348" height="258" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-3.png" alt="" class="wp-image-8233" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-3.png 348w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-3-300x222.png 300w" sizes="auto, (max-width: 348px) 100vw, 348px" /><figcaption><strong><em>Locking</em></strong></figcaption></figure></div>



<p>With Locking we can determine what should happen if we vary the size of the environment window. If we click on the locks, we can close and open them. When we close a lock, we can think of it as sticking the edge of the element to that side at that moment. If we close two opposite locks, our control will be scaled in this axis when the windows size changes.</p>



<p>If only one lock is closed in this axis, then when we scale the window, the element will be pulled in one direction, in the locked direction.</p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow" style="flex-basis:100%">
<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="576" src="https://blog.xojo.com/wp-content/uploads/2021/04/L-1024x576.png" alt="" class="wp-image-8400" srcset="https://blog.xojo.com/wp-content/uploads/2021/04/L-1024x576.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/04/L-300x169.png 300w, https://blog.xojo.com/wp-content/uploads/2021/04/L-768x432.png 768w, https://blog.xojo.com/wp-content/uploads/2021/04/L-1536x864.png 1536w, https://blog.xojo.com/wp-content/uploads/2021/04/L.png 1600w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>
</div>
</div>
</div>
</div></div>
</div></div>



<div class="wp-block-image"><figure class="alignleft size-large"><img loading="lazy" decoding="async" width="92" height="66" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-6.png" alt="" class="wp-image-8237"/></figure></div>



<p>Above the main area of the development environment there is a menu bar with several icons. Click on the small plus.&nbsp;This opens a submenu. In this submenu we click on the first entry Event Handler. A list with several selection options opens.</p>



<p>To the right of the list we see a small description of the events. These events are called when something specific happens to this object, e.g. when the button is clicked (Action) or the mouse is over the object (MouseEnter). Then the code that was written before in the ActionEvent is executed.</p>



<p>Select the ActionEvent. This means that we now define what should happen when the button is clicked.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="546" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-7-1024x546.png" alt="" class="wp-image-8238" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-7-1024x546.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-7-300x160.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-7-768x410.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-7.png 1204w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><strong><em>The button has a lot of events. If you click on a button its action event is called</em></strong><br></figcaption></figure>



<p><strong>Hello World!</strong>&nbsp;</p>



<p>After we have selected the ActionEvent, the code editor opens. Here we write the code that should be executed. As a test we write:&nbsp;</p>



<pre class="wp-block-preformatted">MessageBox "Hello World"</pre>



<p>Now click on the green play sign (Run) in the menu bar. This will compile your program and start it.&nbsp;</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><em>Compiler:<br>Compiling means that your program is rewritten by the compiler into a language your computer can understand. That language is machine language, bit sequences of 0&#8217;s and 1&#8217;s. Now that it has compiled, the computer can understand and execute your program.</em></p><cite><a href="https://en.wikipedia.org/wiki/Compiler">https://en.wikipedia.org/wiki/Compiler</a></cite></blockquote>



<p>Now press the button once and enjoy the moment!</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="496" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-8-1024x496.png" alt="" class="wp-image-8239" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-8-1024x496.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-8-300x145.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-8-768x372.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-8.png 1094w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><strong><em>Hello World dialog</em></strong></figcaption></figure>



<p><strong>Congratulations!</strong></p>



<p>You wrote your first application! The command MessageBox opens a dialog. The text of this dialog we set in quotes, because it is a string.&nbsp;</p>



<p><strong>The User Interface&nbsp;</strong></p>



<p>AS we have now explored the Xojo environment a bit, let&#8217;s really get started with the program. First, we build our user interface.</p>



<p>For this we insert an edit field (TextField) from the library. There we will enter the numbers later. We give it the name &#8220;Input&#8221; in the Inspector. We still need an explanatory label that tells the user what to do. For this we take a label from the library and enter the following text in the Inspector: Enter a number between 1 and 100. We name the button in the Inspector &#8220;Test&#8221; and give it the title: &#8220;Test the number&#8221;.</p>



<p>Two labels from the library are positioned under this button. Their content will be deleted. In the Inspector, we give the upper label the name &#8220;Info&#8221; and the lower label the name &#8220;Tries&#8221;. Next to the lower label we place a label with the text „tries:“. Your window should now look similar to this.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="751" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-9-1024x751.png" alt="" class="wp-image-8240" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-9-1024x751.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-9-300x220.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-9-768x563.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-9.png 1336w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption><strong><em>The GUI of our game</em></strong></figcaption></figure>



<p><strong>Variables: King of Context&nbsp;</strong></p>



<p>The action in the program is started when the user enters a number and presses the button. That means we need the action event. This action event should first read the data from the window and store it in a variable.&nbsp; Our number, which we get in the input, is to be stored in a variable &#8220;InputNumber&#8221; of the type Integer (integer).</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p><em>Variable:<br>A variable is a place where we can store any value. This value can then be used in different places without knowing it exactly. For example, if we have a calculation x + 5 = result, then the result changes depending on what value x has. If x = 3 then the calculation would be interpreted as 3 + 5 and the result would take the value 8. However, X could just as well be 50, then the result would be 55. There are restrictions in the assignment of variables, because a variable has a type. In most programming languages, variables are distinguished by their type. For this reason, a text is stored with a different type than a number or a date.</em></p><cite>https://en.wikipedia.org/wiki/Variable_(computer_science)</cite></blockquote>



<p>For this we declare the variable first, that means we create it. We write in the action event (please delete the old code before you enter this new code):</p>



<pre class="wp-block-preformatted">Dim InputNumber as integer</pre>



<p>Now we also want to assign the value to this variable, because we only told the program until now that there should be one. The value assignment different from what you may be used to and goes from right to left. That means, the variable which should get the value stands on the <em>left</em> side of the equal sign. The expression that returns the value is on the <em>right</em>.</p>



<p>Because we use a text field for the input, the entered number is interpreted as text and is available to us as a character string. In order to work with it in the right way, we have to convert it from a string to a number first. This is done by the ToInteger method. ToInteger converts a text into an Integer Number. If we want a number of type double, that means a decimal number, we would use the ToDouble method.</p>



<pre class="wp-block-preformatted">InputNumber = Input.text.toInteger</pre>



<p>With the previous command we assigned the correct value to „InputNumber&#8221;. Input.text addresses the Input control and accesses the property „text“ there.</p>



<p><strong>At some point everyone has to make the decision</strong></p>



<p>Now we want to test once whether the user has entered anything at all. We do this via a condition. In normal language we would say: <strong>If </strong>the input is empty, <strong>then</strong> say: &#8220;You must enter something&#8221;. That&#8217;s similar to how it is in programming.</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> Input.Text="" <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
  MessageBox <span class="has-inline-color has-vivid-purple-color">"You must enter something"</span>
  <span class="has-inline-color has-vivid-cyan-blue-color">Return</span>
<span class="has-inline-color has-vivid-cyan-blue-color">End If</span></pre>



<p>In this case we actually have to look again at the string we read from the input field, because this way we can check if it is empty. The structure of a condition looks like this:</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> <strong><em>Condition</em></strong> <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
<strong><em>Code that is executed when the condition is fulfilled</em></strong>
<span class="has-inline-color has-vivid-cyan-blue-color">End If</span></pre>



<p>The condition can decide not only whether two things are equal, but also, for example, whether they are larger or smaller. In the code we already recognise the command for the text output in a dialog box, because we have already used the message box.</p>



<p>The &#8220;Return&#8221; makes sure that we return to our window and can make another input. When &#8220;Return&#8221; is called in a code, the program returns to the place where it was called. Any code after a Return is no longer evaluated.</p>



<p>Now we want to test if the entered number is between 1 and 100. For this we need again an if-condition. We want to decide: If the entered number is less than 1 or the entered number is greater than one, then we want to indicate that the number is outside the valid range. For this we add the following lines to the code of our ActionEvent:</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> InputNumber &lt; 1 <span class="has-inline-color has-vivid-cyan-blue-color">Or</span> InputNumber &gt; 100 Then
&nbsp; MessageBox <span class="has-inline-color has-vivid-purple-color">"Enter a number between 1 and 100"</span>
  <span class="has-inline-color has-vivid-cyan-blue-color">Return
End If</span></pre>



<p>As in language, there is also an OR in programming. It checks whether at least one of the statements is true. We can visualise the OR with an example: I have to decide whether I have to go to work or not. I don&#8217;t have to go to work if it is a national holiday or if I am on vacation. In which cases do I have free time?</p>



<pre class="wp-block-preformatted">1. I <span class="has-inline-color has-vivid-red-color">have no vacation</span> and it is <span class="has-inline-color has-vivid-red-color">not a holiday</span> =&gt; <span class="has-inline-color has-vivid-red-color">false</span> OR <span class="has-inline-color has-vivid-red-color">false</span> =&gt; <span class="has-inline-color has-vivid-red-color">false</span>=&gt; <span class="has-inline-color has-vivid-red-color">have to work</span></pre>



<pre class="wp-block-preformatted">2. I <span class="has-inline-color has-vivid-green-cyan-color">have vacation</span> but it's <span class="has-inline-color has-vivid-red-color">not a holiday</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">true</span> OR <span class="has-inline-color has-vivid-red-color">false</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">true</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">I have free time</span></pre>



<pre class="wp-block-preformatted">3. I <span class="has-inline-color has-vivid-red-color">have no vacation</span> but it <span class="has-inline-color has-vivid-green-cyan-color">is a holiday</span> =&gt; <span class="has-inline-color has-vivid-red-color">false</span> OR <span class="has-inline-color has-vivid-green-cyan-color">true</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">true</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">I have free time</span></pre>



<pre class="wp-block-preformatted">4. I <span class="has-inline-color has-vivid-green-cyan-color">have vacation</span> and <span class="has-inline-color has-vivid-green-cyan-color">it is a holiday</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">true</span> OR <span class="has-inline-color has-vivid-green-cyan-color">true</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">true</span> =&gt; <span class="has-inline-color has-vivid-green-cyan-color">I have free time</span></pre>



<p>Except for case one, I have time off. By the way, if the first statement part is already true, the program jumps to the code part that is executed. It doesn&#8217;t even look at whether the other conditions would have been true as well.</p>



<p>In our case the condition is only not executed if the number is between 1 and 100.</p>



<p><strong>Let&#8217;s give chance a helping hand</strong></p>



<p>In order to check whether the entered number matches the random number, we must first create this random number. We need the random number only once per game. That means it has nothing to do in the ActionEvent of the button, because the button is triggered several times during a game. But we should use another event. The OpenEvent of the game window is suitable. We open the menu handler in the window and select the OpenEvent. This event runs as soon as the window is opened, in our case directly at the start.&nbsp;</p>



<p>Now we have to figure out how to make it possible to create the number in the OpenEvent and still have access to it from the button&#8217;s ActionEvent. We can&#8217;t do this with a simple variable, as we have seen so far, because it is a local variable and you can only access it in the ActionEvent or method in which you created it. Therefore we need another way to store the number. &nbsp;</p>



<p>We add the property to the project and name it randomNumber.The type should be integer again, because we only want to guess integers.</p>



<p><em>Property<br>A property is a variable that is bound to the window in which it was created. This means that it can be read and assigned values by all events or methods of the window. The names of methods, variables and properties must be a single word string. I like to use the camel case. This means that for multiple words you write the words together and capitalise the first letters of each word. For Example: randomNumberGenerator</em></p>



<p>Now we open the OpenEvent again and enter the following line there:</p>



<pre class="wp-block-preformatted">randomNumber= Rnd*100+1</pre>



<p>The function rnd returns us a number with a lot of decimal places, which lies between 0 and 1 (0 is a possible value). Because we want to have a number between 1 and 100, we multiply it by 100 so that the number can take values from 0 to 99 and then +1 so that the number is not 0 and our value range is now between 1 and 100. Because our number is of type integer, all decimal places are truncated and we don&#8217;t have to care about them. An example clarifies it:</p>



<p>Rnd gives us the number 0.0123919</p>



<p>Rnd * 100 would be 1.23919</p>



<p>Rnd * 100 + 1 would be 2.23919</p>



<p>Integer cuts off the decimal places, it is the number 2.&nbsp;</p>



<p>The random number is stored in the RandomNumber property after it is calculated. Now we can make further queries in the ActionEvent of the button. There we continue to query what happens if our entered number is not our random number. The character for unequal is &lt;&gt;. This is easy to remember because the number must be smaller or larger.</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> randomNumber &lt;&gt; InputNumber <span class="has-inline-color has-vivid-cyan-blue-color">Then</span></pre>



<p>In this condition we have to make a distinction again, because we want to inform in the info text whether our input number is larger or smaller than the random number. For this we build an If-condition into the execution area of the If-condition. We want to display the input number in the label with the name &#8220;Info&#8221;, in addition to the message whether a number is larger or smaller. For this we can write e.g. the following line.</p>



<pre class="wp-block-preformatted">info.Text=InputNumber.ToString+" is to big"</pre>



<p>We convert our number back to a string using ToString. The + concatenates two strings. Here we have to pay attention to the fact that the space is also a character and therefore has to be written.</p>



<p>So we can write:</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> randomNumber &lt;&gt; InputNumber <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
&nbsp; <span class="has-inline-color has-vivid-cyan-blue-color">If</span> InputNumber &gt; randomNumber <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
&nbsp;&nbsp;  info.Text=InputNumber.ToString+<span class="has-inline-color has-vivid-purple-color">" is to big"</span>
&nbsp; <span class="has-inline-color has-vivid-cyan-blue-color">End If</span>
   <span class="has-inline-color has-vivid-cyan-blue-color">If</span> InputNumber &lt; randomNumber Then
&nbsp; &nbsp; info.Text=InputNumber.ToString+<span class="has-inline-color has-vivid-purple-color">" is to small"</span>
&nbsp;  <span class="has-inline-color has-vivid-cyan-blue-color">End If
End If</span></pre>



<p><strong>What else</strong></p>



<p>In language usage, there is not only an if then but also an else. Example:</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> I go to the theatre <span class="has-inline-color has-vivid-cyan-blue-color">then</span>
        I put on a great dress
<span class="has-inline-color has-vivid-cyan-blue-color">Else</span>
        I put on a jogging suit</pre>



<p>You can already see from the way it is written down that we can almost use the idea behind it one by one in our program.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-10-1024x768.png" alt="" class="wp-image-8242" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-10-1024x768.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-10-300x225.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-10-768x576.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-10.png 1424w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>We have already handled the case where the random number and the input number are not equal. We are still missing the case that the two are equal.This we can now simply put into an else part of this condition, because if it is not unequal, then it must be equal.That&#8217;s why the whole statement now looks like this:</p>



<pre class="wp-block-preformatted"><span class="has-inline-color has-vivid-cyan-blue-color">If</span> randomNumber &lt;&gt; InputNumber <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
&nbsp; <span class="has-inline-color has-vivid-cyan-blue-color">If</span> InputNumber &gt; randomNumber <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
&nbsp; &nbsp; info.Text=InputNumber.ToString+<span class="has-inline-color has-vivid-purple-color">" is to big"</span>
&nbsp; <span class="has-inline-color has-vivid-cyan-blue-color">End If</span>
&nbsp; <span class="has-inline-color has-vivid-cyan-blue-color">If</span> InputNumber &lt; randomNumber <span class="has-inline-color has-vivid-cyan-blue-color">Then</span>
&nbsp; &nbsp; info.Text=InputNumber.ToString+<span class="has-inline-color has-vivid-purple-color">" is to small"</span>
&nbsp; <span class="has-inline-color has-vivid-cyan-blue-color">End If
Else</span>
&nbsp; info.Text=<span class="has-inline-color has-vivid-purple-color">"Congratulations! " + InputNumber.ToString + " is the number you are looking for"</span>
<span class="has-inline-color has-vivid-cyan-blue-color">End If</span></pre>



<p><strong>Cosmetic Corrections</strong></p>



<p>Now we start the game!</p>



<p>It works! Congratulations <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-11-1024x768.png" alt="" class="wp-image-8243" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-11-1024x768.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-11-300x225.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-11-768x576.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-11.png 1424w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>But before you get addicted to your own program, we should make the program a bit more attractive and user-friendly.</p>



<p><strong>How many tries did I need?</strong></p>



<p>To do this, we first specify how many attempts we needed to find the number. We want to display this in the label with the name Tries.</p>



<p>We want to increase the number by one over the duration of the game over and over again, exactly when a valid number was entered, so we have to create a property again. This property is of type Integer and is called &#8220;NumberOfTries&#8221;. The type is again Integer. As we want this to be listed when the entered number is valid, we write:</p>



<pre class="wp-block-preformatted">NumberOfTries = NumberOfTries + 1
Tries.Text=NumberOfTries.ToString</pre>



<p><strong>Empty the field and test the number with Return</strong></p>



<p>Now we would like to make the input field empty again when we have tested a number. Therefore we write at the very end of the ActionEvent</p>



<pre class="wp-block-preformatted">Input.Text=""</pre>



<p>This will overwrite the text of the input with an empty string.</p>



<p>Next, when we have entered a number, we want to be able to simply press Enter to confirm without having to press the button over and over again. For this reason, we set the button as default button. That means that when we press enter the button is clicked and the code runs. For this we switch on the property Default in the inspector of the button.</p>



<p>Then confirming the number with Enter will work.</p>



<p><strong>Now add color to the game</strong></p>



<p>You can now also polish the layout a bit. To change the appearance of a text you can change settings of the individual labels in the inspector. You could change the text color depending on whether the number is greater than, less than or equal to the number you are looking for. You can do this with this line directly in front of the respective output.</p>



<pre class="wp-block-preformatted">info.TextColor = RGB(0 , 0 , 255)</pre>



<p>The color values are given as RGB, this would now color the text in blue for example.</p>



<p>You can also change the background color of the window. For this you can select a Background Color in the Inspector of the window under Background. For the background color to be displayed, you have to activate Has Background Color. In the Backdrop you can add a graphic to the background.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-14-1024x768.png" alt="" class="wp-image-8260" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-14-1024x768.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-14-300x225.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-14-768x576.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-14.png 1424w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>New game &lt;&gt; new window?</strong></p>



<p>Now we don&#8217;t want to have to close the window every time we want to start a new game. Therefore we add a button to the layout. We call this new game. When this button is pressed, a new random number should be generated, which is then stored in the Random Number property.The tries should be set to 0, the info window is flushed and the input is cleared.</p>



<p>Because we have already written the code to create a random number in this area and we want to save ourselves duplicate work when programming, we go to the OpenEvent from the window and select the code. Then we click on it with the left mouse button. In the context menu we will be offered some options on what to do with the selected code.&nbsp;</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="928" height="816" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-12.png" alt="" class="wp-image-8261" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-12.png 928w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-12-300x264.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-12-768x675.png 768w" sizes="auto, (max-width: 928px) 100vw, 928px" /></figure>



<p>We click on Convert to Method.</p>



<p>A new code window opens. Under Name we enter RandomNumberGenerate.</p>



<p>Now in the OpenEvent we can read the following line: RandomNumberGenerate()</p>



<p>This is the call of our own method. A method is a snippet of code which could be inserted at this point, but since we need it several times, we have source out so that we don&#8217;t have to type so much and so the program text is more tidy.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="911" height="549" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-13.png" alt="" class="wp-image-8262" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-13.png 911w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-13-300x181.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-13-768x463.png 768w" sizes="auto, (max-width: 911px) 100vw, 911px" /></figure>



<p>We now see the method on the left side menu. We can click on it and see the original content of the old OpenEvent again.</p>



<p>Now we can also insert the function in the ActionEvent of the new button, so that it now looks like this.</p>



<pre class="wp-block-preformatted">Input.Text=""
Info.Text=""
NumberOfTries=0
Tries.Text="0"
RandomNumberGenerate</pre>



<p>In the call RandomNumberGenerate we can remove the parentheses.</p>



<p>Now our game is ready.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="768" src="https://blog.xojo.com/wp-content/uploads/2021/03/Image-15-1024x768.png" alt="" class="wp-image-8265" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/Image-15-1024x768.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-15-300x225.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-15-768x576.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/Image-15.png 1424w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>I wish you a lot of fun and success with your programming!</p>



<p><em>Stefanie Juchmes studies computer science at the University of Bonn. She came in touch with Xojo due to the work of her brother-in-law and got a junior developer position in early 2019 at <a rel="noreferrer noopener" href="https://www.monkeybreadsoftware.de/xojo/" target="_blank">Monkeybread Software.</a> You may have also read her articles in <a rel="noreferrer noopener" href="http://www.xdevmag.com/" target="_blank">Xojo Developer Magazine</a>. </em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>#JustCode Challenge Week 10 &#8211; NetTank</title>
		<link>https://blog.xojo.com/2018/08/24/justcode-challenge-week-10-nettank/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Fri, 24 Aug 2018 10:00:54 +0000</pubDate>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[#JustCode]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Networking]]></category>
		<category><![CDATA[UDP]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=4851</guid>

					<description><![CDATA[For the 10th week of the #JustCode Challenge I took a look at networking. For my project this week I've created a networked version of the Combat game, which has two tanks on the screen shooting at each other. ]]></description>
										<content:encoded><![CDATA[<p>For the 10th week of the #JustCode Challenge I took a look at networking. For my project this week I&#8217;ve created a networked version of the Combat game, which has two tanks on the screen shooting at each other. The network version allows you to control one tank with the app running on your computer and someone else to control the other tank with the app running on their computer. I call it NetTank.</p>
<p><span id="more-4851"></span></p>
<p>I made a version of Combat in Xojo a while ago (it&#8217;s included in the Xojo examples folder in the Download) so I figured I would start there. To provide network capabilities to a game, you generally want to go with something fast and that means UDP (User Datagram Protocol), which is provided by the UDPSocket. There&#8217;s also a UDPSocket example included with Xojo which I used as a reference.</p>
<p>To start I first decided what data I wanted to send back and forth. I narrowed it down to these actions:</p>
<ul>
<li>JoinAction</li>
<li>MoveAction</li>
<li>HitAction</li>
</ul>
<p>These are all sent as JSON by broadcasting to a Multicast group.</p>
<p>JoinAction is sent when a game is first started to allow the two client NetTank apps to negotiate who is player 1 and who is player 2. The two actions are &#8220;ready&#8221; and &#8220;player2&#8221;.</p>
<p>MoveAction contains the action that your tank just did to send to the other client so it can update its display. Initially I was just sending actions for &#8220;forward&#8221;, &#8220;left&#8221;, &#8220;right&#8221; and &#8220;fire&#8221;. But because UDP does not guarantee messages are received, the tanks would sometimes get out of sync if a lot of moves were sent quickly when there was network congestion. So I instead decided to send the actual xy coordinate and rotation angle for a forward move so that should a message get lost it will at least have the correct information in a future forward message.</p>
<p>When a tank is hit, HitAction contains the new location for the tank (it is moved to a random spot on the screen when hit) to send to the other client.</p>
<p>Because the Combat game already ran using Timers, I didn&#8217;t really have to change much of the original Combat game code for NetTank. I added a UDPSocket to the main CombatWindow and in its DataAvailable event I have the code to check for the messages and update the Tank objects as needed.</p>
<p>I also had to make a few tweaks to the main code to send the JSON messages for movements, hits and to properly identify which tank to move.</p>
<p>To try the game you&#8217;ll need to run it on two different computers. The first one that starts becomes player 1 (blue) and the second one is player 2 (red). Use the arrow keys to move the tanks and press the space bar to fire.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-4856" src="https://blog.xojo.com/wp-content/uploads/2018/08/2018-08-22_14-05-40.png" alt="" width="1220" height="437" /></p>
<p><a href="http://files.xojo.com/JustCode/NetworkTank.zip">Download the project</a> or <a href="https://gitlab.com/xojo/NetTank">check it out on GitLab</a>.</p>
<p>Add your #JustCode project to the <a href="https://forum.xojo.com/49555-just-code-challenge-week-10-projects">week 10 forum conversation</a>.</p>
<p>Download and check out earlier projects:</p>
<ul>
<li>Week 9: <a href="https://blog.xojo.com/2018/08/17/justcode-challenge-week-9-quote-web-service/">Quote Web Service</a></li>
<li>Week 8: <a href="https://blog.xojo.com/2018/08/10/justcode-challenge-week-8-jumpstart-app-launcher/">JumpStart App Launcher</a></li>
<li>Week 7: <a href="https://blog.xojo.com/2018/08/03/justcode-challenge-week-7-pitch-tracker/">Pitch Tracker</a></li>
<li>Week 6: <a href="https://blog.xojo.com/2018/07/27/justcode-challenge-week-6-bubble-popper/">Bubble Popper</a></li>
<li>Week 5: <a href="https://blog.xojo.com/2018/07/20/justcode-challenge-week-5-math-quiz/">Math Quiz</a></li>
<li>Week 4: <a href="https://blog.xojo.com/2018/07/13/justcode-challenge-week-4-mini-golf-scorekeeper/">Mini-Golf ScoreKeeper</a></li>
<li>Week 3: <a href="https://blog.xojo.com/2018/07/06/just-code-challenge-week3/">Dogs Up!</a></li>
<li>Week 2: <a href="https://blog.xojo.com/2018/06/29/just-code-challenge-week2/">Password Generator</a></li>
<li>Week 1: <a href="https://blog.xojo.com/2018/06/22/just-code-challenge-week1/">Color Picker</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>#JustCode Challenge Week 6 &#8211; Bubble Popper</title>
		<link>https://blog.xojo.com/2018/07/27/justcode-challenge-week-6-bubble-popper/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Fri, 27 Jul 2018 10:00:59 +0000</pubDate>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[#JustCode]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Canvas]]></category>
		<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=4568</guid>

					<description><![CDATA[For this week&#8217;s app, I created a simple iOS app where you tap on &#8220;bubbles&#8221; to pop them. This was actually suggested to me by&#8230;]]></description>
										<content:encoded><![CDATA[<p>For this week&#8217;s app, I created a simple iOS app where you tap on &#8220;bubbles&#8221; to pop them. This was actually suggested to me by Dana Brown some time ago as something that would make a great diversion for her son. I have found it helpful with some of my younger nieces and nephews.</p>
<p>This iOS app demonstrates the use of a Canvas and the detection of taps. When all the bubbles have been popped, more are added. It never ends!</p>
<p><span id="more-4568"></span></p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-4580 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2018/07/2018-07-19_09-59-13.png" alt="" width="392" height="770" /></p>
<p><a href="http://files.xojo.com/JustCode/BubblePopper.zip">Download the project</a> or <a href="https://gitlab.com/xojo/BubblePopper">check it out on GitLab</a>.</p>
<p>Enhancements idea include:</p>
<ul>
<li>Add more bubble colors.</li>
<li>Keep track of how many bubbles are popped.</li>
<li>Handle screen rotations so that bubbles that are off screen get repositioned.</li>
<li>Take advantage of multi-touch to allow multiple bubbles to be popped at once.</li>
</ul>
<p>Add your project to the <a href="https://forum.xojo.com/49030-just-code-challenge-week-6-projects">week 6 forum conversation</a>.</p>
<p>Download and check out earlier projects:</p>
<ul>
<li>Week 5: <a href="https://blog.xojo.com/2018/07/20/justcode-challenge-week-5-math-quiz/">Math Quiz</a></li>
<li>Week 4: <a href="https://blog.xojo.com/2018/07/13/justcode-challenge-week-4-mini-golf-scorekeeper/">Mini-Golf ScoreKeeper</a></li>
<li>Week 3: <a href="https://blog.xojo.com/2018/07/06/just-code-challenge-week3/">Dogs Up!</a></li>
<li>Week 2: <a href="https://blog.xojo.com/2018/06/29/just-code-challenge-week2/">Password Generator</a></li>
<li>Week 1: <a href="https://blog.xojo.com/2018/06/22/just-code-challenge-week1/">Color Picker</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Jump Right In! Just Code Challenge</title>
		<link>https://blog.xojo.com/2018/06/18/jump-right-in-just-code-challenge/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 18 Jun 2018 22:37:56 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[#JustCode]]></category>
		<category><![CDATA[Challenge]]></category>
		<category><![CDATA[Citizen Developer]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=4341</guid>

					<description><![CDATA[The Just Code Challenge starts on June 18 and ends on September 21. Develop a new program or app and share it each Friday. Complete 10 out of 14 projects and complete the challenge. If you complete the challenge you'll get one of our super soft, new Xojo shirts and you'll be entered to win a Xojo Pro license!]]></description>
										<content:encoded><![CDATA[<p>I’m often asked by kids and adults how they can start coding and learn to make apps? You <em>could</em> start with the usual <a href="http://www.xojo.com/learn">books</a> or <a href="http://www.youtube.com/goxojo">videos</a>.</p>
<p>But maybe you want to <strong>jump right in</strong>. When I started programming that is exactly how I learned. I tried things to see what worked and what didn’t work. I also looked at and modified other programs I found.</p>
<p>You can learn to code if you <strong>just code</strong>.</p>
<p><span id="more-4341"></span></p>
<p>So let’s kick off this summer&#8217;s Just Code challenge. The idea is that you try to make one app a week throughout the next 14 weeks of the summer. These apps don’t need to do anything fancy, although they should do <em>something</em>. Any type of Xojo-made app counts — desktop, iOS or web. No need to compile, you are only required to submit your project to complete the challenge.</p>
<p>This contest is a great way to show people new to coding what it takes to make an app, and to show how much fun coding is. Even if you already know how to code, you’ll find that this contest is a great way to bring some fun back to coding kinda like Gavin Smith did just last week in his personal <a href="https://www.libertyapp.com/blog/index.php/2018/06/14/ios-game-from-scratch-in-14-days-done/">14 day iOS app challenge</a>.</p>
<p>The Just Code challenge starts today, <strong>June 18</strong> and ends Friday, <strong>September 21</strong>. Submit a project on at least <strong>10 out of 14</strong> Fridays to complete the Just Code challenge! Complete the challenge and you&#8217;ll get one of our super soft, new Xojo shirts (while supplies last) and you&#8217;ll be entered to win a Xojo Pro license plus $100! <em><strong>UPDATE</strong>: Because of growing interest, we&#8217;ll also be giving away a limited number of Xojo Lite licenses!</em></p>
<p>I’ve started a <a href="https://forum.xojo.com/48375-just-code-challenge">forum conversation called Just Code challenge</a>. Go there for ideas, to ask questions and post your projects on Fridays. Of course, I’ll be doing the Just Code challenge too. Each week I will post my project to start the Friday forum thread.</p>
<p><strong>Each Friday</strong> add your new project to the forum thread I started with that week&#8217;s app. Share a description of your project, a screenshot and a download link. Talk about your app and how much fun it is to #JustCode!</p>
<p>So what are you waiting for? Go on, <strong>just code.</strong></p>
<ul>
<li>Week 1 project: <a href="https://blog.xojo.com/2018/06/22/just-code-challenge-week1/">Color Picker</a></li>
<li>Week 2 Project: <a href="https://blog.xojo.com/2018/06/29/just-code-challenge-week2/">Password Generator</a></li>
<li>Week 3 Project: <a href="https://blog.xojo.com/2018/07/06/just-code-challenge-week3/">Dogs Up!</a></li>
<li>Week 4 Project: <a href="https://blog.xojo.com/2018/07/13/justcode-challenge-week-4-mini-golf-scorekeeper/">Mini-Golf ScoreKeeper</a></li>
<li>Week 5 Project: <a href="https://blog.xojo.com/2018/07/20/justcode-challenge-week-5-math-quiz/">Math Quiz</a></li>
<li>Week 6 Project: <a href="https://blog.xojo.com/2018/07/27/justcode-challenge-week-6-bubble-popper/">Bubble Popper</a></li>
<li>Week 7 Project: <a href="https://blog.xojo.com/2018/08/03/justcode-challenge-week-7-pitch-tracker/">Pitch Tracker</a></li>
<li>Week 8 Project: <a href="https://blog.xojo.com/2018/08/10/justcode-challenge-week-8-jumpstart-app-launcher/">JumpStart App Launcher</a></li>
<li>Week 9 Project: <a href="https://blog.xojo.com/2018/08/17/justcode-challenge-week-9-quote-web-service/">Quote Web Service</a></li>
<li>Week 10 Project: <a href="https://blog.xojo.com/2018/08/24/justcode-challenge-week-10-nettank/">NetTank</a></li>
<li>Week 11 Project: <a href="https://blog.xojo.com/2018/08/31/justcode-challenge-week-11-xojo-dojo-for-pi/">Xojo Dojo</a></li>
<li>Week 12 Project: <a href="https://blog.xojo.com/2018/09/07/justcode-challenge-week-12-multitemp/">MultiTemp</a></li>
<li>Week 13 Project: <a href="https://blog.xojo.com/2018/09/14/justcode-challenge-week-13-xojo-speed/">Xojo Speed</a></li>
<li>Week 14 Project: <a href="https://blog.xojo.com/2018/09/21/justcode-challenge-week-14-marching-band-scorekeeper/">Marching Band ScoreKeeper</a></li>
</ul>
<p>Check out this forum post for a list of 100+ projects submitted by Xojo customers:</p>
<p><a href="https://forum.xojo.com/50254-just-code-challenge-submissions">Just Code Challenge Submissions</a></p>
<p>And find out the winners here:</p>
<p><a href="https://forum.xojo.com/50192-just-code-challenge-winners">Just Code Challenge Winners</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Asteroid Run: Xojo&#8217;s Hour of Code 2017</title>
		<link>https://blog.xojo.com/2017/12/05/hour-of-code-2017/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Tue, 05 Dec 2017 18:42:22 +0000</pubDate>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Hour of Code]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3586</guid>

					<description><![CDATA[It's Computer Science Education Week, which also means it's time for Code.org's Hour of Code. I've put together a short 5-part series of videos (less than 25 minutes total) to show how to make a simple game in Xojo called Asteroid Run. It's super fun so give it a shot!]]></description>
										<content:encoded><![CDATA[<p>It&#8217;s Computer Science Education Week, which also means it&#8217;s time for <a href="https://code.org">Code.org&#8217;s Hour of Code</a>.</p>
<p>To share Xojo with Hour of Code, I&#8217;ve put together a short 5-part series of videos (less than 25 minutes total) to show how to make a simple game called Asteroid Run.</p>
<p><span id="more-3586"></span></p>
<p>In Asteroid Run a spaceship flies through space shooting an ever-increasing number of asteroids that are coming at you.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3593" src="https://blog.xojo.com/wp-content/uploads/2017/12/AsteroidRun.gif" alt="" width="600" height="572" /></p>
<p>To get started, <a href="http://www.xojo.com/download">download Xojo &#8211; it&#8217;s free!</a></p>
<h2>Asteroid Run Part 1: Initial Setup</h2>
<p>In part 1 you will do initial setup and add a scrolling background starfield.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part1.zip">Download project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 1: Initial Setup" width="500" height="281" src="https://www.youtube.com/embed/avwgV1RpIP8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 2: Add Spaceship</h2>
<p>In part 2, you will add the spaceship and allow it to move with the mouse.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part2.zip">Download project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 2: Add Spaceship" width="500" height="281" src="https://www.youtube.com/embed/kpEgJ4o7_30?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 3: Add Missiles</h2>
<p>In part 3, you will add the missiles that are fired from the spaceship when you click the mouse.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part3.zip">Download project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 3: Add Missiles" width="500" height="281" src="https://www.youtube.com/embed/_1Dz200fYmU?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 4: Add Asteroids</h2>
<p>In part 4, you will add the asteroids and make the game end when an asteroid hits the spaceship.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Part4.zip">Download project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 4: Adding Asteroids" width="500" height="281" src="https://www.youtube.com/embed/IgimObt1sxo?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<h2>Asteroid Run Part 5: Finish the Game</h2>
<p>In part 5, you will finish the game by making the ship&#8217;s missiles destroys the asteroids for points.</p>
<p><a href="http://files.xojo.com/HourOfCode/AsteroidRun-Final.zip">Download finished project</a></p>
<p><iframe loading="lazy" title="Asteroid Run Part 5: Finish the Game" width="500" height="281" src="https://www.youtube.com/embed/pZuUn7QRa44?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>10 Print</title>
		<link>https://blog.xojo.com/2017/11/10/print-10/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Fri, 10 Nov 2017 07:12:17 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3514</guid>

					<description><![CDATA[The other day I saw this article on Dev.To: A Universe in One Line of Code with 10 PRINT It talks about how you could&#8230;]]></description>
										<content:encoded><![CDATA[<p>The other day I saw this article on <a href="https://dev.to">Dev.To</a>: <a href="https://dev.to/burningion/a-universe-in-one-line-of-code-with-10-print-2d1">A Universe in One Line of Code with 10 PRINT</a></p>
<p>It talks about how you could make a maze-like structure on a Commodore 64 with just this one line of code:</p>
<pre>10 PRINT CHR$(205.5+RND(1)); : GOTO 10</pre>
<p>The author then goes on to show you how you might do something similar using Python and pygame.</p>
<p>I love all things retro and this seemed like fun, so I thought I would whip up the same thing in Xojo.</p>
<p><span id="more-3514"></span></p>
<p>For reference, the primary Python code looks like this (although there is more code to set up the drawing area):</p>
<pre>square = 20
for x in range(0, screenWidth, square):
     for y in range(0, screenHeight, square):
         if random.random() &gt; 0.5:
             pygame.draw.line(screen, white, (x, y), (x + square, y + square))
         else:
             pygame.draw.line(screen, white, (x, y + square), (x + square, y))</pre>
<p>To do this in Xojo, create a Desktop, web or iOS project, add a Canvas to the layout and put this code in its Paint event:</p>
<pre>Const kSquare = 20
For x As Integer = 0 To g.Width Step kSquare
  For y As Integer = 0 To g.Height Step kSquare
    If Rnd &gt; 0.5 Then
      g.DrawLine(x, y, x + kSquare, y + kSquare)
    Else
      g.DrawLine(x, y + kSquare, x + kSquare, y)
    End If
  Next
Next</pre>
<p>(Yes, for this example Xojo uses the exact same code for desktop, web and iOS.)</p>
<p>You should certainly be able to see the similarities between Xojo and Python. Here&#8217;s the output of Xojo desktop, web and iOS apps:</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3516" src="https://blog.xojo.com/wp-content/uploads/2017/11/Print10Desktop.png" alt="" width="800" height="622" /></p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3517" src="https://blog.xojo.com/wp-content/uploads/2017/11/Print10iOS.png" alt="" width="320" height="590" /></p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3518" src="https://blog.xojo.com/wp-content/uploads/2017/11/Print10Web.png" alt="" width="612" height="451" /></p>
<p>Be sure to check out <a href="https://dev.to/">Dev.To</a> and <a href="https://dev.to/lefebvre">follow me there</a> as well.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Programming Challenge: 8 Queens Problem</title>
		<link>https://blog.xojo.com/2017/05/05/programming-challenge-8-queens-problem/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Fri, 05 May 2017 06:00:43 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Atari]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2659</guid>

					<description><![CDATA[In my Algorithms class in my second semester of college (many, many eons ago), one of the project assignments was to write a program that would find&#8230;]]></description>
										<content:encoded><![CDATA[<p>In my Algorithms class in my second semester of college (many, many eons ago), one of the project assignments was to write a program that would find all the solutions to the 8 Queens Problem.</p>
<p><span id="more-2659"></span></p>
<p>What is the 8 Queens Problem?</p>
<p>If you are familiar with chess, you know that the queen is the most powerful piece on the board. It can move any number of squares in any direction in order to “kill” another piece. The 8 queens problem is defined like this:</p>
<blockquote><p>“How many different solutions can you find for placing 8 queens on a chessboard so that they cannot kill another?”</p></blockquote>
<p>Believe it or not, there are quite a few solutions. Back when I was in school, the language of choice for this class was Pascal and I wrote a Pascal program (on my <a href="https://en.wikipedia.org/wiki/Atari_ST">Atari ST</a>) that generated the solutions and printed them to the screen. I got an “A” on it.</p>
<p>A while ago I actually ported this old Pascal program (yes, I still have a copy, which you can <a href="https://www.dropbox.com/s/aj203uygyc3q3it/QUEENS.PAS?dl=0">download if you&#8217;re interested</a>) to Xojo. I updated it a bit to add a graphical view of each of the solutions.</p>
<p>But before I tell you where you can find my updated Xojo solution, think about how you’d solve this using Xojo. Share your thoughts, ideas and projects on the <a href="http://forum.xojo.com">forum</a>.</p>
<p>My Xojo 8 Queens Problem project is included with the Xojo examples: Examples/Sample Applications/8Queens</p>
<p><img loading="lazy" decoding="async" class="wp-image-2660 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-04_11-00-21.png" alt="" width="400" height="505" /></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>XojoTalk 015: Type my password like an animal</title>
		<link>https://blog.xojo.com/2015/07/01/xojotalk-015-type-my-password-like-an-animal/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 01 Jul 2015 00:00:00 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[XojoTalk]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Open-Source]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2015/07/01/xojotalk-015-type-my-password-like-an-animal/</guid>

					<description><![CDATA[XojoTalk 015: Type my password like an animal]]></description>
										<content:encoded><![CDATA[<p>In this episode of XojoTalk, Paul talks with <a href="https://twitter.com/justindelliott">Justin Elliott</a>, IT and Development Manager at <a href="http://www.psu.edu">Penn State University</a>.</p>
<p>Download <a href="http://files.xojo.com/Podcasts/XojoTalk-015.mp3">MP3</a>.</p>
<p><span id="more-225"></span></p>
<p>Show Links</p>
<ul>
<li><a href="http://www.psu.edu">Penn State University</a></li>
<li><a href="http://clc.its.psu.edu/UnivServices/itadmins/mac/blastimageconfig">Blast Image Config</a></li>
<li><a href="http://macadmins.psu.edu">MacAdmins Conference</a></li>
<li><a href="http://developer.xojo.com/xojo-data">Xojo JSON support</a></li>
<li><a href="https://sched.org">Sched.org</a></li>
<li><a href="http://developer.xojo.com/community-open-source-projects">Open-Source Xojo Projects</a></li>
<li><a href="http://www.xojo.com/resources/cloudservices.php">5 Reasons to rely on Cloud services</a></li>
<li><a href="http://developer.xojo.com/webinar-retro-gaming">Git webinars</a></li>
<li><a href="https://github.com/xojo/XojoUnit">XojoUnit</a></li>
<li><a href="https://system76.com">System 76 Linux laptops</a></li>
<li><a href="http://elementary.io">ElementaryOS</a></li>
<li><a href="http://jakobud.com/plan-list.php">JackObud arcade cabinets</a></li>
<li><a href="http://developer.xojo.com/webinar-retro-gaming">Retro game webinar</a></li>
<li><a href="https://itunes.apple.com/us/app/pixel-space-war/id983974668?mt=8">Pixel Space Wars</a></li>
</ul>
<p><!--HubSpot Call-to-Action Code --> <span id="hs-cta-wrapper-32eb9715-5c1c-45a4-9f37-717ffc906d8e" class="hs-cta-wrapper"> <span id="hs-cta-32eb9715-5c1c-45a4-9f37-717ffc906d8e" class="hs-cta-node hs-cta-32eb9715-5c1c-45a4-9f37-717ffc906d8e"><br />
<!-- [if lte IE 8]>


<div id="hs-cta-ie-element"></div>


<![endif]--> <a href="http://feeds.feedburner.com/xojotalk" target="_blank"><img loading="lazy" decoding="async" id="hs-cta-img-32eb9715-5c1c-45a4-9f37-717ffc906d8e" class="hs-cta-img alignnone" style="border-width: 0px; margin: 0 auto; display: block; margin-top: 20px; margin-bottom: 20px;" src="https://blog.xojo.com/wp-content/uploads/2014/09/32eb9715-5c1c-45a4-9f37-717ffc906d8e.png" alt="Subscribe Podcast" width="622" height="107" align="middle" /></a> </span><script src="https://js.hscta.net/cta/current.js" charset="utf-8">// <![CDATA[
<script type="text/javascript"><![CDATA[ hbspt.cta.load(608515, '32eb9715-5c1c-45a4-9f37-717ffc906d8e', {}); // ]]&gt;</script></span><br />
<!-- end HubSpot Call-to-Action Code --></p>
<p>You can also <a href="https://itunes.apple.com/us/podcast/xojotalk-podcast/id920411434" target="_blank">subscribe on iTunes</a>.</p>
]]></content:encoded>
					
		
		<enclosure url="http://files.xojo.com/Podcasts/XojoTalk-015.mp3" length="31009982" type="audio/mpeg" />

			</item>
		<item>
		<title>Programming Resources For Students</title>
		<link>https://blog.xojo.com/2015/06/15/learn2code-xojo-for-students-of-all-ages/</link>
		
		<dc:creator><![CDATA[Alyssa Foley]]></dc:creator>
		<pubDate>Mon, 15 Jun 2015 00:00:00 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Women in Tech]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2015/06/15/learn2code-xojo-for-students-of-all-ages/</guid>

					<description><![CDATA[We offer a lot of resources to help anyone interested in learning to code with Xojo. But we do have some specific resources that will interest and assist students learning the fundamentals of coding and Xojo:]]></description>
										<content:encoded><![CDATA[<p>Can I learn to code in Xojo for free? <a href="http://xojo.com/download/">Yes</a>, Xojo is free for development and testing!</p>
<p>Do you have a free book so I can learn to code? <a href="http://xojo.com/learn/">Yes</a>, <em>Intro to Programming with Xojo</em> is free!</p>
<p>Can I ask my beginner questions? <a href="https://forum.xojo.com">Yes</a>, the Xojo forum is a gateway to the friendly and helpful Xojo community.</p>
<p>The Xojo language is <a href="http://developer.xojo.com/kb/oop">Object-Oriented</a>. Object-Oriented programming is an excellent way to learn the fundamentals of computer programming. Xojo is also cross-platform, which means you can build apps for all kinds of platforms using a single code base. Xojo is a <a href="http://en.wikipedia.org/wiki/Rapid_application_development">Rapid Application Development</a> tool, which means it&#8217;s developed to make building apps simple and quick.</p>
<p><span id="more-219"></span></p>
<p>We offer a lot of resources to help anyone interested in learning to code with Xojo. But we do have some specific resources that will interest and assist students learning the fundamentals of coding and Xojo:</p>
<p><strong>Books</strong></p>
<p><a href="http://www.xojo.com/learn/" target="_blank" rel="noopener">Introduction to Programming With Xojo</a>&#8211; This is a solid resource for learning the fundamentals of programming. While you will use Xojo, the concepts introduced are applicable to any language you want to learn later. In our experience, this book can be helpful to students as young 12 or 13 years old! We also have a Teacher&#8217;s Guide for educators planning on using Xojo in the classroom.</p>
<p><a href="http://xojo.com/learn/" target="_blank" rel="noopener">iOS Booklet</a>&#8211; This booklet shows you how to use Xojo to develop for our latest supported platform, iOS!</p>
<p><a href="http://developer.xojo.com/community-books-magazines-training-and-tutorials">Books, Magazines, Training &amp; Tutorials</a> from the Xojo community.</p>
<p><strong>From the Xojo Blog Archives</strong></p>
<p>First and foremost, <a href="https://blog.xojo.com/2013/12/09/who-should-learn-to-code-everyone/">who should learn to code!? Everyone!</a><br />
Now that you have made your apps with Xojo, read how to <a href="https://blog.xojo.com/2018/07/16/how-to-selling-your-xojo-apps/">Package, Sell &amp; Market your apps</a>.<br />
<a href="https://blog.xojo.com/2014/03/03/flappy-bird-in-xojo/">Xoppy Bird</a> &#8211; Building a Flappy Bird clone in Xojo<br />
Hour of Code Projects for teachers &amp; students: <a href="https://blog.xojo.com/2013/12/11/hour-of-code-spelling-test/">Spelling Test</a>, <a href="https://blog.xojo.com/2013/12/12/hour-of-code-math-facts/">Math Facts</a>, <a href="https://blog.xojo.com/2014/12/19/hour-of-code-2014/">iOS Doodle</a>, <a href="https://blog.xojo.com/2015/12/07/hour-of-code-cat-pictures/">Cat Pictures</a>, <a href="https://blog.xojo.com/2017/12/05/hour-of-code-2017/">Asteroid Run</a><br />
<a href="https://blog.xojo.com/2013/12/12/the-flat-earth-for-young-software-entrepreneurs/">The Flat Earth for Young Software Entrepreneurs</a>&#8211; Today a 12 year old with a good idea and some determination can create an app and sell it with little up-front cost.<br />
<a href="https://blog.xojo.com/2013/10/23/earn-the-boy-scout-programming-merit-badge/">Earn the Boy Scout Programming Merit Badge</a> with Xojo.</p>
<p><strong>On-Demand Webinars &amp; Videos</strong></p>
<p><a href="https://www.youtube.com/watch?v=h_elqXDrues">Retro Gaming</a> &#8211; A fun webinar for beginners! Learn as we create a simple clone of the Atari 2600 game <a href="http://en.wikipedia.org/wiki/Combat_%281977_video_game%29">Combat</a>.<br />
This <a href="https://www.youtube.com/playlist?list=PLPoq910Q9jXiYdPy3sPm_-X9_ol3t9NdM" target="_blank" rel="noopener">Playlist</a> of videos is geared towards Getting Started with Xojo. Recorded webinars and video tutorials can be <a href="https://www.youtube.com/user/goxojo">watched anytime</a>.</p>
<p><strong> Tutorials &amp; Quizzes</strong></p>
<p>Want to see it done? <a href="http://developer.xojo.com/tutorials-overview" target="_blank" rel="noopener">Tutorials</a> take you step-by-step through the code for a Desktop, Web or iOS program. Or get into the details with how to create your own customer controls, build a messenger app, access the serial port, build an iOS app and more.</p>
<p>For a greater challenge see our <a href="http://developer.xojo.com/tutorial/timer">Timer</a> Tutorial &amp; Quizzes, <a href="http://developer.xojo.com/tutorials/sqlite-basics">SQLite Basics</a> Tutorial &amp; Quizzes and the more in-depth <a href="http://developer.xojo.com/sqlitedatabase-and-iossqlitedatabase-for-beginners-tutorial-quizzes">SQLiteDatabase &amp; iOSQLiteDatabase</a> Tutorial &amp; Quizzes. Keep checking in, we add new Tutorials all the time!</p>
<p><strong>Other Resources</strong></p>
<p>Here are step-by-step instructions on how to <a href="http://developer.xojo.com/get-started">get started with Xojo</a>. And of course the <a href="http://blog.xojo.com" target="_blank" rel="noopener">Xojo Blog</a> is always full of tips, announcements, and news about Xojo and cross-platform development. The <a href="http://forum.xojo.com" target="_blank" rel="noopener">Xojo Forum</a> is a good stop when you want to crowdsource your answers or ask a Xojo expert. There are also <a href="http://developer.xojo.com/community-open-source-projects">open-source Xojo projects</a> to review and utilize.</p>
<p>What do you need to start learning to code with Xojo? <a href="https://www.xojo.com/company/contact.php">Email me</a>, I&#8217;m here to help you find the resource you need.<!-- end HubSpot Call-to-Action Code --></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>2048 Game for Desktop, Web and iOS</title>
		<link>https://blog.xojo.com/2014/09/22/2048-game-for-desktop-web-and-ios/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 22 Sep 2014 00:00:00 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Mobile]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2014/09/22/2048-game-for-desktop-web-and-ios/</guid>

					<description><![CDATA[You may have seen the 2048 game running on iOS and Android. Here's a version made with Xojo, which I call 2K that runs on Desktop, Web and iOS.]]></description>
										<content:encoded><![CDATA[<p>You may have seen the 2048 game running on iOS and Android. Here&#8217;s a version made with Xojo, which I call 2K that runs on Desktop, Web and iOS.</p>
<p><span id="more-151"></span></p>
<p>This Xojo clone attempts to emulate the iOS gameplay, which is very simple. You start with two tiles on the grid, which can be either a 2 or a 4. You can slide the tiles either up, down or left, right. Tiles that have he same number are combined into a single new tile whose number is the sum of the tiles. After each slide, a new tile (randomly a 2 or 4) is added to an open position on one of the edges. The newly added tile is highlighted.</p>
<p>So if you slide a row that has two 4 tiles, it will combine to a single 8 tile. You get the value of the combined tile added to your score. The game is over when you have no more moves.</p>
<p><span style="line-height: 1.62;">For reference, this is what the original iOS version looks like on an iPad:</span></p>
<p><a href="http://www.xojo.com/blog/en/assets_c/2014/09/iPad-2048-483.php"><img loading="lazy" decoding="async" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" src="https://blog.xojo.com/wp-content/uploads/2014/09/ipad-2048-thumb-400x501-483.pngt1466486449161ampwidth400ampheight501" sizes="auto, (max-width: 400px) 100vw, 400px" alt="iPad-2048.png" width="400" height="501" /></a></p>
<p>This is the Xojo desktop app:</p>
<p><a href="http://www.xojo.com/blog/en/assets_c/2014/09/Desktop-2K-486.php"><img loading="lazy" decoding="async" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" src="https://blog.xojo.com/wp-content/uploads/2014/09/desktop-2k-thumb-400x431-486.pngt1466486449161ampwidth400ampheight431" sizes="auto, (max-width: 400px) 100vw, 400px" alt="Desktop-2K.png" width="400" height="431" /></a></p>
<p>Most of what you see on the window are Canvas controls, including the logo, score, high score, tile grid and arrows.</p>
<p>The current position of the tiles is stored in a simple 4&#215;4 array called Grid. There are methods that process a slide for each direction, moving tiles and combining them as necessary (SlideUp, SlideDown, SlideLeft, SlideRight).</p>
<p>And the high score is saved to a text file so it can be reloaded.</p>
<h2>Web and iOS, too!</h2>
<p>There are also web and iOS version that you can also try. Both are largely designed the same as the desktop version, but using WebCanvas/iOSCanvas controls.</p>
<p>Have fun playing the game and feel free to send me your enhancements.</p>
<p><a href="http://files.xojo.com/BlogExamples/2K-Xojo.zip">Xojo 2K Game Download for Desktop, iOS and Web</a></p>
<p>Interested in making games with Xojo? <a href="/2014/03/17/making_games_with_xojo/">Read on&#8230;</a><!-- end HubSpot Call-to-Action Code --></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Making Games with Xojo</title>
		<link>https://blog.xojo.com/2014/03/17/making-games-with-xojo/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 17 Mar 2014 00:00:00 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Games]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2014/03/17/making-games-with-xojo/</guid>

					<description><![CDATA[Making Games with Xojo]]></description>
										<content:encoded><![CDATA[<p>So cool, a <a href="https://alwaysbusycorner.wordpress.com/2014/03/06/xojorealbasic-abpe-the-physics-engine/">Xojo user</a> has created a <a href="https://alwaysbusycorner.wordpress.com/2014/03/06/xojorealbasic-abpe-the-physics-engine/">2D physics engine</a> that works with Xojo!</p>
<p><span id="more-108"></span></p>
<p>2D physics engines are the things that are used to create games such as <em>Angry Birds</em>, <em>Where&#8217;s My Water?</em> and others. With a 2D physics engine you define the objects, the &#8220;physics&#8221; and how things interact. The engine takes care of the rest!</p>
<p>The demo project displays a cart at the top of the screen which you can move around with the left and right arrow keys. The car will push and interact with the other objects on the screen. You can see here that I got my cart stuck under a block:</p>
<p><a href="http://www.xojo.com/blog/en/assets_c/2014/03/PhysicsEngineDemo-349.php"><img loading="lazy" decoding="async" class="mt-image-center" style="text-align: center; display: block; margin: 0 auto 20px;" src="https://blog.xojo.com/wp-content/uploads/2014/03/physicsenginedemo-thumb-400x228-349.pngt1466486449161ampwidth400ampheight228" sizes="auto, (max-width: 400px) 100vw, 400px" alt="PhysicsEngineDemo.png" width="400" height="228" /></a></p>
<p>It seems like some fun games could be created with this and best of all the engine is free with full source code!</p>
<p>Head on over to this <a href="https://alwaysbusycorner.wordpress.com/2014/03/06/xojorealbasic-abpe-the-physics-engine/">blog post</a> from @RealAlwaysBusy to download the source code and the example. Then check out the <a href="https://forum.xojo.com/9860-abpe-the-physics-engine/">forum conversation</a> to see what other people have created.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
