audventure.html 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <!DOCTYPE html>
  2. <html lang="en-us">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="generator" content="Hugo 0.36" />
  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 class="twitter">
  23. <a href="http://twitter.com/pleasantprog">@pleasantprog</a>
  24. </li>
  25. <li><a href="/pages/projects.html">projects</a></li>
  26. <li><a href="/posts.html">archives</a></li>
  27. <li><a href="/tags.html">tags</a></li>
  28. <li><a href="/rss.xml">rss</a></li>
  29. </ul>
  30. </nav>
  31. </header>
  32. <div id="container">
  33. <main id="content" role="main">
  34. <article itemscope itemtype="http://schema.org/BlogPosting">
  35. <h1 class="p-name entry-title" itemprop="headline name">
  36. <a href="/posts/audventure.html">Audventure</a></h1>
  37. <small>
  38. <span class="dateline">Posted: <time itemprop="datePublished" datetime="2017-11-19">2017-11-19</time></span>
  39. | More posts about
  40. <a class="tag p-category" href="/tags/games.html" rel="tag">
  41. games
  42. </a>
  43. <a class="tag p-category" href="/tags/programming.html" rel="tag">
  44. programming
  45. </a>
  46. </small>
  47. <div class="e-content entry-content" itemprop="entry-text">
  48. <p>Sometime around 2013 I wrote a clone of the GBA game <a href="https://www.nintendo.co.jp/n08/bit_g/">bit Generations
  49. SoundVoyager</a> called
  50. <a href="https://audventure.pleasantprogrammer.com">audventure</a>. SoundVoyager is
  51. actually a collection of mini-games where sound is the main focus. You can
  52. actually play the game blind, and at some point, that&rsquo;s pretty much what
  53. happens.</p>
  54. <h2 id="sound-catcher">sound catcher</h2>
  55. <p>The signature mini-game in SoundVoyager is sound catcher. In the mini-game, you
  56. can only move left and right at the bottom of the stage, while a &ldquo;sound&rdquo; falls
  57. from the top. Your goal is to catch the sound which is signified by a green dot.
  58. When you catch it, the sound or beat becomes part of the BGM and a new dot
  59. appears with a different sound.</p>
  60. <p>You can of course use your eyes and move accordingly, but if you put on
  61. earphones, you can actually hear where the dot is, either on your left or right,
  62. with it getting louder as it gets close to you. As you collect more sounds, the
  63. dot gets more and more transparent. Eventually (and this is where it gets fun),
  64. you won&rsquo;t be able to see the sounds anymore and will have to rely mostly on your
  65. ears.</p>
  66. <p>You can see what the original game looks like in <a href="https://www.youtube.com/watch?v=C12WRgfIOC8">this
  67. video</a> or you can play it under
  68. <em>sound safari</em> in <a href="https://audventure.pleasantprogrammer.com">audventure</a>.</p>
  69. <h2 id="webaudio-vs-flash">WebAudio vs Flash</h2>
  70. <p>At the time I wrote audventure, only Chrome supported WebAudio. Also, the API
  71. looked (and still looks) quite complicated. Flash on the other hand, was
  72. starting to die, but still well-supported so I went with that. For the most
  73. part, it worked okay though Chrome actually had timing issues when playing
  74. sounds. Now, it doesn&rsquo;t work in any browser. I tried to debug the issues but
  75. ultimately ended up just rewriting it to use WebAudio instead.</p>
  76. <p>For the game, I needed to simulate the source of the sound in 2D/3D space. Flash
  77. only really gives you stereo panning and volume control. With some maths, we can
  78. actually get an acceptable solution. Less importantly, I needed to be able to
  79. get frequency data of the currently playing &ldquo;sound&rdquo; to pulse the background. For
  80. this, I actually had to implement the feature in the Flash library I was using.</p>
  81. <p>With WebAudio, spatial audio is already built-in and you can simply give it the
  82. coordinates of the sounds and the listener. There are some other options to
  83. tweak, but for the most part, no complex math is needed. Getting frequency data
  84. for a sound is also actually built-in and didn&rsquo;t take too long to integrate.</p>
  85. <p>Overall, I was impressed by how much you can do with WebAudio out-of-the-box. I
  86. kind of understand why it&rsquo;s complicated, but there&rsquo;s some simple functionality
  87. that I wish was included. For example, there is no API to pause and then resume
  88. playing an audio buffer. You have to manually save the elapsed time and play
  89. from there.</p>
  90. <h2 id="other-mini-games">Other mini-games</h2>
  91. <p>So far I&rsquo;ve only actually implemented the sound catcher mini-game. There are
  92. around 4 different categories with slight variations in between.</p>
  93. <h3 id="sound-catcher-sound-slalom">sound catcher / sound slalom</h3>
  94. <p>I&rsquo;ve explained sound catcher a while ago; sound slalom is a minor variation on
  95. that. Instead of waiting for the &ldquo;sound&rdquo; to reach you, you now have to guide
  96. yourself in between 2 &ldquo;poles&rdquo; of sound, as in <a href="https://en.wikipedia.org/wiki/Slalom_skiing">slalom
  97. skiing</a>. But this time, you can
  98. also accelerate forward. The goal is to finish the course before the time runs
  99. out.</p>
  100. <h3 id="sound-drive-sound-chase">sound drive / sound chase</h3>
  101. <p>In sound drive, you&rsquo;re driving against the flow on a 5 lane road. You have to
  102. avoid oncoming cars, trucks and animals until you reach the end. You&rsquo;re allowed
  103. to change lanes and accelerate, and the game tracks your best time. Sound chase
  104. is pretty much the same, except you&rsquo;re trying to catch up to a &ldquo;sound&rdquo;.</p>
  105. <h3 id="sound-cannon">sound cannon</h3>
  106. <p>In sound cannon, you&rsquo;re immobile but can rotate within a 180 degree angle. Your
  107. goal is too shoot down &ldquo;sounds&rdquo; which are heading your way. If a sound reaches
  108. you, it&rsquo;s game over. You win when you kill all the sounds.</p>
  109. <h3 id="sound-picker-sound-cock">sound picker / sound cock</h3>
  110. <p>In sound picker, you can move in a giant square field where various sounds are
  111. scattered around. Your goal is to pick up all the sounds within the time limit.
  112. Sound cock is similar, except the sounds are chickens and you have to chase them
  113. around.</p>
  114. <h2 id="source-code">Source Code</h2>
  115. <p>If you want to see the source code, you can check it out
  116. <a href="https://git.pleasantprogrammer.com/games/audventure">here</a>. The sound files
  117. aren&rsquo;t in the repo though, since I&rsquo;m not quite sure about the licensing. If you
  118. want to contribute music or sound effects, I&rsquo;d gladly appreciate it.</p>
  119. </div>
  120. <aside class="postpromonav">
  121. <nav>
  122. <ul class="pager clearfix">
  123. <li class="previous">
  124. <a href="/posts/openpreppad.html" rel="prev" title="OpenPrepPad">&larr; Previous post</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; 2018 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>