<?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: Samuel Collier</title>
    <description>The latest articles on DEV Community by Samuel Collier (@stcollier).</description>
    <link>https://dev.to/stcollier</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F784853%2F5f7ffb5e-3a13-46e5-b9d7-5a1109c647bf.jpg</url>
      <title>DEV Community: Samuel Collier</title>
      <link>https://dev.to/stcollier</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stcollier"/>
    <language>en</language>
    <item>
      <title>I made 3D Snake</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Sat, 01 Apr 2023 02:21:31 +0000</pubDate>
      <link>https://dev.to/stcollier/i-made-3d-snake-2ki4</link>
      <guid>https://dev.to/stcollier/i-made-3d-snake-2ki4</guid>
      <description>&lt;p&gt;Hello everyone! In my last few posts I've shown off some websites that I've built, but honestly JavaScript is overrated and I wanted to dive back into some lower level stuff. I had worked with C and SDL2 before, but I was still quite a beginner at graphics and the C language itself.&lt;/p&gt;

&lt;p&gt;To start things off, I started learning OpenGL from &lt;a href="https://learnopengl.com/Getting-started/OpenGL"&gt;this wonderful website&lt;/a&gt;. After setting up the project infrastructure on the 10th of March, I went through all the "Getting Started" tutorials. This just covers the basics of OpenGL and after re-reading the tutorial sections a few times, I decided to create my own project. I wanted to make a classic game, but in 3D, so I chose to make Snake. The game took 4 days in total to make and is composed of ~900 lines of C code.&lt;/p&gt;

&lt;p&gt;Here's a screenshot of the game:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NlvyPt87--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/200tn6s2kzdijm8x5lkb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NlvyPt87--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/200tn6s2kzdijm8x5lkb.png" alt="Image description" width="880" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to try out the game yourself or inspect the code, you can do that here at the Github repository: &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/STCollier"&gt;
        STCollier
      &lt;/a&gt; / &lt;a href="https://github.com/STCollier/Snake"&gt;
        Snake
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A snake game made with OpenGL and C
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
Snake&lt;/h1&gt;
&lt;p&gt;A snake game made with OpenGL and C (composed of 900 lines of questionable code)&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/81338469/229190939-9bffca2b-6ad4-4146-8ae8-2ebc88598565.png"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RaoQT7Mq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/81338469/229190939-9bffca2b-6ad4-4146-8ae8-2ebc88598565.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
Building&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Unix-like systems&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Dependences
&lt;ul&gt;
&lt;li&gt;GCC Compiler&lt;/li&gt;
&lt;li&gt;GLFW library (&lt;code&gt;sudo apt-get install libglfw3-dev&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/nothings/stb/blob/master/stb_image.h"&gt;stb_image.h&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://glad.dav1d.de/" rel="nofollow"&gt;GLAD&lt;/a&gt; (v.3.3)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/recp/cglm"&gt;cglm&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Windows&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;no&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/STCollier/Snake"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;p&gt;Let me know what you think!&lt;/p&gt;

</description>
      <category>gamedev</category>
      <category>graphics</category>
      <category>c</category>
    </item>
    <item>
      <title>Six Words -- A Unique Fullstack Application</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Wed, 25 Jan 2023 22:03:56 +0000</pubDate>
      <link>https://dev.to/stcollier/six-words-a-unique-fullstack-application-53lm</link>
      <guid>https://dev.to/stcollier/six-words-a-unique-fullstack-application-53lm</guid>
      <description>&lt;p&gt;Hello all!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR: &lt;a href="https://sixwords.fatpancake613.repl.co/" rel="noopener noreferrer"&gt;https://sixwords.fatpancake613.repl.co/&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Recently a friend and I created a fullstack application with the stack Pug + Express. This was the second fullstack application that I was a part of building, and my first time using Express &amp;amp; Pug (I had used Next.js previously). Overall I found Express and Pug pretty nice and simple, but I still prefer the ease of client/server communication that I feel that I can achieve better with Next.js. It was nice though having a much smaller application size (express and pug took up so little storage compared to Next.js!)&lt;/p&gt;

&lt;p&gt;The application idea was based on Ernest Hemmingway's famous six word story: "For sale: baby shoes, never worn." The idea of this application is to see what you can say in 6 words! It's a lot of fun to see what ideas you can form in such brevity.&lt;/p&gt;

&lt;p&gt;Overall building this application was a wonderful experience and I had a lot of fun collaborating :) Collaboration is something I highly encourage; you can take a nice and easy pace and have a lot of fun along the way, making whatever you decide to make.&lt;/p&gt;

&lt;p&gt;So finally, here are the links to the application:&lt;br&gt;
Replit link: &lt;a href="https://replit.com/@FatPancake613/SixWords?v=1" rel="noopener noreferrer"&gt;https://replit.com/@FatPancake613/SixWords?v=1&lt;/a&gt; (source code &amp;amp;&amp;amp; if you want to leave a like, we'd love that)&lt;br&gt;
Website link where you can try it out: &lt;strong&gt;&lt;a href="https://sixwords.fatpancake613.repl.co/" rel="noopener noreferrer"&gt;https://sixwords.fatpancake613.repl.co/&lt;/a&gt;&lt;/strong&gt; (note you need a replit account)&lt;/p&gt;

&lt;p&gt;Hope you enjoy, and happy coding!&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>chatgpt</category>
      <category>ai</category>
    </item>
    <item>
      <title>I just made my first fullstack application. Here's how.</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Thu, 12 Jan 2023 01:36:19 +0000</pubDate>
      <link>https://dev.to/stcollier/i-just-made-my-first-fullstack-application-heres-how-1am9</link>
      <guid>https://dev.to/stcollier/i-just-made-my-first-fullstack-application-heres-how-1am9</guid>
      <description>&lt;p&gt;Hey everyone!!&lt;/p&gt;

&lt;p&gt;I just made my created my first fullstack application, called &lt;strong&gt;The Quotes Place.&lt;/strong&gt; Simply stated, it's an platform where users can find and explore great quotes selected from all around the world! Here is the list of features!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A login system&lt;/li&gt;
&lt;li&gt;Ability to like and dislike quotes&lt;/li&gt;
&lt;li&gt;An admin system (for adding quotes)&lt;/li&gt;
&lt;li&gt;Dynamically generated profiles&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some screenshots!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxb9r9yzonz5o7nmfirdv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxb9r9yzonz5o7nmfirdv.png" alt="Image description" width="800" height="371"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flf1t67xzhfhb9tvhp28l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flf1t67xzhfhb9tvhp28l.png" alt="Image description" width="800" height="412"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you'd like to check it out, here's the link: &lt;br&gt;
Repl link: &lt;a href="https://replit.com/@STCollier/The-Quotes-Place?v=1" rel="noopener noreferrer"&gt;https://replit.com/@STCollier/The-Quotes-Place?v=1&lt;/a&gt; (I'd really appreciate it if you liked it!)&lt;br&gt;
Working URL: &lt;a href="https://the-quotes-place.stcollier.repl.co/" rel="noopener noreferrer"&gt;https://the-quotes-place.stcollier.repl.co/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How I made it
&lt;/h2&gt;

&lt;p&gt;It took &lt;strong&gt;6 weeks&lt;/strong&gt; to fully build this application. The stack that I chose was Next.js as the framework, Sass for styling, and MongoDB as the database. I had previous experience with React.js, but I was almost completely new to learning about clients, servers, APIs, requests, status codes, and so much more.&lt;/p&gt;

&lt;p&gt;Being almost completely new to all of this and jumping straight into building a fullstack application was a key factor in why this took so long to build (6 weeks as I stated earlier!) Perhaps if I had learned the basics of express.js, I could have built this a lot faster and had less of a steep learning curve. It's crazy thinking back on when I first started to build the application, I didn't even know what a GET or POST request was!!&lt;/p&gt;

&lt;h2&gt;
  
  
  The building process
&lt;/h2&gt;

&lt;p&gt;When I first created a Next.js project, it looked pretty similar to React.js, so I thought it would be pretty easy. But as I stated previously, I had little to no knowledge about how servers and databases worked, so it was quite the opposite. Even just getting the basic login system up was hard, and I was using ReplAuth, one of the easiest authentication systems to start using. Thanks to some help from a fellow discord member, I got introduced to &lt;code&gt;req.headers&lt;/code&gt; and &lt;code&gt;getServerSideProps&lt;/code&gt;, both of which I would come to use over and over again in my application. After about a week, I had successfully made a basic website where you could login with Replit. I had also used a tutorial to connect MongoDB to Next.js, but that was all in the backend and I hadn't connected it to an API to display results yet.&lt;/p&gt;

&lt;p&gt;Although this first step was already really hard, it would only get harder. Next up I decided to try to display results from my MongoDB collection onto the page. I was introduced to &lt;code&gt;Array.map,&lt;/code&gt; the MongoDB compass, and a lot more. Finally I had displayed quotes to the page, but now I had to add proper full stack functionality, by adding a feature where you could like a quote. This is where things started to get really rough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The like feature alone took me over 2 weeks to get working.&lt;/strong&gt; I dug through a ton of Stack Overflow posts, gists such as &lt;a href="https://gist.github.com/aerrity/fd393e5511106420fba0c9602cc05d35" rel="noopener noreferrer"&gt;this one&lt;/a&gt;, and so much more, but the reason I struggled so much was because I had to learn about APIs, HTTP request methods and statuses, proper JSON responses, along with integrating this all with MongoDB. I almost gave up here a few times, but I kept going. I must have googled hundreds of things, such as "MongoDB check for duplicate", "How to POST and GET data", "HTTP status codes", and so much more. The 4 best tools that helped me finally figure everything out were&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stack Overflow&lt;/li&gt;
&lt;li&gt;Github&lt;/li&gt;
&lt;li&gt;reqbin.com for testing my APIs&lt;/li&gt;
&lt;li&gt;Digging through other people's Next.js projects&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;But &lt;strong&gt;finally,&lt;/strong&gt; 2 weeks later and 90 lines of code that had been constantly revised, I had a working like button. I found that using the npm package &lt;a href="https://www.npmjs.com/package/next-connect" rel="noopener noreferrer"&gt;next-connect&lt;/a&gt; made this proccess a breeze for handling HTTP request methods.&lt;/p&gt;

&lt;p&gt;After this, the learning curve finally reached its climax, and things weren't that bad. The application was still nowhere near finished, but I was a lot more familiar with the stack. Soon I began writing API's quickly, without even needing to use google! I began to memorize a lot of HTTP status codes as well, which was kinda fun. Soon after about another week of work the application was finally starting to come together!&lt;/p&gt;

&lt;p&gt;To sum things up, here's some things that I did to finally finish my application.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Refactor and rewrite all my API's to use next-connect&lt;/li&gt;
&lt;li&gt;Add a MongoDB collection and API to store user data&lt;/li&gt;
&lt;li&gt;Add a tooltip to display who liked/disliked a post&lt;/li&gt;
&lt;li&gt;Add dynamic routing for each user&lt;/li&gt;
&lt;li&gt;Add an admin system to add quotes directly from the application&lt;/li&gt;
&lt;li&gt;Added a ratelimit (after having a friend completely spam requests and break the database)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And of course there was some nice frontend things to do too, such as&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Making the application responsive
and&lt;/li&gt;
&lt;li&gt;Adding nice animations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But all in all, I'm quite proud of what I built. It was so nice to see that my application finally came into fruition, and I'm super thankful for what I could learn along the way. I definitely want to use Next.js and MongoDB sometime in the future as well; I really like that stack! So finally thanks for reading, and happy coding!&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Creating an Indie Game -- Week 2</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Mon, 24 Oct 2022 02:22:26 +0000</pubDate>
      <link>https://dev.to/stcollier/creating-an-indie-game-week-2-1fpc</link>
      <guid>https://dev.to/stcollier/creating-an-indie-game-week-2-1fpc</guid>
      <description>&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;I'm back for the second update of making an Indie Game. If you're just joining us, here was the post for week one: &lt;a href="https://dev.to/stcollier/creating-an-indie-game-week-1-j4c"&gt;Creating an Indie Game -- Week 1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's an overview of what I did over the week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expanded the map a bit&lt;/li&gt;
&lt;li&gt;Tweaked the rendering of the map in order to prepare for the bigger world I'll soon be drafting&lt;/li&gt;
&lt;li&gt;Created two tree sprites (a regular tree and a tall tree)&lt;/li&gt;
&lt;li&gt;Imported the trees into the game and added falling leaves.&lt;/li&gt;
&lt;li&gt;Refactored a lot of code&lt;/li&gt;
&lt;li&gt;Added a basic interaction system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's some screenshots!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1XbVNXXV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fdsjnwexrjwu2wx33bzd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1XbVNXXV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fdsjnwexrjwu2wx33bzd.png" alt="Image description" width="403" height="325"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Q2g-dzPb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6q96ue7z1fietv4g3av.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Q2g-dzPb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6q96ue7z1fietv4g3av.png" alt="Image description" width="880" height="549"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This week was quite busy, so I didn't get as much done as possible. However, I hope to keep chipping away at this project, even if I don't get much done. Stay tuned for week 3, and follow me so you don't miss it!&lt;/p&gt;


&lt;div class="ltag__user ltag__user__id__784853"&gt;
    &lt;a href="/stcollier" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pijsx9CT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--jN4RSeDf--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/784853/5f7ffb5e-3a13-46e5-b9d7-5a1109c647bf.jpg" alt="stcollier image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/stcollier"&gt;Samuel Collier&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/stcollier"&gt;Student who enjoys the liberal arts along with web &amp;amp;&amp;amp; game development&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Creating an Indie Game -- Week 1</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Mon, 17 Oct 2022 02:32:22 +0000</pubDate>
      <link>https://dev.to/stcollier/creating-an-indie-game-week-1-j4c</link>
      <guid>https://dev.to/stcollier/creating-an-indie-game-week-1-j4c</guid>
      <description>&lt;p&gt;Hello!&lt;/p&gt;

&lt;p&gt;This is week one of making an indie game. The style is a 2D pixel art platformer. I'm not going to reveal much yet, but I'm hoping to have 3 stages, with the first stage being a grassy/forest environment, the second being in the caves, and the third being some sort of magma/mordor type environment.&lt;/p&gt;

&lt;p&gt;So far I've made some tilesets for the game (I'm really trying to get better at pixel art during this time), added it into the game, added player physics, colliders to the blocks, and a dark shrine with a nice animation (this will come into play later).&lt;/p&gt;

&lt;p&gt;Here are some screenshots of what I accomplished in a little under a week.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QHEJuniy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oo57xocl9p9j3wk7fc69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QHEJuniy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oo57xocl9p9j3wk7fc69.png" alt="Image description" width="880" height="643"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Aro-9utp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7f3snsg17zv3tr6epqwy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Aro-9utp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7f3snsg17zv3tr6epqwy.png" alt="Image description" width="880" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I still need to add more art, a player sprite, a background, and some post processing/lighting for the scene to look better. However, I'll hopefully be posting weekly updates on my development so follow me to stay tuned for that! I'm looking forward to sharing my progress!&lt;/p&gt;


&lt;div class="ltag__user ltag__user__id__784853"&gt;
    &lt;a href="/stcollier" class="ltag__user__link profile-image-link"&gt;
      &lt;div class="ltag__user__pic"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pijsx9CT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://res.cloudinary.com/practicaldev/image/fetch/s--jN4RSeDf--/c_fill%2Cf_auto%2Cfl_progressive%2Ch_150%2Cq_auto%2Cw_150/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/784853/5f7ffb5e-3a13-46e5-b9d7-5a1109c647bf.jpg" alt="stcollier image"&gt;
      &lt;/div&gt;
    &lt;/a&gt;
  &lt;div class="ltag__user__content"&gt;
    &lt;h2&gt;
&lt;a class="ltag__user__link" href="/stcollier"&gt;Samuel Collier&lt;/a&gt;Follow
&lt;/h2&gt;
    &lt;div class="ltag__user__summary"&gt;
      &lt;a class="ltag__user__link" href="/stcollier"&gt;Student who enjoys the liberal arts along with web &amp;amp;&amp;amp; game development&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>gamedev</category>
    </item>
    <item>
      <title>Pepper Valley: A Game Made for Kajam! 2022</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Sun, 03 Jul 2022 16:07:48 +0000</pubDate>
      <link>https://dev.to/stcollier/pepper-valley-a-game-made-for-kajam-2022-47mg</link>
      <guid>https://dev.to/stcollier/pepper-valley-a-game-made-for-kajam-2022-47mg</guid>
      <description>&lt;p&gt;This week, I participated in the second annual &lt;em&gt;Kajam!&lt;/em&gt;, a game jam hosted by &lt;a href="https://replit.com/~"&gt;Replit&lt;/a&gt;. The theme was &lt;strong&gt;"Spicy"&lt;/strong&gt;, and what nearly immediately came to mind was a farming game, like &lt;em&gt;Stardew Valley&lt;/em&gt;, where you can grow different varieties of peppers and progress through farming levels.&lt;/p&gt;

&lt;p&gt;I made the game in JS with p5.js, with the style being 2D top-down pixel art. Since, I was on vacation during the jam, I couldn't dedicate much time to the project, so I kept a decently small scope, and didn't create my own music. Otherwise, all the programming and art was done by me.&lt;/p&gt;

&lt;p&gt;Here's the link to the game: &lt;a href="https://kajam-2022-pepper-valley.stcollier.repl.co/"&gt;https://kajam-2022-pepper-valley.stcollier.repl.co/&lt;/a&gt;&lt;br&gt;
Note that it only works on a computer, it's not at all mobile friendly.&lt;/p&gt;

&lt;p&gt;I also made a quick trailer for the game: &lt;a href="https://www.youtube.com/watch?v=L20mmdMsjsA"&gt;https://www.youtube.com/watch?v=L20mmdMsjsA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hope you enjoy!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>p5js</category>
      <category>gamedev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Cleo -- A Simple Game Made in 1 Week</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Sat, 07 May 2022 01:01:48 +0000</pubDate>
      <link>https://dev.to/stcollier/cleo-a-simple-game-made-in-1-week-1l8o</link>
      <guid>https://dev.to/stcollier/cleo-a-simple-game-made-in-1-week-1l8o</guid>
      <description>&lt;p&gt;Hey everyone,&lt;/p&gt;

&lt;p&gt;A short while ago I created a game called Cleo. I really enjoyed making it, and I created it with the p5.js library in Javascript. &lt;/p&gt;

&lt;p&gt;If you didn't know, p5.js is a Javascript library that makes it a bit easier for drawing graphics to the canvas. Besides this, I pretty much had to program my own player controller, player physics (like collisions), scenes, and more! &lt;/p&gt;

&lt;p&gt;I created all the art, music, and code for the project (although I did use some code as a base for project, e.g., for the cool glow effect.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The goal is to get through all 25 buildings to the end and not get lost behind the camera.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can play the game here: &lt;a href="https://cleo.stcollier.repl.co/"&gt;https://cleo.stcollier.repl.co/&lt;/a&gt;&lt;br&gt;
If you would like to see the source code, here's the link: &lt;a href="https://replit.com/@STCollier/Cleo-GAME?v=1#main"&gt;https://replit.com/@STCollier/Cleo-GAME?v=1#main&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope you enjoy the game!&lt;/p&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>gamedev</category>
    </item>
    <item>
      <title>Easy Start with SDL2</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Mon, 11 Apr 2022 15:24:30 +0000</pubDate>
      <link>https://dev.to/stcollier/easy-start-with-sdl2-1877</link>
      <guid>https://dev.to/stcollier/easy-start-with-sdl2-1877</guid>
      <description>&lt;p&gt;Getting setup with SDL2 can be quite difficult. Getting the editor setup is easy enough, but what is the best way to create a window? How should we handle input? How do we compile it? &lt;/p&gt;

&lt;p&gt;However, in an attempt to help, I've created this Github repository to easily set up a SDL2 project with a window, user input, and compilation already done. &lt;/p&gt;

&lt;p&gt;You can find the repository &lt;a href="https://github.com/STCollier/SDL2-Starter-Template"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The code is pretty self explanatory, but I'll go over a few things. Firstly, all the main components of the window are located in a struct called &lt;code&gt;Game&lt;/code&gt;. (This struct is located in the global scope, but you can change that if you like, and pass &lt;code&gt;Game* game&lt;/code&gt; as a parameters to the functions.)&lt;/p&gt;

&lt;p&gt;With this struct, to access the window, just type &lt;code&gt;game.window&lt;/code&gt;, or to access the renderer, just type &lt;code&gt;game.renderer.&lt;/code&gt; (If struct is not global, do &lt;code&gt;game-&amp;gt;window&lt;/code&gt;, etc.) &lt;/p&gt;

&lt;p&gt;Notice that there are also two functions, &lt;code&gt;initialize()&lt;/code&gt; and &lt;code&gt;handle_input()&lt;/code&gt;. &lt;code&gt;initialize()&lt;/code&gt; just creates a window and sets up the renderer; &lt;code&gt;handle_input()&lt;/code&gt;, however, allows you to easily check user input, by typing a conditional like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="n"&gt;SDL_SCANCODE_KEY&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//Do something&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I created another article explaining this in more detail &lt;a href="https://dev.to/stcollier/easy-and-clean-sdl2-keypress-setup-with-c-5948"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Finally, to compile (with linux), make sure you have the GCC compiler installed, go to the project directory, type &lt;code&gt;cd build&lt;/code&gt; (to get into the &lt;code&gt;build&lt;/code&gt; directory), and type &lt;code&gt;sh run.sh&lt;/code&gt;. The compile commands are already set up in the SH file. The result should look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VsPCgsTz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zybwjwzcuq7u5lyyl12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VsPCgsTz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zybwjwzcuq7u5lyyl12.png" alt="Image description" width="880" height="656"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have some trouble setting this up, I have a visual example (no audio) linked &lt;a href="https://www.youtube.com/watch?v=-ONdG5Q47As"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Anyways, I hoped you enjoyed this quick overview and find the repository useful. Happy coding!!&lt;/p&gt;

</description>
      <category>sdl2</category>
      <category>c</category>
    </item>
    <item>
      <title>Easy and Clean SDL2 Keypress Setup (with C)</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Wed, 16 Feb 2022 20:16:05 +0000</pubDate>
      <link>https://dev.to/stcollier/easy-and-clean-sdl2-keypress-setup-with-c-5948</link>
      <guid>https://dev.to/stcollier/easy-and-clean-sdl2-keypress-setup-with-c-5948</guid>
      <description>&lt;p&gt;Today, I'll show you a way to easily manage keypresses with SDL2 and C. Setting up keypresses can get pretty messy sometimes, with code cluttered with a multitude of &lt;code&gt;if/else if/else&lt;/code&gt; statements or &lt;code&gt;switch&lt;/code&gt; statements, like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0u9o2sd03jfsacjuv9xs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0u9o2sd03jfsacjuv9xs.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, there's a much easier way of checking for keypresses, and this is how you do it. First, let's setup a basic C project. Create a file called &lt;code&gt;main.c&lt;/code&gt; and put these three headers at the top:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="cp"&gt;#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdio.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;stdbool.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
#include&lt;/span&gt; &lt;span class="cpf"&gt;&amp;lt;SDL2/SDL.h&amp;gt;&lt;/span&gt;&lt;span class="cp"&gt;
&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, create the classic &lt;code&gt;int main&lt;/code&gt; function, like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, let's set up a &lt;code&gt;typedef struct&lt;/code&gt; called "Game." Inside it, we'll put an array labeled &lt;code&gt;input,&lt;/code&gt; like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="k"&gt;typedef&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;256&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="n"&gt;Game&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;Game&lt;/span&gt; &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next, let's create a function called &lt;code&gt;handle_input&lt;/code&gt;. We'll prototype it at the top like so&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;handle_input&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;and declare it below &lt;code&gt;int main()&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;handle_input&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Inside of this function, we can put the SDL_Event structure, labeled &lt;code&gt;event&lt;/code&gt;, like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;handle_input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;SDL_Event&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, we can check if the key is being pressed or released, with these two conditionals, utilizing the array that we created earlier:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;handle_input&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="n"&gt;SDL_Event&lt;/span&gt; &lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;SDL_KEYDOWN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keysym&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scancode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="c1"&gt;//printf("Keydown");&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;SDL_KEYUP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;keysym&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;scancode&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
       &lt;span class="c1"&gt;//printf("Keyup");&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The code above will check if a key is down. If so, the game.input array will be assigned true, and if the key is up, then the game.input array will be assigned false. Inside the array, we've put &lt;code&gt;event.key.keysym.scancode&lt;/code&gt;, which allows us to check any SDL_key we want. &lt;/p&gt;

&lt;p&gt;So, now that the &lt;code&gt;handle_input&lt;/code&gt; function is done, we can test this out. Call &lt;code&gt;handle_input()&lt;/code&gt; in the &lt;code&gt;int main()&lt;/code&gt; function. Now, all we need to do to check if a key is pressed, say the "R" key, is do this, within the &lt;code&gt;int main()&lt;/code&gt; or any other function:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight c"&gt;&lt;code&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;SDL_SCANCODE_R&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;//Do something!&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's it! It's so much neater and cleaner, and with this approach we can check any key we want without creating an if statement or a switch statement for every single key we want to use.&lt;/p&gt;

&lt;p&gt;Please note: the code will not work by itself, you may setup an SDL2 window to test it out.&lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy coding!!&lt;/p&gt;

</description>
      <category>c</category>
      <category>sdl2</category>
      <category>keypress</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Make A Simple Voice Assistant with JavaScript</title>
      <dc:creator>Samuel Collier</dc:creator>
      <pubDate>Fri, 11 Feb 2022 16:19:06 +0000</pubDate>
      <link>https://dev.to/stcollier/make-a-simple-voice-assistant-with-javascript-3lle</link>
      <guid>https://dev.to/stcollier/make-a-simple-voice-assistant-with-javascript-3lle</guid>
      <description>&lt;p&gt;Hey everyone!&lt;/p&gt;

&lt;p&gt;Ever since I started programming, for some reason, I always thought it would be so cool to program my very own voice assistant. As it turns out, it's not that hard, and I'll show you how to very easily create one!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer&lt;/strong&gt;: the browser compatibility for this project has only been tested on Chrome, so there may be some compatibility issues on other browsers and mobile devices.&lt;/p&gt;

&lt;p&gt;Okay, so first, let's start with a basic setup of our project. Let's create 3 files, &lt;code&gt;index.html&lt;/code&gt;, &lt;code&gt;style.css&lt;/code&gt;, and &lt;code&gt;script.js&lt;/code&gt;. If you're using &lt;a href="https://replit.com/~" rel="noopener noreferrer"&gt;Replit&lt;/a&gt; for this project, which I highly recommend, these three files should already be created with the HTML/CSS/JS template.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;style.css&lt;/code&gt; and &lt;code&gt;script.js&lt;/code&gt; file should be empty for now, but put this HTML snippet in the HTML file if it's not there already:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"utf-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Voice Assistant&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"script.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let's setup the frontend elements we need for this voice assistant. Since a voice assistant is mainly backend JS, we won't need much. We'll only need 3 elements:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A button for the user to click to have the voice assistant start listening, with an id of "listen-button." When the user clicks on the button, we will call the function &lt;code&gt;listen()&lt;/code&gt;, which we have not defined yet, but I'll talk about that later.&lt;/li&gt;
&lt;li&gt;An input area to display the speech-to-text text that we are speaking, with an id of "input-area"&lt;/li&gt;
&lt;li&gt;An output area to display the result of the voice assistant, with an id of "output-area"&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We'll put all 3 of these elements inside a div, and the finished HTML file should look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"utf-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Voice Assistant&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text/css"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"main-container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"input-area"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"output-area"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;...&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"listen-button"&lt;/span&gt; &lt;span class="na"&gt;onclick=&lt;/span&gt;&lt;span class="s"&gt;"listen()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Listen&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"script.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since the items are a little jumbled together with no styling, let's just put this basic piece of the code in the CSS file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nf"&gt;#main-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should be your result so far:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3hosgw2jm2p5lq9maw48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3hosgw2jm2p5lq9maw48.png" alt="HTML finished page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I get that the page still looks trashy without proper CSS styling, but I'm not going to get into that in this tutorial, I'm sure there are plenty of CSS tutorials out there if you would like to make your voice assistant look better.&lt;/p&gt;

&lt;p&gt;Now that the HTML is out of the way, let's get into the fun stuff: actually making the voice assistant work.&lt;/p&gt;

&lt;p&gt;The first part of the voice assistant that we need is some way to get the computer to listen to us, receive microphone input, then turn that speech into text. This would normally be very complicated, but thankfully, we have an API (Application Programming Interface) that can do this very easily for us, called the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Speech_API" rel="noopener noreferrer"&gt;Web Speech API&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, to use this, let's first create a function in the &lt;code&gt;script.js&lt;/code&gt; file, that we can call &lt;code&gt;listen()&lt;/code&gt;. We'll call this function when the user clicks the &lt;code&gt;Listen&lt;/code&gt; button that we created earlier in the HTML.&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;function&lt;/span&gt; &lt;span class="nf"&gt;listen&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside of that function, we'll create an easy way to access our HTML elements:&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;function&lt;/span&gt; &lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;inputArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input-area&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;outputArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;output-area&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And setup our speech recogntion:&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;function&lt;/span&gt; &lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;inputArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input-area&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;outputArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;output-area&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;recognition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;webkitSpeechRecognition&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;recognition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;en-GB&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;recognition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, we will check for a result, and when the recognition gets a result, we'll store that data inside a variable called &lt;code&gt;transcript&lt;/code&gt; and then display that data to the &lt;code&gt;inputArea&lt;/code&gt; that we created in the HTML.&lt;/p&gt;

&lt;p&gt;Here's what that would look like:&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;function&lt;/span&gt; &lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;inputArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;input-area&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;outputArea&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;output-area&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;recognition&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;webkitSpeechRecognition&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;recognition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;lang&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;en-GB&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;recognition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;recognition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onresult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;transcript&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;inputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;transcript&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's run this program and see what happens. &lt;strong&gt;But please note&lt;/strong&gt;: the program will not run properly in an iframe or something other that's not a browser window. The API needs to access your microphone through the browser, so please &lt;u&gt;open it in a new tab.&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Okay, so here's what should happen if you did everything correctly:&lt;/p&gt;

&lt;p&gt;If you open project in a new tab and click the "Listen" button, you should get this prompt:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bs7xkadvjrlju6dunz9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1bs7xkadvjrlju6dunz9.png" alt="Microphone prompt"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click "Allow," and then try speaking! Say "Hello!"&lt;br&gt;
The program should display the result like so:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9ziwgzjfvamqu430ar3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu9ziwgzjfvamqu430ar3.png" alt="Recognition result"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Awesome! The program can show what we're saying on the screen! However, this is only half of the voice assistant. The voice assistant should take the information of what we said and then do something: reply to us, give us information, etc.&lt;/p&gt;

&lt;p&gt;This is very easy to add! Since we have the text stored in the &lt;code&gt;transcript&lt;/code&gt; variable, let's just create a simple if statement, let's say, to check if we said "hello," like this:&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;outputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, User!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, we can place that code right here, in the the &lt;code&gt;recognition.onresult&lt;/code&gt; function:&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="nx"&gt;recognition&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onresult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;transcript&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;outputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, User!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;inputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;results&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;][&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, now if we say "hello," the program should output "Hello, User!"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs69yhdm7z3cqhdf7k6q4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs69yhdm7z3cqhdf7k6q4.png" alt="Voice assistant output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is great, but what if someone said, "Hello voice assistant," or something that included the word "hello"? Our voice assistant wouldn't understand, becuase it's only programmed to respond if the user says &lt;u&gt;only&lt;/u&gt; "hello." However, JavaScript has a handy function called &lt;code&gt;includes()&lt;/code&gt; that can check if a variable includes something. Thus, instead, we can do this:&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;outputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, User!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, if the user says something that includes the word "hello," the program will output "Hello, User!" Great, right?&lt;/p&gt;

&lt;p&gt;Now, with what we've learned so far, let's create two more conditionals: one to give us the weather, and another one to alert us if the program doesn't know what we're trying to say, because currently, the program just does nothing if it doesn't know what we're saying.&lt;/p&gt;

&lt;p&gt;For the weather conditional, we'll use an &lt;code&gt;else if&lt;/code&gt; statement below the &lt;code&gt;if&lt;/code&gt; statement, to open a weather website if the user wants the weather. We can do that like so:&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="nx"&gt;outputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, User!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transcript&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;weather&lt;/span&gt;&lt;span class="dl"&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;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://www.google.com/search?q=weather&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;outputArea&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;I don't know what you mean.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This voice assistant is really coming along! However, I'm going to end the tutorial here. There's still a lot of things you can do, though. Here's a list of features you can add!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more conditionals so that the voice assistant can do more!&lt;/li&gt;
&lt;li&gt;Add better CSS styling!&lt;/li&gt;
&lt;li&gt;Add randomized responses, by storing an array of responses, and getting a random element from them (&lt;a href="https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/4550505/getting-a-random-value-from-a-javascript-array&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Turn this into a real voice assistant by having the program respond with a synthesis voice with another API, like this one: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading this tutorial, and I hope you learned something! Happy Coding!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>beginners</category>
      <category>api</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
