Recently I have felt the need to do a bit more software development and so this evening I pulled out the code for a game I have been writing. Yes it is taking me a long time to write this game but it is the journey I am more interested in than the destination. I need to create an algorithm that allows a bad guy to hunt down the player. It looks so easy to do graphically but is much more difficult as I try to think out the steps so I can translate them into computer code.
I threw together something simple and then discovered that it doesn't work very well. When the player gets close to the edge of the screen, the program gets stuck in an infinite loop. I know the cause and so I am having to create a more complex algorithm. Not only do I have to check if the bad guy is close enough to the player to see him, I also have to check to make sure I don't try to run off the board or through an object on that is supposed to be a barrier.
When I learned how to write computer programs in high school, my teacher taught me to pull out a scratch sheet of paper and step through the algorithm development process. So that is what I find myself doing this evening. I have a notepad with X's (the player) and O's (the bad guy). Then there are arrows showing player movement with the bad guy chasing him down. I am making progress but not nearly as quickly as I had hoped. I do have to admit it is an interesting algorithm I am trying to develop though. One that can be used for a number of video game situations. Unfortunately I had to wake up too early this morning to catch my flight from home to the Bay Area and so I am finding it hard to concentrate. Perhaps I will have more luck tomorrow.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment