The problem with this one was that I was using direct enum values for collision types. A central routine in World class returns this collision type, but when you bumped on closed door it returned hitWall (simply because specific hit on closed door was not needed earlier). This kind of programming has the side effect that if you add something new it will probably make things go bananas elsewhere. The new in this case was hitClosed_Door.
As you may already guess the datatype class and public interface came to the rescue. It took some time to convert all (well, most of them, but it's a different story) direct references to hit...-enums to datatype class, but it was worth the effort. Now there are specific routines such as Is_Hard_Obstacle() and Is_Air() etc. These contain all the collision types and as new types are added no checks are needed through the source code for them to work.
Bump to door -option required this change, but there will be also bump check for things you can read. It will only require a new hit type when hitting a readable object and couple of lines of code to call the read function from the player's collision check routine. The new hit type will not confuse other things like pathfinding for monsters. This is the power of datatype classes.
No comments:
Post a Comment