Ket's Site

Welcome to my little corner of the internet. It is essentially just a microblog.

If you wish to follow my ramblings you can sub via RSS, Twitter or Mastodon.

All posts in order of Date and Time (or Show Table of Contents):

Software Development > Implementing Tiled Map Editor(TMX) Rotation and Flipping

26/11/2019 15:35

Tiled Map Editor, available at is a great FOSS map creation tool for tile based games. The Tiled TMX format is very useful and the maps made in it can be easily brought into any project, either by parsing the TMX/XML files generated by Tiled or by copying the generated layers into your project as (when using C or C++ (For other languages you will have to use the equivalent)) a uint32_t array.

As described in the Tiled documentation the bits at the end of each 32 bit integer that makes up the map are used to store the 'flipping' of each tile. A tile can be flipped in three ways, those being; horizontally, vertically and diagonally. But how do get rotation and flipping in every possible direction from these three bits?

We will be using this table as a reference to how each rotation and flip can be achieved in the below example project.

Example Project

This example project is written in C++ using SDL2 video library.
It simply initialises SDL, loads a tile sheet image and renders our Tiled map until the program is closed.

First we need to create a map. I have created a simple, single layered map that includes a few images in every possible flip combination.

We will then be copying the relevant information from out of the TMX Tiled map into the project rather than parsing it.

The next thing to do before we render our map is to bring the 'flip table' from above into our project.

Once this is done we can then render the tile as we would any other image in our program. In the case of SDL this is done in the line:
SDL_RenderCopyEx(renderer, sheet, &srcRect, &destRect, rotate, &centre, flip);

After compiling the program we can see that the tiles in our SDL window are in the same positions, flips and rotations as in the Tiled map editor.

For a more in depth look at how we are implementing this table you can find the full example program on GitHub.

This entire article and the images included in it are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
The example project included alongside this project are licensed under a MIT License.

Video Games > A list of games I have completed

20/11/2019 00:00

Looking at my Steam library I started to forget what I had finished, so below is a list of games where I have completed the main story or task to look back on. I will be updating this same list as I play or remember more, rather than making a new list.

Games I have completed:
Among the Sleep
Aperture Tag: The Paint Gun Testing Initiative
Battlefield: Bad Company 2
Duke Nukem Forever
The Elder Scrolls: Skyrim
Fallout 4
Fallout: New Vegas
From Dust
Gone Home
Grand Theft Auto IV
Half-Life 2
Half-Life 2: Episode One
Half-Life 2: Episode Two
Hard West
Hotline Miami
Hotline Miami 2: Wrong Number
Just Cause 2
Left 4 Dead
Left 4 Dead 2
Little Inferno
Lumino City
Never Alone (Kisima Ingitchuna)
No Time To Explain
Octodad: Dadliest Catch
Portal 2
Postal 2
Retro City Rampage DX
Saints Row 2
Shovel Knight: Treasure Trove
South Park: The Stick of Truth
S.T.A.L.K.E.R.:Shadow of Chernobyl
Stardew Valley
Super Win the Game
Wolfenstein: The Old Blood
Wolfenstein: The New Order
World of Goo

Meta > Filesystem Blog: Hello Web

19/11/2019 22:00

A few weeks back the laptop that I had set up for programming died. I still had my ‘gaming’ laptop, however that has none of the tools I use for development on it, no ssh keys and so on. Deciding it would be more effort than its worth to set up my environment only to have my new (second hand) laptop arrive in the post once everything is configured to my liking, I chose to wait.
Well, computer games get boring quickly and I wanted to do something else, so I opened up notepad and I designed this little website, attempting to make something that looks like a pad of paper. I was rather pleased with how the simple look turned out so decided to publish it here. [img][/img]

Once my new laptop arrived I initially made a small site using PHP and SQL, however I have done this exercise many times before and it was a little boring. To make a change I decided to build a site that uses standard files and directories to store posts, comments and other information, rather than the normal database. At this point it may have just been wise to create a static site without the need for any PHP at all, but I wanted it to be a little more interactive with comments and maybe some other things in the future, so here we are; besides where is the fun in using something that just works when you can have the fun of putting it together? In the process of creating this site I learnt a couple of things as well, and also had to ask myself a few questions, such as:

Is this secure?
Whereas with an SQL database where I am used to using a product that has already had a lot of thought put into security, plus a community of people constantly reviewing, and fixing security holes. For instance fixing bugs giving users the ability of accessing data they shouldn’t have access to. I am a little concerned that my PHP script that just searches though a folder full of posts may give a hacker a means to request files outside of the ‘posts’ directory, maybe by requesting the URL, for example. To help alleviate this concern I strip all ‘.’ characters from URLs when I am processing them. I am also only reading files with the extensions ‘.post’ and ‘.comment’ so that even if somebody did find a way to escape my posts directory they would not be able to just read any file they please (in theory).

Is it fast enough?
With databases there has at least been some time and thought put into the optimal way to sort things so that they can be accessed nice and quickly. This site is very primitive, and scans every file in every subdirectory of the posts directory when a page is loaded to find the small handful that we need to display. This is, of course a pretty slow way of doing things, and it will only get worse as the site grows. At some point I will add some basic caches to speed things up a bit, but for now I am not really bothered about the speed of this silly personal site.

I have also learnt a frustrating lesson on filesystems. Before I made this site I was unaware that there is no simple uniform way of accessing file creation or ‘birth’ times on a standard Debian setup and an EXT4 filesystem. It would have been ideal for the script to take post creation and modified times straight from automatic data on the text files themselves, but this isn’t a huge issue or something to get hung up on, I have simply resorted to storing these dates in the file names instead.

The outcome of this little project can be found on GitHub, and anybody is free to modify, use and share it under the GPLv3 licence.

Video Games > Star Wars: The Force Unleashed > Final Thoughts

07/11/2019 00:00

That was pretty awful. The game is basically a small set of tedious levels leading to boss fights, the problem being that you don't get any reward for actually playing though the levels, and running past everything trying to kill you seems to be a much better option; there is nothing at all stopping you from doing so. Also, in most cases, enemies (as far as I can tell) spawn endlessly, making sticking around to kill them all the more pointless. Due to this what you are left with is a series of boring boss fights where you spend your whole time blocking and dodging hits while your energy bar recharges.

The story is also a little strange. Don't get me wrong, it was fun to play the bad guy in such a black and white franchise, but you kind of turn good which is a shame. Also, strangely, if this were to be the accepted story between Star Wars Ep. 3 and 4 it would mean that Darth Vader is essentially responsible for founding the rebellion as a means to take down the emperor - maybe that is still the case, I am not sure, I haven't watched the new movies.

The game certainly isn't worth revisiting again, and I don't think I will bother play the second game in the series, or any other hack and slash in a hurry.

Video Games > Star Wars: The Force Unleashed > Invisible Walls

05/11/2019 00:00

This game is riddled with invisible walls. There was a time when it was very common in a lot of games, but I feel like I haven't played a game with any in some time now. Maybe I am just playing the wrong games to run into them (har har) or maybe level design has just gotten much better in the last 11 years.

Privacy Policy (For subdomain

This site does not use cookies.
We do not share any information from your time on this site with any 3rd parties.
If you comment on this site we store your name and email address (if provided). If you wish for your comment(s) to be removed please email ket AT from the email address you provided and we will be happy to comply.


Copyright (c) 2019 - 2021 Alexander Theulings
The copying and redistribution of this page and any images or additional content on it is not allowed unless explicitly stated by or on the resource or unless written consent is given.
A picture of Freki.