Monday, March 15, 2010

AI and the Crosshair

I've done a lot of updates since the last post, so the title doesn't do it all justice. I implemented some simple artificial intelligence for the bad guys. I bought this book on game AI years ago that was written for C++ and shows how to create a state machine for managing character AI states. It's pretty robust allowing for you to have functions that execute when entering and exiting a state, and a global function that executes along with each state. Right now, I just have one state that each enemy type uses called "stroll" which basically has them wandering aimlessly with a 5% chance every half second to either jump or change direction. They are also smart enough not to fall off ledges or to run into walls endlessly.


Besides AI, I spent a lot of time polishing up collision; giving characters, melee attacks, and projectiles their own collision rectangles. The projectiles and melee attacks now collide with characters not on their "team". The team concept will be useful for co-op and multiplayer further down the road.


I also added the crosshair from my previous game attempt. While holding down the left trigger on the gamepad, a crosshair is drawn at your head. You can use the right thumbstick to move the crosshair within a certain radius of your head. This crosshair can be used to aim most weapons in any direction and I'm thinking of incorporating it into combo moves in the future.


The last, and coolest looking, update was to the standard shot. Chris came up with some much nicer looking graphics for the standard shot. One is in motion with a tail, and the other is a ball used for when its revving up to be fired and when it collides. When I saw the ball, I thought it would look awesome as part of a particle system and quickly derived a new one based on the explosion particle system with some tweaks. I set it up so the regular graphic will be used alone for a quick shot, and if you charge it up for more than 2 seconds, you get the cool energy trails.

No comments:

Post a Comment