Five Nights at Freddi Fish

oh Luther...

A Whole Game Made Just to Prove a Point

In the final days of 2015, I made a video about the superbly popular computer game Five Nights at Freddy’s. In this video, we discussed a very critical issue with the game’s logic; that the 6AM event would transition the player to a success state regardless of their current status or the statuses of any other in-game entities. This issue was made more serious due to the fact that it has persisted throughout all relevant games in the series.

To explain this issue and various possible trivial fixes to it, a full Finite State Machine of the game’s systems was produced in a process which I later learned was called Model Based Testing. First the expected high-level behavior of the system was modeled. Once it was discovered that the implementation did not match the logical model, a new model was built from observation of behavior.

FNAF Extended Finite State Machine
Click for full image of EFSM

Initially my plan was to modify the game myself in order to demonstrate how trivial a fix would be. Unfortunately, after disassembly, it was discovered that the project used a premium font package which disabled me from opening it with the free version of Clickteam Fusion (the game’s engine).

So instead of purchasing the cheap game engine as I should have, I began developing a web-based version of the game. As I didn’t want to waste time creating assets, I used art from Freddi Fish 3. Believe it or not I didn’t actually realize the coincidence with the names for a while. The working title was initially Five Nights at JQuery. Anyways, development slowed down once I got to the camera screen feature due to how many permutations of images needed to be made for each room (something that the actual FNAF fails to do properly in one of the rooms where it matters), so I gave up until ConUHacks 2017. I finished the first release over the weekend and now here we are! Enjoy the game in all of it’s 6AM-bug-free glory!

Either play it embedded here or play it full-screen on my GitHub page (recommended).

Please play in Google Chrome for sound effects to work properly

Features for Next Release

  • 6AM success animation
  • Monster kill failure animations

Technical Stuff

The game is made in pure JavaScript with JQuery used just to grab things by their ids quicker. All on-screen element’s have their visibility toggled, that’s basically how it all works. Note though that there are a lot of images and audio clips, so I recommend that you play around and click all of the buttons before starting a game just to get everything into your browser’s memory, otherwise the performance might be a little weird.

Now here’s the part that will make you cry. Originally I was planning on doing two things with this project as exercises for myself. First, I wanted to build the whole system completely procedurally, as in no OOP. Then I wanted to take on a big refactoring and compare dev time of the two projects. I was taking my first software architecture course when this started and I thought it’d be a lot of fun. I was an idiot lol. When I came back to it during the hackathon I shed a few tears. Right now the only class I have is Room, but it’s crap because it interacts with Monsters frequently which themselves aren’t actual concrete objects but rather collections of public variables and functions. It’s bad. I also have a pseudo observer pattern going on for the camera views, but that’s it.

So the plan is to refactor this and make a real OOP system. Once that’s done, I’ll be able to get rid of a lot of the hardcoded crap which will make it easier to expand the system. The ultimate goal will be to use a graph as the map rather than hardcoded room numbers, that way the monsters will be able to move freely throughout the graph and take different paths, something that, again, the actual Five Nights at Freddy’s game doesn’t do. It will also allow for the addition of new monsters.