Posted by & filed under Dissertation.

Over the weekend (and Monday) I worked on the algorithm that will load a specific room based on a text file. I have already had experience in previous projects with this method to load in levels so implementing it into LibGDX wasn’t too difficult.

The code is mostly the same as previous projects expect for how the engine handles resources. Since LibGDX exports projects to Android, Desktop and HTML it has to handle the resources in a specific way so that all three implementations can work the same. It does this by using a class called ‘FileHandle’, you can then say where the files are located (internally or externally). I couldn’t find much documentation of this other than specific bits of code for basic implementation, therefore I had to play around with it for a little bit to get it to work the way I wanted.

The below to the right is an example of a simple level I designed for testing, it uses only three characters right now for the following purposes;

  • ‘#’ = Enemy
  •  ‘|’ = Block
  • ‘-‘  = Blank/Empty Space

The algorithm works by reading each line along the X axis and then each line across the Y axis in two for loops. Each time the algorithm reads in a character it parses it into a switch/case statement where it adds the entity associated to that specific character.

The other part of the project I have implemented is some simple AI. Each of the enemies added to the game screen at the moment move to a specific point in the game, once they arrive at that point they then move to another point on the map. I did this as I wanted to test the hardware of my phone to see if it could handle having a few enemies running at once. Right now there is no collision detection going on so they often move over each other or the player. Collision detection is obviously something I want to implement in the game but right now its not the next thing for me to do.

The next step is the level generator, by this I mean that the game will create a sort of maze based on a few rooms that I have made, the maze needs to be able to be navigated by the player so there should be no inaccesable rooms.

To see a short video clip of what I have implemented so far please click this link:

Leave a Reply

You must be logged in to post a comment.