At my day job, I have the pleasure of working with a great bunch of guys, and one of the best things about working with a team of people is that you get to see how they approach problem solving.  I think some of the best breakthroughs and most elegant solutions I’ve found have been when I’m sitting with another programmer and we’re working together.

How do you go about programming with a partner though if you’re in different rooms, or different buildings?  Screen sharing works, but it’s kind of clunky, and I don’t really need their entire screen, I just need to see the code.  That’s where I package I found online for Atom comes in to play.  It’s called atom-pair.

Atom-pair lets me use my favorite text editor with a partner even when we’re not in the same room.  It’s still in its infancy, but I think it has great promise.  I even submitted a pull request to add Slack integration to it.  Definitely check it out, it’s a great package.

I’m currently working on a top down tile based game, and when I came to generating the map on the screen from a one dimension array, I thought of a few ways to do it.  The first way was a very simple one I saw online.  It involves looping through columns, and then looping through rows within columns to get coordinates.  No math beyond simple addition is required to make this work.

That’s pretty easy, right?  I started to think there might be a better way to accomplish it without using two loops.  I came up with a fairly simple algorithm to take care of it (I’m sure I’m not the first person to come up with it, but I did come up with it on my own).  The second example requires a little bit more math, but still nothing too complex.

I was pretty happy with that last example, it’s still very simple, and in my mind, one loop is better than two, right?  I started thinking though, how much overhead is introduced by using math functions?  Is it enough to offset the cost of an additional loop?

I put together a simple test at jsPerf to find out.  The results blew me away.

map generation results

 

Wow.  I didn’t expect that big of a difference, but there it is.  I hope this helps people who want to do tiled map generation.  Also, if you have a faster way, please comment and let me know what it is!

 

So I use the wonderful Atom to do all of my coding.  It’s free, and open source, so if you haven’t looked into it, you definitely should.

Anyway, one of the issues I’m constantly running into is that I want to open an entire folder with Atom, and have the folder show up in Atom’s project explorer.  Typically, I open up terminal, cd to the appropriate directory, and type  atom . to open up my entire project.  I messed around with Services a little bit and wrote a service that lets me right click on a folder to open the entire folder in Atom.  If you want to skip the tutorial and just download the service, check it out on Github:

Mac Developer Services

    1. Open up “Automator” on your Mac, create a new document, and choose “Service” for the type.
    2. In the top part of the right pane, choose “files or folders” next to “Service receives selected” and “Finder.app” to the right of that.automator-service-1
    3. In the “Actions” panel on the left side, type “open” to search for all actions that start with “open”.  The action you want is called “Open Finder Items”.
      automator-service-2
    4. Drag the “Open Finder Items” action to the right side and drop it in the blank workflow section.automator-service-3
    5. Under “Open with” choose “Atom.app” (or Sublime.app or whatever text editor you use).automator-service-4
    6. Save your service and run it to install.
    7. Right click on a folder to open it in Atom.

automator-service-5

 

That’s all it takes to build an Automator service to launch an application from finder.  Let me know if you have any feedback, or suggestions.

As I started to implement the roguelike sprites I talked about earlier into a map editor, I realized CSS sprites might be a good idea.  I was previously using a split up set of PNGs that I exported from unity, and for a variety of reasons that stopped being a viable solution.

I tweaked the JSON data generation script slightly to have it make a CSS file too.  Enjoy!

CSS File