When I last updated here, I had a guard patrolling around the center pedestal of this space, and the player's character could move around the space, trying not to be seen. Thing was, I had some weird flaws in my raycasting math, and the guard could see the player when he shouldn't have been able to. I looked around, and found a number of different implementations of line segment intersection tests (seems like a while ago, it was easier to find good intersection tests online - have things got worse?) which I coded up bits and pieces of, and eventually came up with one that I liked.
Today, I added in a notion of a "patrol path", an ordered sequence of points that the guard would march along. The way that works is that there's an index of which point the guard is trying to reach. If the guard is close enough to the destination, increment that index. If the guard can't see the destination, increment the index. This suffices (for this map) to give the guard pretty reasonable patrolling behavior.
On top of this, I also check to see if the guard can see the player. If so, rather than moving towards the next patrol waypoint, head toward the player.
This provides a small amount of tension, and you can now "sneak" around the level, timing your darting from one occluded area to another. If the guard sees you, you can dart back into a shadow, which leaves the guard to pick back up on his path. That's not so satisfying, so I'll come back to that later - my plan is to have the guard drop a cookie crumb at the last spot that he saw the player, and chase that in absence of having clear line of sight - this should allow the guard to do some simple chasing around corners.
There's no actual "win" condition yet, and the "lose" condition might be if you want to say that when the guard reaches you, you're "out".
I had planned to have fancy art, and I might still get around to that, but I might stick with abstract representations in order to get something done by the end of June. I've got less than a week. Yeesh.
No comments:
Post a Comment