<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Tetrua on sunbro.dev</title><link>https://sunbro.dev/categories/tetrua/</link><description>Recent content in Tetrua on sunbro.dev</description><generator>Hugo -- 0.131.0</generator><language>en</language><lastBuildDate>Thu, 09 Mar 2023 22:24:07 +0000</lastBuildDate><atom:link href="https://sunbro.dev/categories/tetrua/index.xml" rel="self" type="application/rss+xml"/><item><title>Tetrua - Part 1</title><link>https://sunbro.dev/posts/2020-03-18-tetrua-part-1/</link><pubDate>Wed, 18 Mar 2020 00:05:00 +0100</pubDate><guid>https://sunbro.dev/posts/2020-03-18-tetrua-part-1/</guid><description>Presenting Tetrua</description><content:encoded><![CDATA[<h2 id="grec">GREC</h2>
<p>The idea behind G Rapidement Envie de Coder (GREC - I Wanna Code Quickly)
is to take the concept of a 
<a href="https://en.wikipedia.org/wiki/Game_jam" target="_blank" ><strong>game jam</strong></a> / 
<a href="https://en.wikipedia.org/wiki/Hackathon" target="_blank" ><strong>hackathon</strong></a>
and apply it a short project so third year computer science students can use
it to learn a new concept or language. The project should be able to be
completed in a weekend or 48 hours.</p>
<h2 id="tetrua">Tetrua</h2>
<p>For this project, the end goal is to create a tetris clone using 
<a href="https://www.lua.org/about.html" target="_blank" ><strong>Lua</strong></a> +

<a href="https://love2d.org/" target="_blank" ><strong>LÖVE</strong></a>.</p>
<h3 id="graphics">Graphics</h3>
<p>LÖVE makes it very easy to display sprites and images to screen. As such
my first step was to draw the different blocks needed for the different

<a href="https://tetris.fandom.com/wiki/Tetromino" target="_blank" ><strong>tetrominos</strong></a>. I started off by drawing each tetrimino with

<a href="https://www.aseprite.org/" target="_blank" ><strong>Aseprite</strong></a>:</p>
<p>


<img src="/images/tetromino_i.png" alt="The &amp;ldquo;I&amp;rdquo; tetromino" loading="lazy" width="16"
    height="64" style="max-width: 100%; height: auto;" /></p>
<p>After thinking about it a bit more, I realized drawing each different color
block separately would be easier to deal with in-game and maybe a little more
memory-efficient in the long run, although that is not the priority.</p>
<p>


<img src="/images/block_i.png" alt="The &amp;ldquo;I&amp;rdquo; block" loading="lazy" width="16"
    height="16" style="max-width: 100%; height: auto;" /></p>
<p>Loading and displaying an image in Lua with LÖVE looks like this:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-Lua" data-lang="Lua"><span class="line"><span class="cl"><span class="c1">-- Load the image to a variable</span>
</span></span><span class="line"><span class="cl"><span class="n">sprite</span> <span class="o">=</span> <span class="n">love.graphics</span><span class="p">.</span><span class="n">newImage</span><span class="p">(</span><span class="s2">&#34;path/to/image&#34;</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="c1">-- Draw `sprite` to screen at (150, 150)</span>
</span></span><span class="line"><span class="cl"><span class="n">love.graphics</span><span class="p">.</span><span class="n">draw</span><span class="p">(</span><span class="n">sprite</span><span class="p">,</span> <span class="mi">150</span><span class="p">,</span> <span class="mi">150</span><span class="p">)</span>
</span></span></code></pre></div><h2 id="next-time">Next time</h2>
<p>That&rsquo;s it for now, the next article will likely be about how the game board
works. I hope you enjoyed reading this, see you next time!</p>
]]></content:encoded></item></channel></rss>