<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Clever Humans RSS Feed]]></title><description><![CDATA[Clever Humans Do the Darndest Things]]></description><link>https://cleverhumans.com</link><image><url>https://cleverhumans.com/monkey.png</url><title>Clever Humans RSS Feed</title><link>https://cleverhumans.com</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 09 Apr 2024 11:54:02 GMT</lastBuildDate><atom:link href="https://cleverhumans.com/rss.xml" rel="self" type="application/rss+xml"/><pubDate>Tue, 09 Apr 2024 11:54:02 GMT</pubDate><copyright><![CDATA[©2000-2024 Patrick Burrows. All rights reserved]]></copyright><item><title><![CDATA[Total Eclipse]]></title><description><![CDATA[<p>I spent some time watching the eclipse yesterday. I don't know if I missed what the big deal was, but maybe I was watching the wrong thing:</p>
<p><a href="https://www.youtube.com/watch?v=lcOxhH8N3Bo">https://www.youtube.com/watch?v=lcOxhH8N3Bo</a></p>]]></description><link>https://cleverhumans.com#2024-04-09T08:44:34.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2024-04-09T08:44:34.000Z</guid><pubDate>Tue, 09 Apr 2024 08:44:34 GMT</pubDate></item><item><title><![CDATA[Thanksgiving dinner idea for next year]]></title><description><![CDATA[<p>Thanksgiving dinner idea for next year:</p>
<p><a href="https://mastodon.online/@sorinorii/109394681090213447">I made thanksgiving dinner and now the kids are crying...</a></p>]]></description><link>https://cleverhumans.com#2023-12-16T12:57:59.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-12-16T12:57:59.000Z</guid><pubDate>Sat, 16 Dec 2023 12:57:59 GMT</pubDate></item><item><title><![CDATA[jeff Bezos Rowing Boat]]></title><description><![CDATA[<p>This is a journey. It starts slow, but draws you in. Along the way there is surgery, a live concert, an incredibly detailed sculpture of Jeff Bezos, and hijinks on the high seas.</p>
<p><a href="https://www.youtube.com/watch?v=VGhcSupkNs8">Jeff Bezos Rowing Boat</a></p>]]></description><link>https://cleverhumans.com#2023-12-16T12:32:25.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-12-16T12:32:25.000Z</guid><pubDate>Sat, 16 Dec 2023 12:32:25 GMT</pubDate></item><item><title><![CDATA[6d Stylus]]></title><description><![CDATA[<p>Someone created an open-source digital stylus that has 6 degrees of freedom as their electrical engineering capstone project.</p>
<p><a href="https://github.com/Jcparkyn/dpoint">https://github.com/Jcparkyn/dpoint</a></p>]]></description><link>https://cleverhumans.com#2023-11-20T10:36:28.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-20T10:36:28.000Z</guid><pubDate>Mon, 20 Nov 2023 10:36:28 GMT</pubDate></item><item><title><![CDATA[Let's Not Die]]></title><description><![CDATA[<p>Rachel Nuwer gives us an overview of how modern science is <a href="https://www.technologyreview.com/2023/11/17/1082937/what-is-death/">pushing the boundaries on the definition of death</a>.</p>
<blockquote>
<p>In 2019, scientists reported in Nature that they were able to <a href="https://www.nature.com/articles/s41586-019-1099-1">restore a suite of functions</a> in the brains of 32 pigs that had been decapitated in a slaughterhouse four hours earlier.</p>
</blockquote>
<blockquote>
<p>In 2022, Latham and colleagues published a second paper in Nature announcing that they’d been able to <a href="https://www.nature.com/articles/s41586-022-05016-1">recover many functions in multiple organs</a>, including the brain and heart, in whole-body pigs that had been killed an hour earlier</p>
</blockquote>
<p>This brings to mind a <a href="https://www.pushkin.fm/podcasts/revisionist-history/guns-part-4-moral-hazard">recent episode of Revisionist History on guns</a> where Malcolm Gladwell claimed:</p>
<blockquote>
<p>A city's murder rate is not a measure of the number of people victimized by potentially lethal violence. No. It's a measure of the number of people victimized by potentially lethal violence minus how good a job doctors do at saving that person's life once they get to the hospital.</p>
</blockquote>]]></description><link>https://cleverhumans.com#2023-11-18T12:01:56.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-18T12:01:56.000Z</guid><pubDate>Sat, 18 Nov 2023 12:01:56 GMT</pubDate></item><item><title><![CDATA[Textcasting]]></title><description><![CDATA[<p>Interestingly, my new blog design embraces the idea of <a href="http://textcasting.org">textcasting</a> even though I hadn't heard of it before now. I designed the site around a "slack-like" (or Discord-like) design where most posts are just shorts, without even a title. But there is still support for <a href="/posts/2023-11-12-breakout-01">longer items</a> that can apear on a page of their own. All the posts use Markdown behind the scenes, and I have an RSS feed for the site. If anything comes of "textcasting" I'll make sure to incorporate that into the site.</p>]]></description><link>https://cleverhumans.com#2023-11-17T17:53:04.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-17T17:53:04.000Z</guid><pubDate>Fri, 17 Nov 2023 17:53:04 GMT</pubDate></item><item><title><![CDATA[EDC Mighty Bar]]></title><description><![CDATA[<p>Useful addition for your every-day carry (EDC) keychain. Would replace a leatherman or other small keychain knife. Some have claimed it has made it through TSA checks without being confiscated.</p>
<p>https://gearspool.com/products/the-mighty-bar</p>]]></description><link>https://cleverhumans.com#2023-11-17T17:47:54.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-17T17:47:54.000Z</guid><pubDate>Fri, 17 Nov 2023 17:47:54 GMT</pubDate></item><item><title><![CDATA[1886 US Government Commissioned Watercolors of Fruit]]></title><description><![CDATA[<h1><a href="https://www.openculture.com/2019/06/the-us-government-commissioned-7500-watercolor-paintings.html" title="Permanent Link to In 1886, the US Government Commissioned 7,500 Watercolor Paintings of Every Known Fruit in the World: Download Them in High Resolution">In 1886, the US Government Commissioned 7,500 Watercolor Paintings of Every Known Fruit in the World</a></h1>
<p><img src="/assets/images/posts/Untitled-image-20231117120758948.png" alt=""></p>
<p><img src="/assets/images/posts/2023-11-17-fruit-image-20231117120829252.png" alt=""></p>
<blockquote>
<p>Central to the government agency’s growing pomological agenda was the recording of all the various types of fruit being cultivated, hybridized, inspected, and sold from both inside the U.S. and all over the world.</p>
</blockquote>
<blockquote>
<p>Prior to and even long after photography could do the job, that meant employing the talents of around 65 American artists to “document the thousands and thousands of varieties of heirloom and experimental fruit cultivars sprouting up nationwide.” The USDA made <a href="https://naldc.nal.usda.gov/usda_pomological_watercolor?q=&#x26;search_field=all_fields">the full collection public</a> after Electronic Frontier Foundation activist Parker Higgins submitted a Freedom of Information Act request in 2015.</p>
</blockquote>]]></description><link>https://cleverhumans.com#2023-11-17T17:07:46.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-17T17:07:46.000Z</guid><pubDate>Fri, 17 Nov 2023 17:07:46 GMT</pubDate></item><item><title><![CDATA[TITLE]]></title><description><![CDATA[<p><img src="/assets/images/posts/Untitled-image-20231117115031715.png" alt=""></p>]]></description><link>https://cleverhumans.com#2023-11-17T16:50:28.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-17T16:50:28.000Z</guid><pubDate>Fri, 17 Nov 2023 16:50:28 GMT</pubDate></item><item><title><![CDATA[Creating Breakout A Lot]]></title><description><![CDATA[<p>(this is a stream-of-conscious rambling of the making of a basic video game)</p>
<p><a href="https://en.wikipedia.org/wiki/Breakout_%28video_game%29">Breakout</a> is one of the first video games. Sort of like a single-player version of Pong, where instead of trying to get a ball past your opponent, you are trying to get your ball to hit all the bricks until you clear a board.</p>
<p><img src="/assets/images/posts/Pasted%20image%2020231112062217.png" alt=""></p>
<p>To this day, Breakout style games are constantly popular in App Stores everywhere. They are a timeless waste of time.</p>
<p>Given the simplicity of the basic game (modern versions add all sorts of complications), it seems like a good way to get my feet wet in creating a video game.</p>
<p>I've been a professional programmer for going on 30 years now, and have never created a video game. It seems like a glaring omission on my part. As a self-taught programmer, the math aspect of video game creation always intimidated me (my college degree is in writing poetry, something that is also a timeless waste of time.)</p>
<p>My intent is to create multiple versions of a Breakout style game using different programming languages, different technologies and different techniques to try my hand at "video game creation."</p>
<p>For the first version I'm going to use the tools I'm most familiar with, and try to depend on as few external libraries as possible. For me, that means I'll write it in C# and use the most primitive and "low-tech" ways of drawing the game board.</p>
<p>The other thing I want to do with this first version is look up as little as possible on the Best Practices for video game creation. As much as possible, I want to figure this out on my own. I'm sure there are dozens of libraries out there which would let me slap together a game like this in a day or so, but that's not the point of this learning project for me.</p>
<p>I'm sure I'll have to look up the trigonometry pieces for actually calculating the ball movements, of course. It has been 30 years since my last math class.</p>
<h2>Setting Up the Project</h2>
<p>First step is opening Rider and creating a new desktop application. I haven't made a desktop application in years. Everything now-a-days seems to be web applications of some sort.</p>
<p>All I see in the options for desktop applications are Windows Forms applications and WPF Applications. I've made both in the past, but I'm pretty sure they are old technologies. I thought Maui was the new way to develop desktop applications these days. I'm surprised it isn't already installed.</p>
<p>I need to separately install <a href="https://rider-support.jetbrains.com/hc/en-us/community/posts/6087514959122-Windows-Environment-Setup-for-MAUI-Development-Windows-Desktop-Application-">Maui</a>, apparently.</p>
<pre><code>dotnet workload install maui
dotnet workload install wasm-tools
</code></pre>
<p>Wow, that's installing a lot.</p>
<p>While that is running, let's read about the...</p>
<h2>History of the Game</h2>
<p>The wikipedia page for <a href="https://en.wikipedia.org/wiki/Breakout_%28video_game%29">Breakout</a> is fascinating. Apparently it was originally written by Steve Wozniak! How cool! He wrote it in May of 1976, when I was only 3 months old. Apparently, later in life, when Wozniak was designing the Apple II, a lot of the features he chose to include in that computer was directly influenced by Breakout. Things like graphics commands in BASIC, paddle support, sound, and color graphics!</p>
<p>He is quoted in the Wikipedia article as saying:</p>
<blockquote>
<p>Basically, all the game features were put in just so I could show off the game I was familiar with—<em>Breakout</em>—at the <a href="https://en.wikipedia.org/wiki/Homebrew_Computer_Club" title="Homebrew Computer Club">Homebrew Computer Club</a>. It was the most satisfying day of my life [when] I demonstrated <em>Breakout</em>—totally written in BASIC. It seemed like a huge step to me. After designing hardware arcade games, I knew that being able to program them in BASIC was going to change the world.</p>
</blockquote>
<p>Who knew Breakout was so important!</p>
<p>Ok, Maui is installed. Let's restart Rider and create a new Maui App.</p>
<h2>Maui</h2>
<p>So a new Maui app won't even build without an Android SDK installed? Ok, let's install Android Studio and get an SDK! Yay, more installing things! I'm fine with this, though, since I intend to eventually write my Breakout clone in native Android as well.</p>
<p>...</p>
<p>Now it is complaining that I don't have the proper Android SDK version, but the version it is looking for isn't even available to install. I've <a href="https://github.com/dotnet/maui/discussions/18373">posted a question</a> in the Maui discussion board about this. But, for now, I am going to punt on Maui, this is a distraction from actually building what I want to build.  I'm not even trying to build a mobile version right now, just a desktop app.</p>
<p>I guess I was under the impression that Maui was the new windows desktop app technology that gave you the option to make mobile versions of your app, not FORCE you to make mobile versions of your apps.</p>
<p>I might come back to Maui when I get to the mobile versions of this project. But, honestly, probably not. I was planning to build that in Kotlin.</p>
<p>Let's leave aside the idea of HOW to display the game for now and let's instead...</p>
<h2>Think About the Game</h2>
<p><img src="/assets/images/posts/Pasted%20image%2020231112062448.png" alt="">
(<a href="https://en.wikipedia.org/wiki/File:Breakout2600.svg">Atari 2600 version</a>)</p>
<p>There's not a lot of elements to the most basic Breakout clone (which I will very uncreatively call Brick Out.) The elements I can think of immediately:</p>
<ul>
<li>Brick</li>
<li>Ball</li>
<li>Paddle</li>
<li>GameBoard</li>
</ul>
<p>As I've said already, and as I'll probably repeat hundreds of times in this series, I am not a game programmer. And, at least in this first version of the game, I am deliberately trying NOT to learn about game programming. I want this version to be as naive an implementation as possible.</p>
<p>So that said, from a code structure point of view, I am going to create types for each of the elements (a "model" as it were), and then a separate type to encapsulate the logic:</p>
<p>The model:</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Brick</span> {}
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Ball</span> { }
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Paddle</span> {}
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">GameBoard</span> {}
</code></pre>
<p>The logic:</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">BrickOutGame</span> {}
</code></pre>
<h2>Laying Out the GameBoard: Grid vs Coordinates</h2>
<p>If I think about the <code>GameBoard</code>, I can think that there might be a grid system that defines the game board (Rows and Columns), with Bricks and Paddles being able to span multiple columns.</p>
<p>Obviously that can't be right. If right from the very first definition I am already  defining elements which "Break Out" from the grid (puns are fun!) then obviously a grid system isn't the right way to think about it.</p>
<p>I mean, it IS a grid, of course, but just not a "column layout" type of grid, and more as Cartesian coordinates.</p>
<p>Tracking state with a coordinate system instead of a grid system will mean tracking the pixel layout of each element. It is more flexible, but also harder to reason about than a grid. With pixels we are going to have to test if objects overlap, wheras with a grid, we would just have a multi-dimensional array that tracks the contents of each item.</p>
<p>I'm not sure which is best, so for now I am going to stay open to both possibilities.</p>
<h2>Giving the Items Some Dimension</h2>
<p>Let's define some sizes for items that interact with each other. I'll create a base interface called <code>DisplayItem</code> that will hold the shape of the item and its location:</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title">DisplayItem</span>
{
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}
</code></pre>
<p>And make Bricks, Balls, and Paddles have some sizes (I'll come back to location in a bit):</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Brick</span> : <span class="hljs-title">DisplayItem</span>  
{  
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">20</span>, <span class="hljs-number">10</span>);  
}  
  
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Ball</span> : <span class="hljs-title">DisplayItem</span>  
{  
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">5</span>, <span class="hljs-number">5</span>);  
}  
  
<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Paddle</span> : <span class="hljs-title">DisplayItem</span>  
{  
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">40</span>, <span class="hljs-number">5</span>);  
}
</code></pre>
<p>So a brick is 20 pixels wide by 10 pixels high. A ball is a 5 pixels by 5 pixels (that's not going to roll very well!) and the paddle is 40 pixels wide by 5 pixels high.</p>
<p>And then, for the GameBoard, let's start with hardcoding VGA-sized graphics, 640x480. And let's create some properties to store the other DisplayItems:</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">GameBoard</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> Height { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-number">640</span>;
    <span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> Width { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-number">480</span>;

    <span class="hljs-keyword">public</span> List&#x3C;Brick> Bricks { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>();
    <span class="hljs-keyword">public</span> Ball Ball { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>();
    <span class="hljs-keyword">public</span> Paddle Paddle { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>();
}
</code></pre>
<p>And finally, let's say our first game is going to have 6 rows (again, just hardcoding this for now), and if it is 480 pixels wide that means we can fit 24 20pixel bricks on a row (480 / 20 = 24). Let's go ahead and create those bricks without actually giving them a position yet. For this, I'll create a new static method in GameBoard called NewGame() that will return a properly created GameBoard. My final GameBoard class looks like this:</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">GameBoard</span>
{
    <span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> Height { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-number">640</span>;
    <span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> Width { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-number">480</span>;

    <span class="hljs-keyword">public</span> List&#x3C;Brick> Bricks { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>();
    <span class="hljs-keyword">public</span> Ball Ball { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>();
    <span class="hljs-keyword">public</span> Paddle Paddle { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>();

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">NewGame</span>()</span>
    {
        <span class="hljs-keyword">var</span> board = <span class="hljs-keyword">new</span> GameBoard();
        
        <span class="hljs-comment">// create bricks</span>
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> row = <span class="hljs-number">0</span>; row &#x3C; <span class="hljs-number">6</span>; row++)
        {
            <span class="hljs-comment">// 24 columns == 480 width / 20 pixel wide bricks</span>
            <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> col = <span class="hljs-number">0</span>; col &#x3C; <span class="hljs-number">24</span>; col++)
            {
                board.Bricks.Add(<span class="hljs-keyword">new</span> Brick());
            }
        }
    }
}

</code></pre>
<h2>What About Laying Out the Bricks?</h2>
<p>Right now, every brick is at position 0,0. That's not a very fun game! So, my question is, should I store position as part of the rectangle, or have a separate variable to store the position? A Rectangle in DotNet is made up of a Point (x,y coordinates) and a Size (width and height). So far I've only set the Size.</p>
<p>I think the path of least resistance, though perhaps not the most future flexible path, is to just use the Rectangle's Point property to set the value. I can go ahead and do it within the same nested loop that creates the bricks in the first place.</p>
<p>First I'll add a constructor to Brick to let me set the Point of the Rectangle struct:</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Brick</span> : <span class="hljs-title">DisplayItem</span>
{
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-keyword">new</span>(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">20</span>, <span class="hljs-number">10</span>);
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Brick</span>()</span> {}

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Brick</span>(<span class="hljs-params"><span class="hljs-built_in">int</span> x, <span class="hljs-built_in">int</span> y</span>)</span>
    {
        Shape = <span class="hljs-keyword">new</span> Rectangle(x, y, <span class="hljs-number">20</span>, <span class="hljs-number">10</span>);
    }   
}
</code></pre>
<p>I probably don't need the empty constructor anymore, but I'll leave it for now.</p>
<p>And then I'll update my <code>NewGame()</code> method to set the (x,y) coordinates of the bricks, again, using hardcoded values for my screen size:</p>
<pre><code class="hljs language-csharp">    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title">NewGame</span>()</span>
    {
        <span class="hljs-keyword">var</span> board = <span class="hljs-keyword">new</span> GameBoard();
        
        <span class="hljs-comment">// create bricks</span>
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> row = <span class="hljs-number">0</span>; row &#x3C; <span class="hljs-number">6</span>; row++)
        {
            <span class="hljs-built_in">int</span> y = row * <span class="hljs-number">10</span>;
            <span class="hljs-comment">// 24 columns == 480 width / 20 pixel wide bricks</span>
            <span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> col = <span class="hljs-number">0</span>; col &#x3C; <span class="hljs-number">24</span>; col++)
            {
                <span class="hljs-built_in">int</span> x = col * <span class="hljs-number">20</span>;
                board.Bricks.Add(<span class="hljs-keyword">new</span> Brick(x, y));
            }
        }
    }
</code></pre>
<h2>Let's Create the Ball and Paddle</h2>
<p>We'll go ahead and create the Ball and Paddle objects now, too within the NewGame() method and give them an initial position. Again, we'll create a constructor to set the (x,y) coordinates of the Ball and the Paddle</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Ball</span> : <span class="hljs-title">DisplayItem</span>
{
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Ball</span>(<span class="hljs-params"><span class="hljs-built_in">int</span> x, <span class="hljs-built_in">int</span> y</span>)</span>
    {
        Shape = <span class="hljs-keyword">new</span> Rectangle(x, y, <span class="hljs-number">5</span>, <span class="hljs-number">5</span>);
    }
}

<span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">Paddle</span> : <span class="hljs-title">DisplayItem</span>
{
    <span class="hljs-keyword">public</span> Rectangle Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } 

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Paddle</span>(<span class="hljs-params"><span class="hljs-built_in">int</span> x, <span class="hljs-built_in">int</span> y</span>)</span>
    {
        Shape = <span class="hljs-keyword">new</span> Rectangle(x, y, <span class="hljs-number">40</span>, <span class="hljs-number">5</span>);
    }
}
</code></pre>
<p>And then we'll set their initial position on the GameBoard by adding these lines to the <code>NewGame()</code> method:</p>
<pre><code class="hljs language-csharp">board.Paddle = <span class="hljs-keyword">new</span> Paddle(<span class="hljs-number">0</span>,<span class="hljs-number">635</span>);
board.Ball = <span class="hljs-keyword">new</span> Ball(<span class="hljs-number">20</span>, <span class="hljs-number">630</span>);
</code></pre>
<p>This should put the paddle all the way at the left of the screen on the very bottom (640 screen height - 5 paddle height = 635), and the ball right on top of it (635 paddle top - 5 ball height = 630)</p>
<p>Again, we are just hardcoding everything. I know I'll need to change that later.</p>
<h2>Displaying the NewGame</h2>
<p>So far, I have implemented all the logic of the game (such as it is) in its own class, separated from any display logic. Part of that was because of my frustrating experience with Maui up above. But the other part is because I know I want to re-use the game logic and display it in several different ways over this series.</p>
<p>But, for me, I am a visual person and I like to see things as I go. So I am going to move the game logic into a C# project called Brickout.GameLogic, and create a WPF project called Brickout.Wpf.</p>
<p>We'll set the main component in the app to be a Canvas and set the height and width to the size we want (with the height being a little more than 640 to account for the title bar).</p>
<p>Here is MainWindow.xml:</p>
<pre><code class="hljs language-csharp">&#x3C;Window x:Class=<span class="hljs-string">"BrickOut.Wpf.MainWindow"</span>
        xmlns=<span class="hljs-string">"http://schemas.microsoft.com/winfx/2006/xaml/presentation"</span>
        xmlns:x=<span class="hljs-string">"http://schemas.microsoft.com/winfx/2006/xaml"</span>
        xmlns:d=<span class="hljs-string">"http://schemas.microsoft.com/expression/blend/2008"</span>
        xmlns:mc=<span class="hljs-string">"http://schemas.openxmlformats.org/markup-compatibility/2006"</span>
        xmlns:local=<span class="hljs-string">"clr-namespace:BrickOut.Wpf"</span>
        mc:Ignorable=<span class="hljs-string">"d"</span>
        Loaded=<span class="hljs-string">"MainWindow_OnLoaded"</span>
        Title=<span class="hljs-string">"BrickOut"</span> Height=<span class="hljs-string">"700"</span> Width=<span class="hljs-string">"480"</span>>
    &#x3C;Canvas Name=<span class="hljs-string">"GameCanvas"</span> Height=<span class="hljs-string">"700"</span> Width=<span class="hljs-string">"480"</span>>

    &#x3C;/Canvas>
&#x3C;/Window>
</code></pre>
<p>In the code behind, let's add the MainWindow_OnLoaded method, create a new GameBoard:</p>
<pre><code class="hljs language-csharp">    <span class="hljs-keyword">public</span> <span class="hljs-keyword">partial</span> <span class="hljs-keyword">class</span> <span class="hljs-title">MainWindow</span> : <span class="hljs-title">Window</span>
    {
        <span class="hljs-keyword">public</span> GameBoard CurrentGame { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = GameBoard.NewGame();

        <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">MainWindow</span>()</span>
        {
            InitializeComponent();
        }

        <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">MainWindow_OnLoaded</span>(<span class="hljs-params"><span class="hljs-built_in">object</span> sender, RoutedEventArgs e</span>)</span>
        {
            DrawGameBoard();
        }
    }
</code></pre>
<p>Before we get to the <code>DrawGameBoard()</code> method, let's choose the colors we want our bricks to be. The only possible option here is to choose the first 10 colors of the Colors enum, in alphabetical order:</p>
<pre><code class="hljs language-csharp">        <span class="hljs-keyword">private</span> List&#x3C;Color> BrickColors = <span class="hljs-keyword">new</span>()
        {
            Colors.AliceBlue,
            Colors.AntiqueWhite,
            Colors.Aqua,
            Colors.Aquamarine,
            Colors.Azure,
            Colors.Beige,
            Colors.Bisque,
            Colors.BlanchedAlmond,
            Colors.Blue,
            Colors.BlueViolet,
            Colors.Brown
        };
</code></pre>
<p>Yes, that should be truly ugly!</p>
<p>All our DisplayItems are <code>System.Drawing.Rectangle</code> objects, but to show them on a WPF canvas, we need to convert them to <code>System.Windows.Shapes.Rectangle</code> objects and set them on our canvas. We'll create a method specifically to do that:</p>
<pre><code class="hljs language-csharp"><span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">AddRectangleToCanvas</span>(<span class="hljs-params">SolidColorBrush brush, <span class="hljs-built_in">int</span> x, <span class="hljs-built_in">int</span> y, <span class="hljs-built_in">int</span> width, <span class="hljs-built_in">int</span> height</span>)</span>
    {
        <span class="hljs-keyword">var</span> wpfRect = <span class="hljs-keyword">new</span> Rectangle();
        wpfRect.Fill = brush;
        wpfRect.Width = width;
        wpfRect.Height = height;
        GameCanvas.Children.Add(wpfRect);
        Canvas.SetTop(wpfRect, y);
        Canvas.SetLeft(wpfRect, x);
    }
</code></pre>
<p>Note we are taking x, y, width, and height as parameters here instead of a <code>System.Drawing.Rectangle</code> (which would have been easier). But I wanted to avoid the confusion of referencing a type called <code>Rectangle</code> multiple times.</p>
<p>Now let's implement the <code>DrawGameBoard()</code> method and add the bricks, ball, and paddle to the board:</p>
<pre><code class="hljs language-csharp"><span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">DrawGameBoard</span>()</span>
        {
            GameCanvas.Children.Clear();

            <span class="hljs-keyword">foreach</span> (<span class="hljs-keyword">var</span> brick <span class="hljs-keyword">in</span> CurrentGame.Bricks)
            {
                AddRectangleToCanvas(
                    GetNextBrickColorBrush(),
                    brick.Shape.X,
                    brick.Shape.Y,
                    brick.Shape.Width,
                    brick.Shape.Height);
            }

            AddRectangleToCanvas(
                <span class="hljs-keyword">new</span> SolidColorBrush(Colors.Red),
                CurrentGame.Paddle.Shape.X,
                CurrentGame.Paddle.Shape.Y,
                CurrentGame.Paddle.Shape.Width,
                CurrentGame.Paddle.Shape.Height);
            
             AddRectangleToCanvas(
                            <span class="hljs-keyword">new</span> SolidColorBrush(Colors.Green),
                            CurrentGame.Ball.Shape.X,
                            CurrentGame.Ball.Shape.Y,
                            CurrentGame.Ball.Shape.Width,
                            CurrentGame.Ball.Shape.Height);
        }
</code></pre>
<p>The <code>GetNextBrickColorBrush()</code> simply keeps an iterator over our beautiful list of colors and makes it iterate forever by resetting back to 0 when it gets to the end:</p>
<pre><code class="hljs language-csharp">        <span class="hljs-keyword">private</span> <span class="hljs-built_in">int</span> nextBrickColorIndex = <span class="hljs-number">0</span>;
        <span class="hljs-function"><span class="hljs-keyword">private</span> SolidColorBrush <span class="hljs-title">GetNextBrickColorBrush</span>()</span>
        {
            <span class="hljs-keyword">var</span> brush = <span class="hljs-keyword">new</span> SolidColorBrush(BrickColors[nextBrickColorIndex]);
            nextBrickColorIndex += <span class="hljs-number">1</span>;
            <span class="hljs-keyword">if</span> (nextBrickColorIndex >= BrickColors.Count)
            {
                nextBrickColorIndex = <span class="hljs-number">0</span>;
            }

            <span class="hljs-keyword">return</span> brush;
        }

</code></pre>
<p>Now let's run it and see how beautiful our game board is:
<img src="/assets/images/posts/Pasted%20image%2020231112062520.png" alt=""></p>
<p>Yes, very beautiful!</p>
<p>Let's play with the colors a little. Since the game is called "Brick Out" let's set a color palette that looks a little more like, you know, brick:</p>
<pre><code class="hljs language-csharp">        <span class="hljs-keyword">private</span> List&#x3C;Color> BrickColors = <span class="hljs-keyword">new</span>()
        {
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#BC4A3C"</span>),
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#CE7064"</span>),
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#D88D83"</span>),
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#E2A9A2"</span>),
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#AB4336"</span>),
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#8C372C"</span>),
            (Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#6D2B22"</span>),
        };

</code></pre>
<p><img src="/assets/images/posts/Pasted%20image%2020231112062541.png" alt=""></p>
<h2>Let's Move The Paddle</h2>
<p>Next step would be to move the paddle back and forth across the screen. I want to be able to use the mouse to control the paddle since that will allow faster movements than just arrow keys. So let's add some mouse event listeners.</p>
<h3>First, Some Refactoring</h3>
<p>Above, I ask the question:</p>
<blockquote>
<p>Right now, every brick is at position 0,0. That's not a very fun game! So, my question is, should I store position as part of the rectangle, or have a separate variable to store the position?</p>
</blockquote>
<p>One thing to note about the Rectangle is that it is an immutable struct and that I cannot change the (x,y) position of the Rectangle without recreating it, and there is not any built-in methods to create a new one from an existing one easily. Instead, I'll add a Location to the DisplayItem interface.</p>
<p>Which means that the Shape property can just be a Size, since I'm really only using half of the Rectangle.</p>
<pre><code class="hljs language-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title">DisplayItem</span>
{
    <span class="hljs-keyword">public</span> Size Shape { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
    <span class="hljs-keyword">public</span> Point Location { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; }
}
</code></pre>
<p>Which means updating the constructors for all the DisplayItems to look like this (this is just the Brick one, but they all look the same, but with different Size numbers):</p>
<pre><code class="hljs language-csharp">    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">Brick</span>(<span class="hljs-params"><span class="hljs-built_in">int</span> x, <span class="hljs-built_in">int</span> y</span>)</span>
    {
        Shape = <span class="hljs-keyword">new</span> Size(<span class="hljs-number">20</span>, <span class="hljs-number">10</span>);
        Location = <span class="hljs-keyword">new</span> Point(x, y);
    }
</code></pre>
<p>And then updating the calls to <code>AddRectangleToCanvas</code> in the MainWindow.xaml.cs to use the new Location property:</p>
<pre><code class="hljs language-csharp">	AddRectangleToCanvas(
		GetNextBrickColorBrush(),
		brick.Location.X,
		brick.Location.Y,
		brick.Shape.Width,
		brick.Shape.Height);
</code></pre>
<p>Since showing all the little refactorings in the blog post is too much to type (and tedious to read!) here is the <a href="https://github.com/pburrows/BrickOutALot/commit/992c9026682d319dc9ca258e973616c72a46420c">post-refactoring commit</a> and this is the updated <a href="https://github.com/pburrows/BrickOutALot/commit/992c9026682d319dc9ca258e973616c72a46420c#diff-440cde2402216faf84ec618fff13e5be96ea7ccdbbedfb96620ffa0fe9e5dd02">BreakoutModel.cs</a> that has the separated Rectangle.</p>
<h3>Back to Mouse Movements</h3>
<p>In MainWindow.xaml.cs, we will hook up the MouseMove event for the GameCanvas to an event handler called <code>GameCanvasOnMouseMove</code> and then update the Location of the paddle when the mouse moves:</p>
<pre><code class="hljs language-csharp">        <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">GameCanvasOnMouseMove</span>(<span class="hljs-params"><span class="hljs-built_in">object</span> sender, MouseEventArgs e</span>)</span>
        {
            <span class="hljs-keyword">var</span> position = e.GetPosition(GameCanvas);
            CurrentGame.Paddle.Location = <span class="hljs-keyword">new</span> System.Drawing.Point((<span class="hljs-built_in">int</span>)position.X, <span class="hljs-number">0</span>);
        }
</code></pre>
<p>When I run this, I can see the breakpoint hitting and the location being updated. However, the screen is not updating, because we only call DrawGameBoard one time.</p>
<p>We could choose to update the position of the paddle on the screen here, but MouseMove events are VERY noisy and since we are going to also need a smoothly traveling ball, let's set up a timer that updates the display of the game several times per second.</p>
<p>If we want the screen to refresh at 30 frames per second, we will want our timer to fire every 33 milliseconds.</p>
<p>Also, in the original <code>DrawGameBoard()</code> method we are not actually storing the Rectangle objects that are created which represent the paddle and ball. So let's create some fields in MainWindow to hold the timer and the rectangles for the paddle and ball:</p>
<pre><code class="hljs language-csharp">        <span class="hljs-keyword">public</span> DispatcherTimer refreshTimer;
        <span class="hljs-keyword">public</span> Rectangle paddleRectangle;
        <span class="hljs-keyword">public</span> Rectangle ballRectangle;
</code></pre>
<p>I am going to modify the <code>AddRectangleToCanvas()</code> method to return the created Rectangle and store the ball and paddle objects in the new fields when they are created. Here is the updated code which creates the original ball and paddle:</p>
<pre><code class="hljs language-csharp">paddleRectangle = AddRectangleToCanvas(
	<span class="hljs-keyword">new</span> SolidColorBrush(Colors.Red),
	CurrentGame.Paddle.Location.X,
	CurrentGame.Paddle.Location.Y,
	CurrentGame.Paddle.Shape.Width,
	CurrentGame.Paddle.Shape.Height);

ballRectangle = AddRectangleToCanvas(
	<span class="hljs-keyword">new</span> SolidColorBrush(Colors.Green),
	CurrentGame.Ball.Location.X,
	CurrentGame.Ball.Location.Y,
	CurrentGame.Ball.Shape.Width,
	CurrentGame.Ball.Shape.Height)
</code></pre>
<p>Finally, we will set up the DispatchTimer in the OnLoaded method, after the game board is created</p>
<pre><code class="hljs language-csharp">        <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">MainWindow_OnLoaded</span>(<span class="hljs-params"><span class="hljs-built_in">object</span> sender, RoutedEventArgs e</span>)</span>
        {
            GameCanvas.Background = <span class="hljs-keyword">new</span> SolidColorBrush((Color)ColorConverter.ConvertFromString(<span class="hljs-string">"#F5E2E0"</span>));
            GameCanvas.MouseMove += GameCanvasOnMouseMove;
            DrawGameBoard();
            refreshTimer = <span class="hljs-keyword">new</span> DispatcherTimer();
            refreshTimer.Interval = <span class="hljs-keyword">new</span> TimeSpan(<span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">0</span>, <span class="hljs-number">33</span>);
            refreshTimer.Tick += RefreshTimerOnTick;
            refreshTimer.Start();
        }

        <span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">RefreshTimerOnTick</span>(<span class="hljs-params"><span class="hljs-built_in">object</span>? sender, EventArgs e</span>)</span>
        {
            UpdateGameBoard();
        }

</code></pre>
<p>And implement the <code>UpdateGameBoard()</code> method that fires whenever the timer ticks. For now this method will just update the paddle. But we will add updating the ball and other logic to it later:</p>
<pre><code class="hljs language-csharp"><span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">UpdateGameBoard</span>()</span>
{
	<span class="hljs-keyword">if</span> (paddleRectangle == <span class="hljs-literal">null</span>)
	{
		<span class="hljs-keyword">return</span>;
	}
	
	Canvas.SetLeft(paddleRectangle, CurrentGame.Paddle.Location.X);
}
</code></pre>
<p>When we run it, we can see how it works. In the image below you can see the paddle tracking my mouse as I move it.</p>
<p><img src="/assets/images/posts/20231029-1040-15.6265679.mp4" alt="20231029-1040-15.6265679.mp4"></p>
<p>I'll probably come back to this later when I start fine-tuning the game because right now the paddle moves very fast and responsively with my mouse which will probably make the game too easy (unless I make the ball move very fast!)</p>
<p>This is a good point to <a href="https://github.com/pburrows/BrickOutALot/commit/ff3b655b25b43ab5961ad4020f0b6524137f0fbb">check-point the code</a>. It's easier to see the changes to MainWindow.xaml.cs in the Github diff viewer.</p>
<h2>Moving the Ball</h2>
<p>The next obvious step is getting the ball to move. This is the part where my lack of math classes for the last 30 years is going to bite me. And, honestly, this is the part of video game development that has always seemed intimidating.</p>
<p>One of the reasons I chose Breakout as the game to clone is that there IS a math component to it, but it shouldn't be TOO complicated. I shouldn't have to deal with matrixes or transformations or anything like that (which I only vaguely remember from an old Algebra 2 class.) Instead, I should be able to use vectors to track the direction and velocity of the ball and appropriately add or subtract values from those vectors (or reverse them) whenever the ball hits something.</p>
<p>At least, that's the idea that is in my head right now. We will see what the reality becomes.</p>
<p>First let's add variables to the Ball to track its velocity:</p>
<pre><code class="hljs language-csharp">    <span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> VelocityX { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-number">1</span>;
    <span class="hljs-keyword">public</span> <span class="hljs-built_in">int</span> VelocityY { <span class="hljs-keyword">get</span>; <span class="hljs-keyword">set</span>; } = <span class="hljs-number">-1</span>;
</code></pre>
<p>Since the ball position is starting in the bottom left corner (0,630), we want the Y value to decrease (so the ball moves up the screen) and the X value to increase (so the ball moves from the left to the right across the screen.)</p>
<p>To our <code>UpdateGameBoard()</code> method, which is called at every tick of the timer, we will call a new method called <code>UpdateBallPosition()</code> which adds the velocity to the current location of the ball and updates it on the screen.</p>
<pre><code class="hljs language-csharp"><span class="hljs-function"><span class="hljs-keyword">private</span> <span class="hljs-keyword">void</span> <span class="hljs-title">UpdateBallPosition</span>()</span>
{
	<span class="hljs-keyword">var</span> newX = CurrentGame.Ball.Location.X + CurrentGame.Ball.VelocityX;
	<span class="hljs-keyword">var</span> newY = CurrentGame.Ball.Location.Y + CurrentGame.Ball.VelocityY;
	CurrentGame.Ball.SetLocation(newX, newY);
	Canvas.SetLeft(ballRectangle, CurrentGame.Ball.Location.X);
	Canvas.SetTop(ballRectangle, CurrentGame.Ball.Location.Y);
}
</code></pre>
<p>I also added a <code>SetLocation()</code> method to the Ball (and the Paddle) to get the references to <code>System.Drawing</code> out of the MainWindow.xaml.cs code (since WPF has its own implementations of Rectangles, Points, and other similar components.)</p>
<p>Here is what it looks like with the speed set to 1 (VelocityX = 1, VelocityY = -1):</p>
<p><img src="/assets/images/posts/20231029-1117-18.3207067.mp4" alt="20231029-1117-18.3207067.mp4">
That is excruciatingly slow! But it gives a good starting point to play around and see what a good initial velocity value is (purely subjective, of course.)</p>
<p>After playing around a little, I'll go with 8 (8,-8) as the initial velocity. This is satisfyingly faster:</p>
<p><img src="/assets/images/posts/20231029-1129-16.7299432.mp4" alt="20231029-1129-16.7299432.mp4"></p>
<p>The ball, of course, is flying off the side of the screen because it doesn't know about borders and edges. That will be the next step. But first, let's go ahead and <a href="https://github.com/pburrows/BrickOutALot/commit/e674da4e1b45d9c91b2d389d3707fd557b429793">commit</a> this step so we can track what changed.</p>
<h2>Edge Detection</h2>
<p>Let's stop the ball from flying off the edge of the screen. Instead, we want the ball to "bounce" off the edges (or "reflect.") Because all of our edges in this game are right-angles, we can take a shortcut to figuring out how the ball reflects. All we need to do is reverse the velocity of the direction where it reached the edge.</p>
<p>For example, if the ball is traveling to the right of the screen with a VelocityX of 8, when it reaches the right most part of the screen, we need to set the VelocityX to -8 so it starts traveling back in the other direction.</p>
<p>One of the other things I want to change in this step is where the logic is stored. This logic shouldn't be in the WPF code, whose only job should be displaying the game and reacting to user events, rather, it should be encapsulated as part of the game logic inside of the game itself. We are going to introduce a BrickOutGame class in our BrickOut.GameLogic project and move the ownership of the GameBoard into that class. This class is also where we will store the logic for the ball movement and the various hit tests.</p>
<p>First, before we implement any more logic, let's do the refactoring. I won't walk through all the changed bits, but you can see the updated code in <a href="https://github.com/pburrows/BrickOutALot/commit/f5fcfaf0ba982510128020676315466c1596916c">this commit</a> at github.</p>
<p>Now we'll move the <code>UpdateBallPosition()</code> method into the BrickOutGame class and implement the edge detection:</p>
<pre><code class="hljs language-csharp">    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">UpdateBallPosition</span>()</span>
    {
        <span class="hljs-keyword">var</span> newX = GameBoard.Ball.Location.X + GameBoard.Ball.VelocityX;
        <span class="hljs-keyword">var</span> newY = GameBoard.Ball.Location.Y + GameBoard.Ball.VelocityY;

        <span class="hljs-keyword">if</span> (newX >= GameBoard.Width <span class="hljs-number">-5</span> || newX &#x3C;=<span class="hljs-number">0</span>)
        {
            GameBoard.Ball.VelocityX *= <span class="hljs-number">-1</span>;
        }

        <span class="hljs-keyword">if</span> (newY >= GameBoard.Height <span class="hljs-number">-5</span> || newY &#x3C;= <span class="hljs-number">0</span>)
        {
            GameBoard.Ball.VelocityY *= <span class="hljs-number">-1</span>;
        }
        
        GameBoard.Ball.SetLocation(newX, newY);
    }
</code></pre>
<p>I'm still hardcoding all my values for paddle size and ball width. I'll need to come back and change that in a fine-tuning step (for instance, I think the ball is too small right now.)</p>
<p>Here is the ball moving around the screen and bouncing off the edges:</p>
<p><video muted autoplay loop controls src="http://localhost:3000/assets/images/posts/20231029-1153-53.8520583.mp4"></video></p>
<p>It is still not aware of the other items on the screen, like the paddle and the bricks. But that will be the next step.</p>
<p>Let's go ahead and <a href="https://github.com/pburrows/BrickOutALot/commit/4622e01f069a03d9e7ce1ce985cf1d3a4749bbe9">commit</a> this step before we move on.</p>]]></description><link>https://cleverhumans.com/posts/2023-11-12-breakout-01</link><guid isPermaLink="true">https://cleverhumans.com/posts/2023-11-12-breakout-01</guid><pubDate>Sun, 12 Nov 2023 11:21:31 GMT</pubDate></item><item><title><![CDATA[Now and Then]]></title><description><![CDATA[<p>The <a href="https://www.youtube.com/watch?v=AW55J2zE3N4">new Beatle's song</a> is actually quite beautiful.</p>
<p>There's a mini-documentary on the creation of the Beatles song here:</p>
<p><a href="https://www.youtube.com/watch?v=APJAQoSCwuA">https://www.youtube.com/watch?v=APJAQoSCwuA</a></p>]]></description><link>https://cleverhumans.com#2023-11-10T15:01:04.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2023-11-10T15:01:04.000Z</guid><pubDate>Fri, 10 Nov 2023 15:01:04 GMT</pubDate></item><item><title><![CDATA[My top songs of 2019]]></title><description><![CDATA[<p>I'm not sure if this list is arranged by how much I listened to each song, but it seems to be. Though, I am surprised by the first song, "First Person on Earth" by Rober DeLong. It is a good song, but I don't think I once specifically played that song. My guess is it showed up in a lot of lists when I chose to play a "Radio."</p>
<p><img src="/assets/images/posts/2019-12-06-My-top-songs-of-2019-image-20231111073132152.png" alt=""></p>
<p>What would be more interesting is a ranking of songs by which songs I chose to play the "radio" for. For instance, I played grandson radio quite a bit (and grandson's songs claim positions 2 and 3 on my list).</p>
<h2>grandson</h2>
<p>grandson was one of my happy discoveries this year. Jordan Benjamin makes very good modern "protest" music. Much like Rage Against the Machine, but with a more electronic influence. For instance, his song about school shootings called "thoughts &#x26; prayers" (grandson seems to not like capitalization) starts with the verse:</p>
<pre><code>Smile for the camera
Another politician bought
I swear I heard another shot
Cash another payment
Bled all on the canvas
There's murder on the campus
</code></pre>
<p><a href="https://www.youtube.com/watch?v=4DQ-2tDzJxw">Thoughts and Prayers</a></p>
<p>And has the chorus of:</p>
<pre><code>No thoughts, no prayers
Can bring back what's no longer there
The silent are damned
The body count is on your heads
</code></pre>
<p>It is direct lyrics, unobscured by any metaphor. It is directly commenting on the do nothing culture of "our thoughts and prayers are with the victims tonight." Thoughts &#x26; Prayers are an abdication of responsibility, it is the idea that we should leave the fixing of our society in God's hands, ignoring that God left things in ours. It is playing "hot potato" with our school children.</p>
<h2>YUNGBLUD</h2>
<p>YUNGBLUD's Dominic Harrison has a hard rock style similar to grandson (but with opposite capitalization). He sings songs of being an outsider and how hard it is to find a place where you can fit in. His song "Kill Somebody" deals with those emotions, of the anger he feels towards the ones who fit in easily.</p>
<pre><code>Today you made me feel irrelevant
Twisted my intelligence
Made it seem there's no brain in my head
I'm like a skeleton, can't show my eyes
</code></pre>
<p>Singing songs of the outsider strikes me as very topical in today's world. Recently, Harrison was asked not to perform at a High School in California because of this song. Which strikes me as more avoiding of a problem instead of addressing it head on.</p>
<h2>Hear what I say</h2>
<p>You have to scroll down surprisingly far to see the first rap song on my list (Run the Jewels' "Legend Has It"). Which I think reflects less how much I listen to rap, as it does how I would often just put the Spotify "Alternative Beats" on as background music when I work or drive.</p>
<p>But once you get down that far, you start to see songs by Vince Staples, Madlib, ScHoolboy Q, and a lot of other great, modern (alternative) hip-hop.</p>
<p>It's fun that Spotify shows us this automated review of the year. But I don't know how much it really reflects what I like, as it represents how Spotify's algorithms determine which songs are similar to each other.</p><div class="link-preview"><div class=""><a class="titleLinkHref" href="https://www.youtube.com/watch?v=4DQ-2tDzJxw">https://www.youtube.com/watch?v=4DQ-2tDzJxw</a><div class=""><a class="titleLink" href="https://www.youtube.com/watch?v=4DQ-2tDzJxw"><img src="https://www.youtube.com/s/desktop/a669eefe/img/favicon_144x144.png" class="favIcon"><h4>grandson - Thoughts and Prayers (Official Audio) - YouTube</h4></a></div></div><img src="https://i.ytimg.com/vi/4DQ-2tDzJxw/maxresdefault.jpg" class="previewImage"><div class="description"><b>GrandsonVEVO — </b>Music video by grandson performing Thoughts and Prayers. http://vevo.ly/jXgRJO#grandson #ThoughtsandPrayers #Vevo #Alternative #OfficialAudio</div></div>]]></description><link>https://cleverhumans.com/posts/2019-12-06-My-top-songs-of-2019</link><guid isPermaLink="true">https://cleverhumans.com/posts/2019-12-06-My-top-songs-of-2019</guid><pubDate>Fri, 06 Dec 2019 16:35:22 GMT</pubDate></item><item><title><![CDATA[somewhere between the sacred silence...]]></title><description><![CDATA[<p>somewhere between the sacred silence and sleep: disorder.</p>]]></description><link>https://cleverhumans.com#2019-03-27T20:53:21.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2019-03-27T20:53:21.000Z</guid><pubDate>Wed, 27 Mar 2019 20:53:21 GMT</pubDate></item><item><title><![CDATA[Kindergarten Cop Remake]]></title><description><![CDATA[<p>I would like to see a remake of Kindergarten Cop starring Rowan Atkinson playing the Mr. Bean character, instead of Arnold Schwarzenegger.</p>]]></description><link>https://cleverhumans.com#2019-02-06T20:33:15.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2019-02-06T20:33:15.000Z</guid><pubDate>Wed, 06 Feb 2019 20:33:15 GMT</pubDate></item><item><title><![CDATA[Astronaut back on earth]]></title><description><![CDATA[<p><img src="/assets/images/posts/s8gdj4y96hb21.gif" alt=""></p>
<p>My fondest dream is to one day have this issue.</p>]]></description><link>https://cleverhumans.com#2019-01-21T16:23:33.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2019-01-21T16:23:33.000Z</guid><pubDate>Mon, 21 Jan 2019 16:23:33 GMT</pubDate></item><item><title><![CDATA[Need a new car?]]></title><description><![CDATA[<p><a href="https://tanks-alot.co.uk/product/margret-thatchers-armoured-bus/">Margaret Thatcher's armored bus is for sale on the internet!</a></p>
<blockquote>
<p>Margret Thatchers Armoured Bus – This bus was specially commissioned for Margret Thatcher and her cabinet after the Brighton bombings. At obscene cost, It’s supposed to weigh 38 ton, have run flat tyres and be fully armoured all over to withstand 7.62 rounds. with a two foot deep honeycombed anti blast floor made from an unpronounceable material.</p>
</blockquote>
<p>Of course, if it is gone by the time you see this, Tanks-a-Lot can probably hook you up with a new daily driver that will really turn heads!</p>]]></description><link>https://cleverhumans.com#2019-01-20T14:15:34.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2019-01-20T14:15:34.000Z</guid><pubDate>Sun, 20 Jan 2019 14:15:34 GMT</pubDate></item><item><title><![CDATA[Why I Write]]></title><description><![CDATA[<p>I don't usually remember things, details, about my life unless I write them down as a detail in a story or an essay. People ask me why I write? I write to remember.</p>]]></description><link>https://cleverhumans.com#2019-01-19T00:06:18.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2019-01-19T00:06:18.000Z</guid><pubDate>Sat, 19 Jan 2019 00:06:18 GMT</pubDate></item><item><title><![CDATA[Dr. Demento Covered in Punk]]></title><description><![CDATA[<p>Just found this cool album of cover songs
<a href="https://open.spotify.com/embed/album/2rfJWlz3zx7Ore5HWz13A4">Album: Dr. Demento Covered in Punk</a></p>]]></description><link>https://cleverhumans.com#2019-01-16T21:25:46.000Z</link><guid isPermaLink="true">https://cleverhumans.com#2019-01-16T21:25:46.000Z</guid><pubDate>Wed, 16 Jan 2019 21:25:46 GMT</pubDate></item></channel></rss>