Thursday, March 18, 2010

Back to "Work"

I know my previous post was only yesterday, but I thought I would show you what I managed to do in the couple of hours I've been awake. I mentioned earlier I had planned on paper the 'AutoTile' feature I wanted for my map editor and it really helped with the amount of time it took to code this:



As you can see, just by placing Water\Ground tiles the editor automatically fills in the edges for me so I don't have to. I know there is no pretty UI at the moment. But because I rewrote the engine, I haven't implemented it fully yet. Well enough to be of any use for this.

The way this works is pretty simple. The map consists of 4 layers, which only 2 of are used in the video. Layer 0 represents ground data. In this case only grass and water. Layer 1 contains edge data, which my "auto edge" function works out based on the ground tiles in use. To save memory, only Layer 0 is required to have valid 'Cells' loaded at all times. So when you see no edge, that means that the cell on the Edge Layer doesn't exist. In other words == NULL.

You might have noticed some choppieness when I started to tile. This is because at the moment, my resource manager is loading images on demand. Just as before, if the image has already been loaded, it is found and a pointer to it is returned instead of loading the image again. I can fix this by having the map load all the images it will need before hand, but I will get to that later when I reimplement my map loading feature.

Well this was just a quick update to let you know I'm still working!

Living up to the blog title...

I don't have a very good reason for why updates are lacking. In fact the only reason was the arrival of my birthday and then a couple of dats later Final Fantasy 13!
So, after managing to put 80 hours of last week into the game, I've almost 100% cleared it. I don't usually play games like that, only the ones that deem worthy to steal my life.
I really enjoyed the game, despite how linear it was. The story was good, not the best, but enough to make me feel something for the characters. Althoguh the ending I had to watch twice to get my head around what exactly happened.
The new battle system is nice as well, although a little easy once you get the hang of it. But it's fast paced and flows well, unlike most RPGs that don't have real time combat,

Anyway enough of that game, and more about mine I think. I really wanted to have another video ready for this post but alas I have been lazy and only now decided to open up Code::Blocks and pick up from where I left off.
How ever after my last post, I decided to re-write the whole 'engine' and am still in the process of doing so, so if I showed you a video now, the best I could probably do is something like my first post.
The reason I decided to re-write it is 2-fold. One because I didn't like the coding style I was using. As the project grew I was confusing myself a little bit. Secondly because I was programming elements that just wouldn't be needed. Mainly the GUI... Yes the window things were nice, but I will never use them in my game. From now on I will spend less time on gimmicks that are cool, or I think "That might be useful later" when in fact it wont and code only what's needed. I have a very good idea of what the game entales now, as I have spent a lot of time jotting down notes, and drawing up charts while at work (yes it's boring and empty in the bar I work in).

My next post will have something nice to look at I promise. I actually hand wrote the code for the map editor "auto-tile" feature which I will get working asap (if you remember I was going on about this in a previous post - it's something like the Advance Wars editor when you place grass\water etc...). I have also spent some time on drawing up some sprites that I'm quite pleased with :P So until next time, thanks for read. Ciao.

Tuesday, March 02, 2010

It speaks... Well, writes...

For detailed changes click here.

After all my work on the GUI, I got a little bored of it and decided to work on something with a little bit more meat and could actually be finished quickly. So I chose to work on my RPG-esque (actually it's near enough a complete copy) TextBox class. It was only after a few hours of head ache I realised this was just another form of GUI and wouldn't be as easy to implement as I thought. If you don't know what I'm talking about, check out the example pic below from Zelda Ocarina of Time to get an idea.


I wanted to implement a flexible TextBox class that very easy to get going when I wanted to display it. It needed to do the following:
  • Adjust it's height based on the amount of lines I wanted to display (and shrink if the text was smaller than that amount)
  • Take the whole text as one single string (not line by line) and be able to calculate how many lines there would be based on font width
  • Have support to colour characters\words\sentences through html like tag system within the text string
  • Have support to change the font of characters\words\sentences through html like tag system within the text string
  • Have support to force a new line when needed
  • Image support, either right\left aligned
  • Text alignment - left \ centre (I did right as well but it looked crap and I will never use it so it's removed)
  • Display text character by character based on delay time
  • Speed up the character by character delay by holding down a button
  • Display a whole line in one go without the effect of character by character
So yes, I wasn't asking to much... Especially since I haven't really worked with strings before to this extent. In fact the only thing I've done with strings in the past is assign them and display them (and maybe check their width). So it was quite a nice little learning curve. Check out the latest vid below to see how it turned out.



As you can see I've got everything I wanted apart from the image support (which is coming!) and I'm pretty happy with the results. At the moment it really does feel a little un-optimised though. For instance to prints this text string with the word "RPG" being red and in a different font and adding a new line before it I would type:

"/n<red><f>RPG<-> Text Boxes are more hassle than they look..."

When the string is parsed, new line symbols (/n - not \n) are removed and the text width is calculated by stripping the tags and then re-adding them after. Only during the drawing section of this text are the tags evaluated. Which seems wrong, because during that drawing, the logic is also reading the string character by character. I tried to find a smart way of doing this only during the logic cycle but couldn't come up with anything other than creating another array the same size as the string and keeping information about the tags on a per character basis, and that really did seem like more hassle than it was worth.

It works though which is the main thing, and with clever use of the:


int al_color_name_to_rgb(char const *name, float *r, float *g, float *b)

command in Allegro 4.9 my textbox now supports all these colours with just one simple routine. Yes I am really grateful for the hard work the Allegro Devs do, because it's introducing commands like those that make life a lot easier. I hope one day I will be good enough to contribute something back.

I think that's enough of me going on for one post, so I will leave it here. My next major task is going to be cleaning up my existing code, and completing the Map Editor to 100% or near enough. College finished early today and I thought I would spend the time in the library fleshing out my game design, so now I'm pretty certain what I will and won't need which can only be a good thing. I would like to talk about the game more, but I really would like to have something to show about it first.

Thanks for reading =)