audventure.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="Hugo 0.92.0" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <link rel="stylesheet" href="/assets/css/theme.css">
  8. <link rel="alternate" href="/rss.xml" type="application/rss+xml" title="Pleasant Programmer">
  9. <script type="text/javascript" src="//use.typekit.net/iwm5axp.js"></script>
  10. <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
  11. <title>Audventure - Pleasant Programmer</title>
  12. </head>
  13. <body>
  14. <header id="header" role="banner">
  15. <div id="thomas">
  16. <img src="/assets/img/thomas.gif" alt="DJ THOMAS IN DA HAUS">
  17. <img src="/assets/img/thomas.png" alt="Pleasant Programmer">
  18. </div>
  19. <h1 class="site-title"><a href="/">Pleasant Programmer</a></h1>
  20. <nav id="menu" role="navigation">
  21. <ul>
  22. <li><a href="/pages/projects.html">projects</a></li>
  23. <li><a href="/posts.html">archives</a></li>
  24. <li><a href="/tags.html">tags</a></li>
  25. <li><a href="/rss.xml">rss</a></li>
  26. </ul>
  27. </nav>
  28. </header>
  29. <div id="container">
  30. <main id="content" role="main">
  31. <article itemscope itemtype="http://schema.org/BlogPosting">
  32. <h1 class="p-name entry-title" itemprop="headline name">
  33. <a href="/posts/audventure.html">Audventure</a></h1>
  34. <small>
  35. <span class="dateline">Posted: <time itemprop="datePublished" datetime="2017-11-19">2017-11-19</time></span>
  36. | More posts about
  37. <a class="tag p-category" href="/tags/games.html" rel="tag">
  38. games
  39. </a>
  40. <a class="tag p-category" href="/tags/programming.html" rel="tag">
  41. programming
  42. </a>
  43. </small>
  44. <div class="e-content entry-content" itemprop="entry-text">
  45. <p>Sometime around 2013 I wrote a clone of the GBA game <a href="https://www.nintendo.co.jp/n08/bit_g/">bit Generations
  46. SoundVoyager</a> called
  47. <a href="https://audventure.pleasantprogrammer.com">audventure</a>. SoundVoyager is
  48. actually a collection of mini-games where sound is the main focus. You can
  49. actually play the game blind, and at some point, that&rsquo;s pretty much what
  50. happens.</p>
  51. <h2 id="sound-catcher">sound catcher</h2>
  52. <p>The signature mini-game in SoundVoyager is sound catcher. In the mini-game, you
  53. can only move left and right at the bottom of the stage, while a &ldquo;sound&rdquo; falls
  54. from the top. Your goal is to catch the sound which is signified by a green dot.
  55. When you catch it, the sound or beat becomes part of the BGM and a new dot
  56. appears with a different sound.</p>
  57. <p>You can of course use your eyes and move accordingly, but if you put on
  58. earphones, you can actually hear where the dot is, either on your left or right,
  59. with it getting louder as it gets close to you. As you collect more sounds, the
  60. dot gets more and more transparent. Eventually (and this is where it gets fun),
  61. you won&rsquo;t be able to see the sounds anymore and will have to rely mostly on your
  62. ears.</p>
  63. <p>You can see what the original game looks like in <a href="https://www.youtube.com/watch?v=C12WRgfIOC8">this
  64. video</a> or you can play it under
  65. <em>sound safari</em> in <a href="https://audventure.pleasantprogrammer.com">audventure</a>.</p>
  66. <h2 id="webaudio-vs-flash">WebAudio vs Flash</h2>
  67. <p>At the time I wrote audventure, only Chrome supported WebAudio. Also, the API
  68. looked (and still looks) quite complicated. Flash on the other hand, was
  69. starting to die, but still well-supported so I went with that. For the most
  70. part, it worked okay though Chrome actually had timing issues when playing
  71. sounds. Now, it doesn&rsquo;t work in any browser. I tried to debug the issues but
  72. ultimately ended up just rewriting it to use WebAudio instead.</p>
  73. <p>For the game, I needed to simulate the source of the sound in 2D/3D space. Flash
  74. only really gives you stereo panning and volume control. With some maths, we can
  75. actually get an acceptable solution. Less importantly, I needed to be able to
  76. get frequency data of the currently playing &ldquo;sound&rdquo; to pulse the background. For
  77. this, I actually had to implement the feature in the Flash library I was using.</p>
  78. <p>With WebAudio, spatial audio is already built-in and you can simply give it the
  79. coordinates of the sounds and the listener. There are some other options to
  80. tweak, but for the most part, no complex math is needed. Getting frequency data
  81. for a sound is also actually built-in and didn&rsquo;t take too long to integrate.</p>
  82. <p>Overall, I was impressed by how much you can do with WebAudio out-of-the-box. I
  83. kind of understand why it&rsquo;s complicated, but there&rsquo;s some simple functionality
  84. that I wish was included. For example, there is no API to pause and then resume
  85. playing an audio buffer. You have to manually save the elapsed time and play
  86. from there.</p>
  87. <h2 id="other-mini-games">Other mini-games</h2>
  88. <p>So far I&rsquo;ve only actually implemented the sound catcher mini-game. There are
  89. around 4 different categories with slight variations in between.</p>
  90. <h3 id="sound-catcher--sound-slalom">sound catcher / sound slalom</h3>
  91. <p>I&rsquo;ve explained sound catcher a while ago; sound slalom is a minor variation on
  92. that. Instead of waiting for the &ldquo;sound&rdquo; to reach you, you now have to guide
  93. yourself in between 2 &ldquo;poles&rdquo; of sound, as in <a href="https://en.wikipedia.org/wiki/Slalom_skiing">slalom
  94. skiing</a>. But this time, you can
  95. also accelerate forward. The goal is to finish the course before the time runs
  96. out.</p>
  97. <h3 id="sound-drive--sound-chase">sound drive / sound chase</h3>
  98. <p>In sound drive, you&rsquo;re driving against the flow on a 5 lane road. You have to
  99. avoid oncoming cars, trucks and animals until you reach the end. You&rsquo;re allowed
  100. to change lanes and accelerate, and the game tracks your best time. Sound chase
  101. is pretty much the same, except you&rsquo;re trying to catch up to a &ldquo;sound&rdquo;.</p>
  102. <h3 id="sound-cannon">sound cannon</h3>
  103. <p>In sound cannon, you&rsquo;re immobile but can rotate within a 180 degree angle. Your
  104. goal is too shoot down &ldquo;sounds&rdquo; which are heading your way. If a sound reaches
  105. you, it&rsquo;s game over. You win when you kill all the sounds.</p>
  106. <h3 id="sound-picker--sound-cock">sound picker / sound cock</h3>
  107. <p>In sound picker, you can move in a giant square field where various sounds are
  108. scattered around. Your goal is to pick up all the sounds within the time limit.
  109. Sound cock is similar, except the sounds are chickens and you have to chase them
  110. around.</p>
  111. <h2 id="source-code">Source Code</h2>
  112. <p>If you want to see the source code, you can check it out
  113. <a href="https://git.pleasantprogrammer.com/games/audventure">here</a>. The sound files
  114. aren&rsquo;t in the repo though, since I&rsquo;m not quite sure about the licensing. If you
  115. want to contribute music or sound effects, I&rsquo;d gladly appreciate it.</p>
  116. </div>
  117. <aside class="postpromonav">
  118. <nav>
  119. <ul class="pager clearfix">
  120. <li class="previous">
  121. <a href="/posts/openpreppad.html" rel="prev" title="OpenPrepPad">&larr; Previous post</a>
  122. </li>
  123. <li class="next">
  124. <a href="/posts/isp-issues.html" rel="next" title="ISP Issues">Next post &rarr;</a>
  125. </li>
  126. </ul>
  127. </nav>
  128. </aside>
  129. <section class="comments">
  130. <script
  131. data-isso="https://isso.pleasantprogrammer.com/"
  132. data-isso-require-author="true"
  133. data-isso-vote="false"
  134. src="https://isso.pleasantprogrammer.com/js/embed.min.js">
  135. </script>
  136. <section id="isso-thread"></section>
  137. </section>
  138. </article>
  139. </main>
  140. <footer id="footer" role="contentinfo">
  141. <p>
  142. <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/deed.en_US">
  143. <img alt="CC-BY-SA" style="border-width:0" src="https://licensebuttons.net/l/by-sa/3.0/80x15.png">
  144. </a> &copy; 2022 Thomas Dy - Powered by <a href="http://gohugo.io">Hugo</a></p>
  145. </footer>
  146. </div>
  147. <script src="/assets/js/konami.js"></script>
  148. <script>
  149. var easter_egg = new Konami();
  150. easter_egg.code = function() {
  151. var el = document.getElementById('thomas');
  152. if(el.className == "whoa") {
  153. el.className = "";
  154. }
  155. else {
  156. el.className = "whoa";
  157. }
  158. document.body.scrollTop = document.documentElement.scrollTop = 0;
  159. }
  160. easter_egg.load();
  161. </script>
  162. </body>
  163. </html>