Isometric Tile Transforms

It might require a bit of initial thinking, but I'm sure it would be worth it.

I’m debating with myself whether to make my game engine pseudo-3D, using transforms and masks and whatnot to generate and texture isometric tiles.

On one hand there’s something to be said for tile-based systems to have every graphic meticulously crafted by a master designer, but on the other hand, I’m not that designer. It’d be so much easier to slap a grass texture down and transform it to match a programmatic grid. Maybe adjust the brightness to simulate lighting, then cache that sucker to achieve decent performance and move on to the next tile.

I think it’s feasible. It would allow for much easier creation of game elements such as hills and height, walls, roads, and so many more cool things. It’s also a total departure from my original idea of a traditional isometric game engine, but once it’s implemented it would make things way easier for both myself and anyone who wanted to create a map in the future because one high resolution texture could be used for countless tile combinations.

I think I’m going to give it a try, because if nothing else it’s a damn cool idea.

SVG and Canvas Transformation Matricies

Both SVG and HTML5 Canvas have basic transformations such as rotation and scaling, but they also have a more advanced “transformation matrix” mode which lets you do more complex transformations. I’m not pretending to understand it properly.

A transformation matrix has six parameters, named A—F. A lot of the documentation I found on them wasn’t particularly useful, so here’s my take on how each value works:

NameDescriptionDefault ValueExplanation
awidth11 equals 100%. A value of -1 would mirror image the object on the left hand side. .5 would halve the width, and 2 would double it, etc.
bY axis shear0A positive value shears the object downward on the righthand edge.
cX axis shear0A positive value shears the object rightward on the bottom edge.
dheight1Similar in operation to a, above.
ex offset0Offset the object on the x axis.
fy offset0Offset the object on the y axis.

So for instance, if you wanted to create an isometric tile from an image, you could use the following transform:

matrix(1,-.5,1,.5,0,0)

This would keep the same width, shear both axis by 50% effectively rotating the image 45°, and halve the height giving us our iconic half-height isometric tile.

Some other transformations relevant to isometric game tiles might might include:

OperationOutput
matrix(1,0,0,1,0,0)No change.
matrix(1,-.5,1,.5,0,0)Square sheared into half-height isometric tile.
matrix(1,-1,1,.5,0,0)Sheared into a leftwards isometric incline.
matrix(1,1,-1,.5,0,0)Sheared into a rightwards isometric incline.
matrix(1,0,1,.5,0,0)Sheared into a leftwards isometric decline.
matrix(1,0,-1,.5,0,0)Sheared into a rightwards isometric decline.

You’ll notice that the output tiles are significantly larger than would be generated with a straight out rotate and scale. You may need to add an additional scale operation to adjust the size of these tiles to fit your game board.

Putting it Together

Once you put these tiles together, you start to get an idea of how we can use canvas (or SVG) matricies to create isometric tiles for your game.

Using transforms to create game images makes tiles click into place like lego.

If you wanted to play around with transforms with a visual tool, you could check out Inkscape, the best vector editor in the world. The matrix transformation sidebar is found by clicking the menus Object , Transform, then clicking the “Matrix” tab.

Ridley X-Bow

My Avanti Blade 8 C has been at Lifecycle for the past two weeks and I haven’t heard a peep from them. I’ve had enough of the thing breaking down, and I don’t trust it not to fall apart underneath me.

Trust is an important thing to have in a bike. The amount of times the internal hub has skipped a gear as I’ve been climbing a hill, seized up or started making noises halfway home, and the number of times I’ve been left weeks waiting for Lifecycle to get back to me has left me angry and stressed out. Not being able to trust my bike to get me places is not only stressful, but makes me not want to ride at all.

For the last two months I’ve been riding my fallback bike which is a bit small for me and doesn’t have a pannier rack, meaning I have to wear a backpack which gets a bit sweaty. It’s a good bike, very reliable, and pleasant to ride short distances, but it’s not especially good for commuting.

So after stumbling upon a new bike store in Aspley, and stumbling inside only to stumble upon the perfect bike, I took twenty-four hours to arrange my funds and buy the sucker.

Black & white bike beside a bike path, complete with pannier and helmet.

It’s a Ridley X-Bow (Crossbow), which is billed as an ideal commuting bike. I took the opportunity to upgrade it with mud guards and a pannier rack, and fitted it with a set of SPD pedals that I had traded Thom for assorted cheeses days earlier.

A black & white bike on the back of a blue Hyundai Getz, in front of the red facade of the Aspley Bike Hub (no longer there)
The Aspley Bike Hub was a great bike shop, but is no longer there.

It’s a very nice bike.

It’s going to take a bit of getting used to because I’ve only ever ridden anything with flat handlebars, and these have three spots where hands can go. The gear changing mechanism is a bit strange to me as well, but I’m sure it’ll be fine once I’m used to it. Furthermore I’ve not ridden a bike with SPD pedals despite owning the shoes for a year now, so that will take some getting used to too.

I took it for a quick spin before it got dark this afternoon so I could work out how to use the pedals in particular, but I want to take it out for a longer ride before I have to go back to work on Monday, just to get the hang of it.

Playing with SVG

Spent the day plying with SVG. I've always used Inkscape for as long as I can remember, but it's taken me this long to actually dive in and start using the underlying markup for anything more than designing stuff.

I wrote a library to take an input string in a particular format and output a fully blown diagram to scale, based on the measurements and configurations from the input. The idea is that not just myself but also the lay person can rapidly prototype a bunch of diagrams (perhaps dynamically) for the new web site, and later reuse the library for internal projects.

I'm really rather impressed with myself. Aside producing a really cool tool, I've learned a fair bit about SVG itself and how it works. It's a pretty neat language, and features a lot of traits from XML, and CSS. I can see why it was poised (and I suppose still is, although it really fizzled thanks to Internet Explorer) as a web language. I really quite enjoy XML as a markup language, so it's quite fun to use it for drawing lines, filling rectangles with predefined gradients and translating things across the page.

I'm pretty proud of my work today, and I'm quite pleased to add another entry to my wide repertoire of half known things.