Tuesday, April 27, 2010

Vehicles and Physics

I've added the Farseer Physics Engine to our game. I have to say, it's very impressive and a lot of fun to play with. I spent hours tweaking various physics values and trying different functionality. For now, my goal was to get the engine integrated into our game and create a vehicle that can ride around our maps with a mounted turret gun that fires. To do this, I first had to make our map ledges "collidable" with Farseer's Physics Simulator. I changed the map loading routine to automatically create polygon "Geoms" with which objects can collide with when creating the ledges. Then, I went to work with building a prototype vehicle that I (very) roughly modeled after the Warthog from the Halo series. One interesting thing I discovered during this whole process is that most popular platformers don't actually use realistic physics like this. It makes the character difficult to control and the movement just doesn't feel "right" for a human (or human like being). For this reason, I decided to keep the original, simple, physics system I already had developed and include Farseer as an additional physics system to use only for specific entities that require more complex and realistic physics such as vehicles and grenades. Because we don't have art yet for sloped ground or any vehicles, I just draw simple shapes to demonstrate the physics and vehicle.



Tuesday, April 20, 2010

A Brave New World

It's been a long time since my last update to the blog. It's not because I took a break from the game, but rather that I've tackled my toughest challenge yet. I decided to design my own system for map linking and mini-maps. Instead of looking for help and examples in books, forums, or blogs, I sat down with a pen and paper and planned things out myself. It took me quite awhile to come up with answers to all the problems I faced, but I think I ended up with something decent that works and I'm happy with it. I call a collection of maps a "world", hence the title of this post. I needed to make a new editor to create worlds with, but I'm bored to tears with the UI code so I just put together something super ugly but super quick, copying a lot of code from my previous editors. The video below shows Chris' new shark, which I think is super cool, running through our first test world.







Next up on my TODO list is to fix up a few map transition issues and then experiment with the Farseer 2D physics engine to see if I can get it working with our game.

Friday, April 16, 2010

Shark Attack

We added a new character yesterday, the so far unnamed shark warrior. I've been working on the art for this character on and off over the last two weeks. The shark is going to act as our strength character. While the blind warrior will be our DPS and the Bargle is going to fill the intelligence/tech role. At least, that's our thinking so far, the game is ever changing.



I put some time in after I finished the sprite work and got a pretty decent run sequence going. Since I've been working on this game I've been using the book Cartoon Animation by Preston Blair as a reference. The book is very old school and at first glance looks a bit cheesy but it's actually packed with tons of good information ranging from character creation to animation sequences. It's also very easy to find online for free.



I based the shark's run sequence off of the sequence below. It translated pretty well but I did have to add one more frame to the sequence to get it looking right.




Wednesday, March 31, 2010

Reading and Writing XNA Game Data on the xbox

This is something that you think would be simple and straightforward but is actually a bit tricky. I found it tricky anyways, because I could not find adequate information on the subject from Microsoft's XNA and MSDN web sites. Surely, I could be missing something somewhere, but it wasn't apparent to me where I could find what I was looking for. After reading about a dozen or so blogs, forum posts, and MSDN pages, and struggling with my game for a few hours, I finally figured it out. This is what you need to know:


1. You need to use the XNA Storage API, which conveniently will automatically work with PC and xbox without having to code separately for each.


2. There are two separate file locations to work with, the TitleLocation and user-specific folders. The TitleLocation is read-only and stores all game related data that ships with the game. In my case, this is where my map and character data files are kept and read from. I simply place the files in the root folder of the project and add them to the project with properties set to "Copy if Newer" and "No Processing Required". The user-specific folders are read/write and this is where you can save/load games, store high-scores, etc. and it is per user (xbox or windows user).


3. When opening a stream to read data from your TitleLocation, be sure the access flag is set to read-only. It will crash if you open it any other way, even if you only plan to read from it.


I'm not going into all the details with code examples, because there's a lot to find on the internet already. I just wanted to point out some of the facts that I thought were missing from what I read in my research.

Tuesday, March 30, 2010

Turrets!

Originally, we had decided that we wanted to make the game single player, with possible multiplayer and coop additions in the future. However, last week we reversed this decision and opted to go for a multiplayer only game first and then possibly follow it up with a single player and/or coop campaign mode. This would make it easier for us to release the game sooner as less content is required. We started thinking of different types of online games we enjoy playing and although we don't have a definite plan yet, we're leaning towards a sort of 2D Starsiege: Tribes inspired game. There would be two teams, each defending a base where they can deploy turrets, defensive walls, generators, etc. and would heavily rely on setting up cameras and motion sensors to detect and track enemy movement on the map. The map would be divided into many screens to make a big playable arena, so it's not just about combat, but strategy and communication. These are just ideas right now, and we're not sure how well it work out just yet, but that's where all the fun will be trying out different ideas. So this week, we had two major accomplishments: adding the turret, and getting the game to run on xbox. Getting the game to run on xbox was harder than it probably sounds and took me a few hours to figure out. I'm going to post a separate entry on that process for future reference and in case anyone else gets stuck like I did and stumbles across this blog. Anyways, check out the cool turret:


Tuesday, March 23, 2010

Rock n' Roll Arm

The main addition in this update is what I call the "rock n' roll arm". Last update, I added the ability to aim your shots in any direction, 360 degrees, using a crosshair. Unfortunately, this didn't look very good when shooting in any direction except straight ahead because the animation for the hero just has him aiming straight ahead. I fixed this by replacing his shooting arm from the defined animation with a special arm that will rotate to aim wherever you are aiming. This looks much better, and when you circle his arm around it looks like he's rockin out really hard. Aside from this, I also added character-to-character collision and a hollywood style slow motion effect which can be scripted. The new collision allows for characters to push each other around. The slow motion effect is simply to add some style, and to show it off, I added it as part of the attack combo animation I created a few weeks ago.


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.