Yearly Archives: 2015


Music, Intention, Focus, and Video Games

Generally, people enjoy music. More specifically, people tend to love some kinds of music while disliking or downright hating others. But because music is so prevalent in society, a significant number of studies have been done on it. People have tested whether music helps you focus, whether or not the music you like determines your personality, what types of music are beneficial for studying, etc. Often I pass over these studies, but I like to look at the ones that look into music and academia. Many of these contradict — some say that music can focus your thoughts, others say that it’s too distracting to effectively focus no matter what, and others decide that it’s entirely independent on the individual. However, most studies seem to agree that video game music can help people focus for sure.

Intent

My opinion on many studies that attempt to show a correlation between music and focus is frequently low. This is because many studies use entire genres for a single data point, when the genres themselves are far too variable to get any valuable data without splitting them up into subgenres. Now, I’m not going to go into a subgenre rant, but merely mention that music is created with different intentions. Many classical pieces were created for active listening, i.e. the music would be the main thing the person focused on. However, incidental music was written to be played in the background — such as at a party or dance. Both of these types would fall under classical, but the pieces created for active listening would most certainly distract a person more than the incidental music would, despite belonging to the same genre. Likewise, instrumental pop/metal/classical/etc. songs are generically less likely to be distracting than songs that include vocals, as vocal songs almost always are created for active listening. Because studies do not separate out their music by their intent, the results are conflicting.

What we can pull out of all these studies, however, is that music does help focus if it’s not TOO distracting. While studying or working on a single time-consuming task such as cleaning or filling out paperwork, there’s a part of your brain that always wants to be doing something else — to eat, to look at Facebook, to bounce your leg, and so on. Over time, it gets harder and harder to ignore that urge and easier and easier to get distracted. However, music can keep that part of your brain consistently busy so that the rest of you can think about your work. But if the music is made to be listened to actively, it can steal too much of your attention and be detrimental to work.

This is where video game music comes in. Recently, I’ve seen people link to articles about how video game music can help you focus. I wholeheartedly believe this, and my words on intent will help to explain why.

Music on Loop

This much is obvious – people buy video games to play them, and to be immersed in them. As such, when music is written for video games, it’s not meant to be the main focus. Video game creators know, however, that music can keep people more invested in a game than they would otherwise — because they know a little bit of music helps keep your entire brain focused on the game, leading to a more immersive experience. Many quality games have music that is just the right amount of distracting for maximum immersion. There is an added challenge with game music in that the themes are likely to be heard over and over. Nintendo’s main composer Koji Kondo listens to his music for hours on end to be sure that players will not get tired of hearing it, while still fitting the theme of the game. At this, he succeeds — anyone who has played a Nintendo game is likely to remember a few of the melodies with fondness. Certainly I didn’t tire of hearing this theme for all the hours I put into a Link to the Past and a Link Between Worlds.

Recently, I played an indie game called Undertale, which has rapidly gained popularity and sold over 400,000 copies since its release on September 15th. What made this game especially great for me was its music. As a musician myself, I tend to pay special attention to the music in games, and the sheer cleverness of how the creator uses music in this game is brilliant. There’s the typical background music that varies from scenario to scenario, but when it comes time for a boss battle, that’s where the music really shines. What immediately struck me was how well the music introduced the personalities of the opponents. The music and dialogue together really helped develop complex characters. Additionally, and this is the real kicker, the music and the timing/style of the battles match really well. Here’s part of a fight with one of the first bosses (if you don’t mind spoilers):

As you can see, the challenge in this fight involves timing jumps, which goes really well with the bouncy music, and also the character’s lighthearted personality. This combination makes it really easy to get invested in the game.

Back to Focus

Just as good video game music helps the player get absorbed in the game, so too can video game music help with focusing on other tasks. Since it was designed with the intent of being in the background, it perfectly keeps people on track while studying, cleaning, or writing a really long blog post. Ordinarily, video game music is not bought and listened to on its own, as they tend to be short or atmospheric tracks that are looped continuously (exceptions being games that produce full tracks like Bastion, which has amazing music that plays a larger role than usual in the story).

In short, specific types (not necessarily entire genres!) of music can help with focus. Music written with the intent of being in the background especially works, with video game music as the primary example here.

An excellent post that goes into more depth as to what types of music helps focus is here.

For those interested in listening, here’s a link to game music radio.


CraftyJS in JavaScript

As a computer science student with an active interest in web development, it’s about time I learned how to program with JavaScript. JavaScript is one of the major languages used for websites, alongside HTML and CSS. It is supported by every modern site, and is used by almost all of them.

I already had plenty of experience with HTML and CSS, but almost none with JavaScript. There are a couple reasons for this, one being that the websites I worked on had little to no JavaScript at all, let alone any that needed to be changed. The other reason is that the need to learn it simply never came up. I enjoy learning things in my free time, but I had heard many a horror story about using JS, and as such was in no rush to learn it.

But then, as it happens, the opportunity to learn it came up. For my current Computer Science course, our over-the-block projects were to design a web application. “Hey,” I thought to myself. “This is the opportunity to learn and build something with JavaScript, and you really should learn it sooner rather than later.” Since I had no idea whatsoever what to build for the web, I figured I might as well default to making a game. I had already made some pixel images for a spaceship game my friend was working on, so why not make a similar Galaga-type game?

I decided to look for a framework or library that would make the whole process easier, and JS has a LOT of those. I ended up going with a beta framework that was specifically designed to help make games with JS.

CraftyJS

CraftyJS is in active development, and all of the code for it can be found on their Github. They actually released a new beta version about 2 weeks ago. I chose it because it looked intuitive and easy to use, even for someone with no prior JS experience. Turns out I was right – it is fairly intuitive. There are, however, some drawbacks and challenges that I faced during the creation of this project.

Problems with JavaScript

JavaScript is an interpreted language, meaning it has no compiler, but also meaning that it will always run, no matter how horribly broken the code is. To quote W3Schools, “Normally, errors will happen, every time you try to write some new JavaScript code.” This makes debugging more difficult, as one tiny change can make nothing show up on your webpage, and without the kind of error throwing and debugging tools that exist for compiled languages, it can be difficult to find the problem. Less obvious errors might go completely unnoticed by developers for long periods of time.

Because JS is such a popular language, though, not all is lost. Tools like JSLint and JSHint can help in resolving errors and adhering to conventional formatting (though JSLint is a little too strict about some conventions, in my personal opinion), and IDEs like WebStorm will catch syntactic errors and provides support for other libraries and frameworks. It is still a step more difficult to debug than compiled languages, though. It is no surprise why there are so many frameworks and libraries that exist to solve many of its annoying quirks.

The Good of CraftyJS

By far the best things about Crafty besides its general ease of use is its documentation. It is well-written, and best of all, it provides examples of how to use it. There are multiple demos on the website whose code is also on GitHub, which was useful for some problem-solving when the documentation was insufficient. Overall, I’ve found Crafty’s simplicity to be a great and pretty fun thing to use, which is not what I expected at all.

Problems with Crafty

Even though its demo code is on GitHub and it has great documentation, Crafty otherwise has a pretty small community. This means it’s harder to find help for specific issues. Additionally, a recent issue has come up where directional keys don’t work in the newest version of Firefox, so I will have to come up with a workaround. However, I have been able to work through every other issue or challenge I’ve faced thanks mostly to Crafty’s great documentation, which will point out potential issues and how to solve them (ex. “the shared object trap“).

I will post a link to the working version of the game and my final thoughts once it’s completed, though you can see the in-progress code on my GitHub.