SSS #8 - More bad guys
Since the last update two weeks ago, I added more enemies to the game, heart pickups to replenish health, and (completely off-topic) I’ve spent a week in the Netherlands.
The new enemies are skeletons, knights, and knights with shields.
Skeletons and random walks
Skeletons do a random walk around the screen, and when you line up with them in either the X or Y axes, they turn towards you and fire an arrow.
If the server and client used different seeds for the random walk, the behavior of skeletons could get out of sync between updates from the server and look quite laggy. The hack I’m quite proud of is to use a combination of the mob’s position, GUID, and the number of seconds since the last time it took damage as the seed. As all this information is deterministic, but changes between successive random choices, the behavior is completely deterministic and tolerant of lag, but still looks quite random.
Knights reuse the skeleton’s code for random walks, but they behave differently when you line up with them in either the X or Y axes. Knights charge at the player with their swords out instead of firing arrows. Shielded knights (the lighter, grayer versions) also carry shields and so are impossible to damage from in front.
In practice they tend to be really quite tough to kill and to escape from. To soften them down a bit I’ve made them drop hearts upon death, and they will also blindly charge into holes. The best way to kill them seems to be to jump over them and attack from behind. In the released game I will limit them to one or two per screen.
blog comments powered by Disqus