Game Development

I started a CodePen collection called GameDev to explore some GameDev concepts. The first one, I explored was a basic loop:

The code for a loop is super simple. Here’s what it basically boils down to:

function start() {
  // setup and persistent state goes here
  window.requestAnimationFrame(update); // queue update
  function update() {
    // update logic
    window.requestAnimationFrame(update); // requeue update to create a loop

My first example counted frames and also updated the UNIX timestamp in DOM so I can see that things are actually updating. The frame count is not entirely accurate as it actually counts the frames in the given second, not frames elapsed in a second. The difference is that the first second is inaccurate and the frame total updates only once per second unlike FPS counters in video games that update once per frame.

The second venture into GameDev was capturing input. The screenshot looks identical to the above one except that it tells you what keys have been pressed. A few interesting takeaways:

  1. using JS’s String.fromCharCode works only on alphanumeric characters. Any other keys get a blank square as a result. It’s definitely not a reliable way to figure out what key was pressed
  2. keydown and keyup event listeners basically add and remove from an array of keys that are currently pressed. In my last dev update, I mentioned how I just had a “pressedKey” variable that captured the input of a single key press rather than keeping an array of currently pressed keys
  3. you can setup several update loops on window.requestAnimationFrame and they get fired sequentially. This is a pretty cool feature

So, why am I doing these small demoes? Before throwing myself into Phaser and other game dev HTML5 frameworks (and failing as I have before), I feel like I need to get a really firm grasp what those frameworks might be doing beneath the surface. And possibly build a game without them.

I’m currently working on an example that updates a graphic on screen when a key is pressed. A red square gradually becomes blue when a key is pressed and then returns back when the key is not pressed. So here is what I plan to explore by my next update:

  1. moving a square around with keys, and affected the square’s “mode” with another key
  2. possibly tiling

App Development

As you may know, I’m currently working on an app called OMEN. OMEN is supposed to be a powerful markdown editor geared at indie writers. I’ve since slightly “pivoted” from that experience and want to offer a more IDE-like experience for the users.

One huge update I have about OMEN is that not only did I do a bunch of refactors, I got subtree listings working!

Because of some other logic I have written a while ago, I can open subtree files without having to modify anything. This is really exciting!

There hasn’t been much work beyond that because this took a while. It’s still buggy but hey, you can open the files and you can save them and that’s good enough for me right now.

I’ve also started working on a UI overhaul:

I’m still trying things out but I like this bigger layout. I’m going for a more modern look at Scrivener. The design is missing icons (like folders, files, etc.) but otherwise, it’s a rough sketch of how the redesign will look.

I have a few goals to accomplish by the next update:

  1. figure out how to implement keybindings in Angular. This one is BIG
  2. explore new ways of scaling/approaching CSS


My writing updates are covered in a different blog post but to summarize:

I’m doing really well rewriting my NaNoWriMo 2014 (was it…2014? I’m not a 100% sure).


Other Ventures!

I had the opportunity to look into Newsletters recently and realized that I actually have two lists on Mailchimp that I aggregated from this site! A total of 36 people. Wow, right?

Anyways, I’m hoping to start the newsletter back up and deliver the updates I promised, namely on the progress of a programming book I’m writing called WebDevelopment.META draft is available free on Github.

I also started a new newsletter for writing so if you’re an indie writer, go check it out and sign up! 😃 The development of it is still in VERY early stages.