Tile-Set Implementation

Pic2_19_2015This weeks blog post will be about the implementation of the tile-set. The main part of the tile-system is how it reads from a file.

The main function of the file reading system is called explode. Explode works in such a way that it creates a  vector for parts. The functions parameter defines what the delimiter will be and what sort of text it contains.

The function works in such a way that if I have a row of text in a text file like this: “Greetings reader welcome to my blog”. If I set the delimiter to be ” ” also known as a space, it will set the space as the separator.

So since explode separated a line of code into parts and pushed them back into a vector. The text  “Greetings reader welcome to my blog” will have different values in the parts vector. so the first index of part will be Greetings, the second index will be reader and the third index will be welcome and so forth.

With this vector I check certain words in certain lines for more accuracy of certain types of data. For example i can check index[0] of a certain line to determine what kind of information is held in the rest of the line to determine what the syntax should do with it.

So in my code i check if parts[0]==”ts”. Ts stands for tile size.

So i check if the index 0 of parts is tile size and then check index 1 of parts to determine the actual tile size number to read it in into the syntax.

The file reader itself creates four vertices also known as quads. The file defines the position of all of the vertices. It is worth to note that a quad of vertices is required for both the position of the vertices quad and the texture coordinates from a image file.

The image file is composed out of 12 different tiles. Also known as a tile set. Each tile is defined by the vertices quads.  I can also get the tile ID with the current code, but I have not had enough time to implement any functionality that affects the mechanics yet.

I also implemented an additional library into the project called Thor. Thor is namespace that holds a lot of functionality. The only functionality i am using from it  at this moment is the input system. Since it holds a function for pressed once and when a button or mouse click is released. Which was needed for placing towers, so multiple does not spawn at the same time.

Thor also holds functionality for animation and a lot of math functions, though as i said. I have not used any of that functionality yet.

About Gabriel Ajuwa

2014  Programming