blog.nek0.eu/site/posts/2020-12-14-Tiles-and-maps.md
2020-12-23 17:52:16 +01:00

1.8 KiB

title author tags description
Tiles and maps nek0
devlog: pituicat
english
Putting previous stuff to use and walking steadily forward

Hi there!

Another weekend passed and another step has been taken. Last time I was struggling my way through OpenGL and got a single quad displayed on screen, which I had hardcoded there. The next step I decided to take was reading level maps and generate quads where tiles would be and texture them properly.

I had already put some thought into how to store level information.

May train of thought here is, that tiles are static and arranged in layers above each other. To represent that I use a simple bitmap picture per layer. every single pixel in this bitmap represents a tile. The red channel contains the information of the tile type (at the moment there are only solid tiles, platform tiles and decoration tiles). The green and blue channel mark the offset on the tilemap. To make the information visible to the naked eye, the information is stored inverted, so that filled areas appear white and empty areas black.

I will have to figure out dynamic objects like collectibles or enemies later.

So after defining types for the tiles, the tilemap and the level map I also defined a rather generic typeclass for anything drawable to spew out vertices with texture coordinate information. Putting my game on the screen now looks like this:

Screenshot

Making progress is fun and I enjoy making it in my own bespoken way, though havig to think in different coordinate systems at the same time (OpenGL coordinates vs. Image coordinates mostly) can cause quite a headache and some rather fun bugs.

As always, feel free to check out the code on my gitea.

See you next time!