I went back to a couple of my old games, in order to remind me of them for my Freegamer Interview. The first was DangerMan, a platformer with weapons. And I was (IMHO) quite impressed - the gameplay was solid, there were no glaring bugs, and it moved at a reasonable speed.
Then I took a look at Metal Glove Solid, my Gauntlet remake (which will have additional features later). Oh dear, it wasn't very good. It was dog-slow and the collision detection left a lot to be desired. How come I don't remember it being like that? It's time for some emergency programming!
The problem seemed to be my method for storing sprites. Gauntlet is famous for having a lot of sprites on the screen at once, and I needed an efficient way of keeping track of them for processing and collision detection. Usually in my games I just store them in a long list, but this can be quite slow.
My method was to have two two-dimensional arrays - one for storing each sprite at it's mapsquare co-ordinate (so drawing would be efficient as I could easily identify which sprites needed to be drawn, based on the area of map that was being shown on-screen), and one storing each sprite at each mapsquare co-ordinate that the sprite was covering - this would improve collision detection since I could easily identify all the sprites that shared the same mapsquare with the sprite I was testing for collisions.
Both of these methods seem sound, but the drawback is that every time a sprite moves, it needs removing and re-adding it to both arrays. This is what takes a long time. My not-so-difficult solution was to get rid of the first array and simply store the sprites in a tried-and-tested list. Performance is much improved, and the latest version (1.1) can be downloaded here.
2 comments:
Don't forget to enhance the Metal Glove Solid graphics using the Gauntlet Resurrection graphics from the FreeGameDev forums.
Yep, I fully intend to. I was about to start when I realised what a bad state the game was in! Now that's hopefully sorted, I'm doing the graphics next.
Post a Comment