<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CrownTV</title>
    <description>The latest articles on DEV Community by CrownTV (@crowntv_us).</description>
    <link>https://dev.to/crowntv_us</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4281865%2F3e2f1a06-7d0d-4341-b4c7-bdbff7f46341.png</url>
      <title>DEV Community: CrownTV</title>
      <link>https://dev.to/crowntv_us</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/crowntv_us"/>
    <language>en</language>
    <item>
      <title>A daily-challenge stacking game in 47 KB of vanilla JavaScript</title>
      <dc:creator>CrownTV</dc:creator>
      <pubDate>Fri, 04 Dec 2026 05:17:52 +0000</pubDate>
      <link>https://dev.to/crowntv_us/a-daily-challenge-stacking-game-in-47-kb-of-vanilla-javascript-1h4f</link>
      <guid>https://dev.to/crowntv_us/a-daily-challenge-stacking-game-in-47-kb-of-vanilla-javascript-1h4f</guid>
      <description>&lt;p&gt;We build and install real video walls for a living at &lt;a href="https://www.crowntv-us.com/" rel="noopener noreferrer"&gt;CrownTV&lt;/a&gt; in New York, so for our first browser game we made one about stacking screens. It's called &lt;strong&gt;Screen Stack&lt;/strong&gt;, it's free, and you can play it here: &lt;a href="https://www.crowntv-us.com/game/" rel="noopener noreferrer"&gt;www.crowntv-us.com/game&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The whole thing is four small files: one HTML page, one stylesheet, one script and a tiny audio file. That is about 34 KB of JavaScript and 47 KB in total (17 KB zipped). No engine and no libraries. Here are the four small tricks that made that possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. The core mechanic is interval overlap
&lt;/h2&gt;

&lt;p&gt;A screen slides back and forth. When you tap, the game compares it with the screen below as two 1D intervals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;L&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;ov&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;R&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="no"&gt;L&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// overlap width&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;ov &amp;lt;= 0&lt;/code&gt; you missed and the run is over. Otherwise the new screen shrinks to the overlap, and whatever hangs past &lt;code&gt;L&lt;/code&gt; or &lt;code&gt;R&lt;/code&gt; goes into a list of falling pieces with a little spin so it tumbles away. That is the entire physics system.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A forgiving perfect window
&lt;/h2&gt;

&lt;p&gt;Pixel-perfect drops are close to impossible on a phone, so a drop within a small tolerance of the screen below snaps into place and counts as perfect. Three perfects in a row make the wall slightly wider again, which gives players a way back after a bad start instead of a slow death spiral. A rare golden screen restores the full width if you land it perfectly.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. A daily level with no server
&lt;/h2&gt;

&lt;p&gt;Every player gets the same Daily Tower, and there is no backend involved. The game pulls its randomness from one function, and in daily mode that function is a tiny seeded PRNG (mulberry32) seeded with today's date:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;rng&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mode&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s1"&gt;'daily'&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nf"&gt;mulberry32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/-/&lt;/span&gt;&lt;span class="n"&gt;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;random&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same date, same seed, same tower for everyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Sound without sound files
&lt;/h2&gt;

&lt;p&gt;The sound effects are Web Audio oscillators: a short beep through a gain envelope. The pitch climbs with your combo (&lt;code&gt;440 * 1.12 ** streak&lt;/code&gt;, capped), so a good run literally sounds like it is going up. Phones also get a short &lt;code&gt;navigator.vibrate()&lt;/code&gt; buzz on a perfect drop and a longer one when you miss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Small things that mattered
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The canvas is scaled by &lt;code&gt;devicePixelRatio&lt;/code&gt;, capped at 2, which keeps the pixel count sane on high-density phones.&lt;/li&gt;
&lt;li&gt;High scores and settings live in &lt;code&gt;localStorage&lt;/code&gt;. The builds we upload to game portals make no network requests at all.&lt;/li&gt;
&lt;li&gt;Results share as an emoji grid, Wordle-style, through &lt;code&gt;navigator.share&lt;/code&gt; or the clipboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  One thing the day job taught us
&lt;/h2&gt;

&lt;p&gt;A fact from the hardware side that we like: in window displays, glass eats brightness. A rule of thumb from the &lt;a href="https://highbrightnessdisplay.com/nits-guide" rel="noopener noreferrer"&gt;nits guide&lt;/a&gt; on a related site of ours is to multiply the screen's nits by the visible light transmission of the glass, so 4,000 nits behind 70% glass reads closer to 2,800. None of that is simulated in the game, where every screen is equally bright.&lt;/p&gt;

&lt;p&gt;If you try it, tell us your best tower and whether the difficulty curve feels fair. Play it here: &lt;a href="https://www.crowntv-us.com/game/" rel="noopener noreferrer"&gt;Screen Stack&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>gamedev</category>
      <category>webdev</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
