Character mapping, loading, and the power of lists.

I have added different enemies to the maps. I created a Point variable and a property for it on the AnimatedSprite class. This helped me use the TileEngine points to place them on the maps and manipulate them if needed. I then created a list to store the enemy animated sprite objects. This made it much cleaner code everywhere else. I knew from the start that I should implement a list but I was doing lots of things to try it out and see what could be done.

I was so happy with the list though because it cut out at least 30 lines of very similar code just on the check for what map to draw the enemy in. It also made collision detection for them simple by iterating through the list again and setting the rectangle equal to their position if they were on the active map.


Beautiful Spaghetti Code

Replaced by these 5 lines.

I am familiar with lists but this still felt like a major programming breakthrough for me. I still have a hard time programming from scratch and this felt like I was able to start coming up with ideas and implementing them on my own. In fact, I don't think I have made this much progress in Shiny Blade as I have in the past few weeks alone.

From there it was a simple change to the battle screen constructor and the call to it to pass the AnimatedSprite objects to the 2DBattleScreen. Now the badguy sprite in the 2DBattleScreen is the same that was on the Overworld screen. There are still issues to work out and clean up but it was really not as hard as I thought it would be to get that setup.



So from here on out there is still a lot of work to go. I really want to use bigger cleaner sprites in the battle system. I then need enemy artificial intelligence. Right now they all just shoot projectiles to the left and don't move. I want to start creating my own artwork. My first attempt wasn't as nice as I wanted.Then it will probably be onto music which I don't even know where to start with that. It seems that most indie developers that I have asked said they hired out for the music. After that I am thinking two player mode. My son really wants that included.

This whole experience has helped me appreciate the talents of those who make games. It is very satisfying, but there are those times where I feel overwhelmed with how much I don't know. There are times where I try an idea and feel that for sure that is the way to program it. One example is screen management. I am following the example found online for XNA. It seems simple enough but I always seem to be removing screens from the stack in the wrong way. I try ScreenManager.Remove() so many times before I do it right ( which off the top of my head I can't remember right now) and it even states in the summary for that call to use GameScreen.Exit() instead. That won't work in all cases due to being static.

Well it's late. We haven't had as much sleep as normal in our house due to some kids being sick so I will turn in for the night. 




Comments

Popular Posts