Sunday, May 12, 2013

Heart Realm Update #005

So it's been two weeks since the last post, I just never got around to posting earlier because I felt that the progress I made wasn't worth posting about too much as it wasn't too glamorous.

Over the past two weeks I've been working on ways to implement enemy mobs and some of the various things associated with them.

1) I had to create a base class for the character stats which is utilized for both the player and enemy mobs, then create two child classes each with their own variations of the Character class to incorporate the differences they each have. For example, the player has equipment that can affect their stats while the NPC mobs don't.

2) Created a way to import enemy types and store it somewhere so they can be used.

3) Loot Tables, a simple way to store the types of items that can be dropped by mobs, can be reused by multiple mob types which can help cut down on memory usage, having to recreate the same loot tables.

4) Entity Manager a way to handle the many entities and to allow for easier communication between entities.

5) Rendering the enemy mobs, which means including any animated sprites that would be need to render them.

With all those set in place, I faced a slight issue, the way the render function worked for my Entity Manager class was it would loop through all the stored entities and render them in the order with which they were entered in. The problem was that you could have some entities overlapping other entities that shouldn't be overlapping, simply because it was created prior to the other one. To fix this I had to come up with a way to sort the list of entities and what I felt was sufficient was to simply sort them based on x and y location. An entity with a higher y value would be rendered after one with a lower y value, which give the effect that objects higher up in the screen were further away which works for this sort of semi-top-down perspective. I figured I'd do the same for the x coordinate as well, just because (no real difference in performance by adding in the x coordinate).

After fixing that issue, I faced another issue. The tiles were too small, when the player was standing next to a mob of roughly the same size they would be practically standing shoulder to shoulder, which is something I didn't want. To fix this, I decided to increase the tile size from 16 to 24 allowing for more detail and as well as more space for the two entities to stand next to each other without touching. This on its own brought on a few interesting set backs as I had to fix a bunch of things that I had hard-coded. I originally planned for the game to utilize 16x16 square tiles, but because the player is a 32x32 sprite it really screwed with the amount of space for objects to sit on a tile.

That's all for this update. I hope to add in health/basic attacking of enemies and maybe some basic AI by the time I post another update, hopefully in a week rather than two.




Oh yeah, I also messed around with fonts a bit and drawing text on screen. I still haven't come up with a robust way of doing so as right now I had to hard-code that text in the main game class, something I definitely will not be keeping.

~ Rogue Templar

No comments:

Post a Comment