Reducing friction

In my post on changes I wrote:

I want to simplify my online life/presence. I was maintaining (neglecting) two separate blogs while mainly posting to Twitter instead.

7 years ago I started a coding blog using free WordPress hosting. This wasn’t ideal, but was good enough at the time, and the price was right. A year later I started a personal blog that also used free WordPress hosting. (The reason for the separate blog was not wanting to dilute my coding blog with personal content.)

Over time I became increasingly frustrated with WordPress dot com’s ads and my lack of control over what are supposed to be my websites. Having two blogs to manage was just extra hassle. Fast forward 6 years and both my blogs had been neglected for years, and when I did post online it was to Twitter. Posting to my own blog should be as frictionless as tweeting. I had been following the development of Manton Reece’s micro-blogging service, micro.blog for some time, but had not yet signed up. In February with the extra free time of not having an employer and inspired by this great post by Brent Simmons, I decided to finally tackle my blog problem. I wanted to accomplish three things:

  1. Move my blogs from wordpress dot com
  2. Combine my two blogs into a single site
  3. Integrate micro-blogging (status) posts into my blog

I decided that I would stick with WordPress as a platform, just not WordPress dot com as a hosting company. I signed up for 5 years of hosting with BlueWin because the price was right and their WordPress support was good enough for me. I had some trouble with WordPress’ import/export tools and ended up having to do a lot of manual migration, but otherwise it was pretty straightforward to port over all posts from my two blogs and combine them into a single site. As a bonus I made SSL mandatory for the site. I even added support for JSON Feed.

At the same time I signed up for an account with micro.blog. While they offer an option to host your micro blog posts, I wanted to host everything here on my own site (which micro.blog fully supports in both their website and apps). I created a micro category to be used with all status posts, so that I could hide them from the main page of my blog. I did opt for a $2/month cross-posting bot that would intelligently post my blog entries to Twitter. (This post by Chris Reed on Configuring WordPress for Micro.blog was very helpful in getting everything set up.)

What I’m doing is not exactly POSSE because status posts under 280 characters are cross-posted to Twitter as plain tweets and don’t link back here, but that’s fine by me. I don’t care if Twitter has copies of my photos and words as long as I have the originals hosted here on my blog.

I downsized from two blogs to one, and now instead of tweeting, I publish status posts to my blog (which get cross-posted to Twitter). I mostly use micro.blog’s iOS app for status posts, but any WordPress-compatible client would work.

Pixel Art Map Tiles in SpriteKit

I decided to use SKTileMapNode to render the mountain that must be climbed. There will be tiles for stone, sky, ice, snow, flowers, etc.

Map Tiles
Tile Map

As I mentioned in my previous post, Mountain Dash renders 1x pixel art at 2x (which means 4 × 4 or 9 × 9 pixels on screen for each pixel in the original assets). I chose to do tiles at 16 × 16 pixels, so I need each tile to render at 32 × 32 points. It is entirely possible to do this using the Tile Set Editor and Tile Map Editor in Xcode, but I ran into two problems:

  1. Every time you assign an image in the Tile Set Editor, it defaults to the image’s actual size (16 × 16) and must be manually changed to the desired size (32 × 32)
  2. Occasionally Xcode for whatever reason decides to blur the tiles when scaling them up. The only solution with the Tile Set Editor is to remove and then re-add all the images (and manually retype all the sizes yet again).
Blurry Tiles
Blurry Tiles

I already knew that I could fix the blur in code by setting filteringMode = .nearest for each texture, but while the Tile Set Editor lets you define textures, it doesn’t let you set filteringMode.

All of the above was way too much hassle and as it turns out unnecessary. Instead of scaling up my maps and my sprite by 2x, I could use all my assets at their native sizes and just use an SKCameraNode and set cameraNode.scale = 0.5 to scale in 2x. I need to use SKCameraNode anyway to scroll my map (you just change the position of the camera), so this was perfect. Also it’s helpful for debugging to use the camera’s scale to either zoom in (see pixel art details) or zoom out (see more of the map on screen at once). (The above screenshot was taken at 4x or scale = 0.25.) I may even add a pinch-to-zoom gesture to allow the player to do the same. The scale on SKCameraNode was unintuitive at first because it is the inverse of what I expected; I’m used to writing scale = 2 to double a view’s size.

Even with everything at 1x, I’ve still had the Tile Set Editor barf on me once and give me blurry tiles, so I’ve decided to permanently fix this by looping through all the textures in the tile set and setting the filteringMode. I wonder if there’s a better way of handling this…

let tileSet = map.tileSet
for tileGroup in tileSet.tileGroups {
    for tileRule in tileGroup.rules {
        for tileDefinition in tileRule.tileDefinitions {
            for texture in tileDefinition.textures {
                texture.filteringMode = .nearest
            }
        }
    }
}