Hello Blog. It’s been a while since I’ve posted anything on you. Sorry to be away for so long. Lots has happened since I last posted. I’ll start with a post about my studies and the Train2Game course I am doing, at the end of which I plan to be a games developer!
I have been working on Portfolio Project 2 which has proven to be a little trickier than originally thought. Since September 2011 I have come to a finishing point for two of the five tasks. Sprite Blitting and Pathfinding.
I tackled Sprite Blitting to start with and really had to get my head around what it was that was being asked of me. I decided that it was to create a class that could take one image of sprites all various sizes and split them up as required, for example the image would be 100 pixels wide and 20 pixels high and within that would be 20 by 20 pixels of character animating making 5 animations. The code would split the big image up and put the smaller images in to an animation sprite. I had about three attempts at getting the starting point right, but in the end I managed to identify the necessary classes that needed to be created and the files I needed to make the sprite blit animations work successfully. I guess this means a cut down on the number of separate images that need to be supplied for an animation, and the amount of processing required to access the files and store them in memory each time. But I got the code to function and run and now I have four images appearing on screen where only half that amount is image files. The documentation still needs fleshing out a bit, but I felt it was time to move on to the next task.
Pathfinding was the harder of the two so far. I had an understanding first off of what was required, it was how to get the desired result that was the problem. I created a map file that would be loaded and then displayed. At points on that map were start and end positions along with obstacles in the way, and then the player character would be loaded and go from start to end positions avoiding obstacles. Easy!? hahaha.
Getting the Tiles mapped out in to a text file and then having them load to appear on screen was easy enough. The start and end position images were loaded correctly, the player character was loaded and animated just fine. Getting the player character to move from start to end checking for collisions and avoiding obstacles was also fine without any path checking, just trying to go the .x+1 and .y+1 route. What was tricky was implementing the A* algorithm to then work out which tiles the character was best to use to get to the start and end with the least cost involved and avoiding obstacles. I don’t think I had thought hard enough in to the tiles and how they are stored/referenced so I had to do addition workings within the A* code to figure it out. At first I managed to get the character to work out the route, but that was a simple go down three tiles and right 5 tiles. Anything more complex seemed to make the character wander off in all sorts of directions without stopping! I eventually worked out that the heuristics were causing problems and working things out the wrong way round. Values were lower when they should have been higher. So I changed from a Manhattan heuristic to a Euclidian heuristic and managed to get the right result, the character would go from start to end avoiding obstacles perfectly on a semi-complex map. But when you add in major path finding obstacles and paths then the character just seemed to go up and down until it got stuck and then jumped to the goal over everything. Since I had spent a long time getting to this stage I put it on hold with comments in the document of all the improvements I want to make if there is more time, but the overall algorithm works fine.
I’m now on to the third task of Data Serialisation. At first I thought this would just be a case of using the example code supplied and getting it to save as binary, but there seems to be a lot more involved with creating a serialiser and a serialise aspect to the whole thing. It gives examples of XML, YAML and JSON as file type examples that are read and written. I understand what it is saying with regards to these files but I need to research a bit more in to what it is I am to create.
That’s it for now on my studies. The Portfolio Project 2 is coming along (somewhat slower than I’d have liked) but at least I have a schedule in place to help get me back in to the flow of studying more and more. Usually 2 days a week uninterrupted as well as a few evenings.