Monday, August 17, 2009

Class preparation

I've been putting all my extra time into a class I will be teaching at Chapman University next semester. We'll be using XNA and C# to build an open source game engine. I have the project all setup, the training and managment of subversion is ready and I have a pretty good outline and a good direction for the engine. I've done a few games using XNA, but for the tool side needed to figure out the WinForms integration and found these microsoft sites on WinForms/XNA to be very helpful.

I'm a blender fan, but I really need to train people on 3dsMax. I purchased an edu copy a year ago (still way to expensive) and I'm finally forcing myself to use it. I've been going through the tutorials and think it will be a good way to learn max. I also need to get through all the skeleton animation stuff so I know how to do it in Max. I've done it with Blender, but for this class I really need to use the tools that we have on the computers in class.

It starts in two weeks. I have a ton of material so far, but there is still a lot to go over.

I also went back and looked at the pinball game in second life and I have been itching to do some more work on it. I finally think I know how to fix the bumper mechanic and add a little skill to the game. Too much going on at this point, but hopefully the idea can slowly rise to the top of the queue and I can do some more work in SL since I enjoy that environment.

Tuesday, July 21, 2009

GameDev360 website updated

I've updated the GameDev360 website for the class. I have it on local disk so not much to show. I'm planning on mostly using the open source project on source forge for the class, but I still needed some place for the syllabus and class overview.

I also had to pick a book for the class. This is the book I'm going to use. I doesn't have anything to do on engine development, so I'll be teaching that part without a book.



I also like these books a lot and will be using them as a resource. The second one doesn't have anything to do with XNA, but it has a lot of good ideas about game engines.


  

Monday, July 20, 2009

CPSC340 Game Development

I've been working on both Project2015 and a class I am teaching this fall. The Project2015 stuff is going very slow and has seemingly lost a ton of momentum. Work has had a tough deadline and this looming class I'm teaching is starting to consume my extra time as I prepare.

The class is on Game Engine Development. My plan so far is to use XNA and C#. I had wanted to use Torque/C++, but the XNA/C# stuff has made some sense and we have been going in that direction. I still want to get in some C++ work and I'm trying to figure out how to do that at this point.

The open source engine is going to be called Panther Game Engine. I've already setup a source forge project for it and have been slowly configuring the group. I still have about 6 weeks, but that doesn't feel like much time.

I've completed all the SVN setup and have my lecture for that planned. I still want to create a screen cast of the process so it will be even clearer.

The term "Game Engine" is heavlily loaded and not well defined. For me, it's all about tools to make building games easier. So, I've been creating the shell of a level editor for xna. The toughest part was integrating XNA and Windows Forms. I have that working and ended up using a piece of Microsoft sample code and have tried to segment it from the open source project as best I could. This really should be part of the XNA release and not some separate set of code, but at least there is a sample of how to do this.

Next up is working on a terrain system, then I want to get the animation work flow down. Lots to do.

Monday, June 29, 2009

Project 2015

I've had a few meetings about the Imagine Cup game. It seems like the best option would be to develop the game under some sort of non-profit. We would finish the game by trying to get grants or just using free time, then launch it on something like Xbox live or as a pure PC game. Take the "profits" and turn them back seed funding to continue the work on the game and to build other humanitarian interest games. That is the plan.

We need to create a development plan to use on any grant requests so we can show what any grant money would be used for. This is also necessary in developing the game. I have started on this and a business plan for the game. My regular work is coming into a dead line so I think the next month will be insane so I don't think I will get very far on this. I'll continue to work on it when I have extra time.

Wednesday, June 10, 2009

Imagine Cup Results

We learned that we did not make the finals for the Imagine Cup. Most of the games that were selected seemed to whitewash the Millenium goals and I do think that our game, given more development, could help make a big difference in people's lives.

My goal is to somehow continue development on it and finish creating a training tool for people planning on working in impoverished communities. I'm not sure how to get that done, but I've planned a couple of meetings with some of my contacts in the game industry to see what people have to say.

Monday, May 18, 2009

Imagine Cup

Where has all my time gone?

My work got really busy and I've been mentoring a team creating a game for the Imagine Cup. Never expected it, but all those trips to Africa doing community development have been helpful in building a game that is designed to help work on the United Nations Millennium Development Goals.

The team is in the final week (two days) of development and everything is coming along. I think this is one of the most interesting projects I have worked on in years and really follows closely the work in Africa I (my wife and a lot of good friends) have been involved with over the past five years. When we started the team we were looking at a different contest and the Imagine Cup came along after that contest was delayed. Very cool to see the fruits of many years of labor multiplying into completely new avenues of opportunity.

The game is called Project 2015. The Project 2015 website is currently a month and a half old and used for the first submission. I expect it to be updated in the next week. Stay tuned.

Friday, April 10, 2009

Testing some shading options

As I've been testing lately, you can purchase all the source code for this sample for $5
(http://store.payloadz.com/go?id=254377).

I’ve been testing some shading options and working on the 3D aspects of XNA that I have been needing to learn. One of the problems is that I have 3DStudioMax, but it is only on a machine I don’t use as much. I’ve been contemplating moving the license, but that has issues. I’ve used Blender in the past and have enough knowledge to be dangerous to myself, but went back to it as I have not been able to use Max when I need it. So, this was as much a Blender session as an XNA lighting session.

I’m using Reimer Grootjan’s book XNA 2.0 Game Programming Recipesand found it very helpful in the shading and rendering aspects. I know it’s for XNA 2.0 and I’m using XNA 3.0, but the stuff I’m looking at has not changed (as is most of the book) so it is still highly relevant to learning XNA 3.0.

The section I used was on directional lighting on page 514. It shows how to get the BasicEffect to work with a directional light.

My code looked like this when I was done.

effect.LightingEnabled = true;
effect.DirectionalLight0.Direction = light0Pos;
effect.DirectionalLight0.DiffuseColor = Color.White.ToVector3();
effect.DirectionalLight0.Enabled = true;
effect.PreferPerPixelLighting = false;
effect.DirectionalLight0.SpecularColor = Color.White.ToVector3();
effect.SpecularPower = specPower;
With, specPower and light0Pos set at the top of the class definition.


Vector3 light0Pos = new Vector3(-0.5f, -1.0f, 0.0f);
float specPower = 64;
After weeks of procrastination and thinking I was going to have to create a custom shader it was nice to find out that adding a directional light was very simple. One of the games I was going to do requires a spotlight and I do think that will require a custom shader so it's off the list until I get some extra time.

So, first up with Blender. I’m trying to display a gemstone. I created a isosphere then scaled and stretched it to look like a gem stone. Then I added a red texture. You can see that I set the Col (Color), Spe (Specular Color) and the Mir (Mirror Color) for the gem.


This was fine, except that the gem came out all smooth.


I know from experience that this is caused by the rendering system using vertex normals to draw the individual triangles of the gem as smoothly as possible. This is almost always the case. But for a gemstone, you want it to have facets. I spent a ton of time trying to figure out how to get blender to remove the vertex normals and only use surface normals.

This ended up being easy inside of blender, but took a while to figure out how to get this information into the direct X file. To do this in blender, you select the object in edit mode, then click the Set Smooth button to use vertex normals for rendering and Set Solid to use surface normals for rendering.


Easy and you can see the two rendered versions here.


That’s all well and good in Blender rendering, but XNA kept displaying the gem as a smooth surface. After tons of fiddling, I noticed one of the options on the Blender DirectX exporter was “no smooth”. The tool tip says exactly what I wanted to hear “Every vertex has the face normal, no smoothing”.



Once I exported with that setting everything worked.



Getting back to Blender, I found it really hard to learn, and hard to relearn, but for the price (Free) it really is an amazing tool. I have a book on it that I've barely touched called Introducing Character Animation with Blender by Tony Mullen. I've had it for a few years and only touched the surface on it and every time I pick it up I'm always impressed. It really does look like a great book. As I write this he has a new version due out soon and another book on Blender that was just released. See below.

My real problem with Blender came in the classes I was teaching on Torque last year and the fact that we could never get the bone systems to work properly. It seemed that 3DSMax was the only real way to do modeling for Torque. Maybe that has changed?

I did find this great reference image on the Blender hotkeys (http://en.wikibooks.org/wiki/File:BlenderHotkeysObjectMode.png. If you are going to use Blender, you are going to want to learn as many as possible. It really is a fast fast tool once you get to know the UI. Mostly I only use Space Bar, B (box select), A (select/deselect all), S (scale), R (rotate X,Y,Z).




As I've been testing lately, you can purchase all the source code for this sample for $5.
(http://store.payloadz.com/go?id=254377).

Wednesday, April 1, 2009

Balance Air Game

This is the best one so far. Didn't have a lot of time again so I went 2D and wished I had enough time to add a little sound (like a hair dryer sound) and do some more complex goals (like a bucket), but I think it's probably the most fun so far. It's not super pretty, but good luck, it's really really hard.


The game is called Balance Air. You have a hair dryer at the bottom of the screen and you need to balance the ball on air and force it into the goal. You move the blower left or right to change the direction of the ball. There are 7 levels which are basically just different locations for the goal. The score for each goal is dropping over time.

As I did last time you can download a free executable of the game. It is available here: http://www.woodsgoods.com/gawxna/02balanceair.

The complete source and Visual Studio project is available for $5 at http://store.payloadz.com/go?id=246205 .

Enjoy and please give me some feedback.

Wednesday, March 25, 2009

Skeet Slider game

I didn't even think I was going to be able to get a game done this week. I was spending a bunch of time on HLSL (the XNA shader language) and not getting where I needed to get. I decided I still needed to get a game done this week and I have yet to do a 2D game using XNA so I decided (yesterday) that would be the best way to complete the project in the time left.

The game is called Skeet Slider. Not my best by far, but much better than the past few weeks while I've been learning the XNA framework. You slide a puck across the bottom of the screen trying to avoid bouncing blocks. It's all about timing. I wanted to add a feature to change the velocity of the puck, but I'm out of time. Here is a screen shot of the game on level 4, the highest level. I spent a little time at the end to add better art for the game so it is cleaner that what I've written in XNA so far.



I also messed with the publish system in XNA Game Studio 3.0 and created an installer you can use to run the game. It is available here: http://www.woodsgoods.com/gawxna/01skeetslider.

I have also been considering offering the source code to some of these games to try and cover some of my time. It's a minimal $5 to purchase the C# source code to the Skeet Slider XNA Game. Please tell me if you think this is reasonable or not? I could really use some feedback.

Wednesday, March 18, 2009

SpinMag game

I used the same rotating magnet from last week and added a different scoring mechanic. I also added a levels using png images to place items on the map. There are four levels, but the game is really tough. Currently it only has one life. I wanted to add more, but ran out of time. I again spent a bunch of time reading about texturing and lighting and have not made the progress I had hoped. I'm considering a game that uses spot lights as a mechanic next week.

This is a screen shot of the game.

This is the map image. Each pixel represents the location of one of the 3d spheres.

Here is the code that reads the map image and converts it to 3d objects.

protected void LoadMap(String mapname)
{
// the map is just an image file with pixels of various colors
// red = barrier
// black = open space
// cyan = closed space
// green = starting point
Texture2D map1 = content.Load<Texture2D>(mapname);

mapwid = map1.Width;
maphei = map1.Height;
int numpix = mapwid*maphei;

if ((map == null) (map.Length < numpix))
{
map = new byte[numpix];
}

// want this map to fit over the circle, so calculate the size of each ball
// scale of the ball
mapballsz = (int)(maxballdist*2) / mapwid;
mapxstart = -(mapwid / 2-1) * mapballsz;
mapystart = -(maphei / 2-1) * mapballsz;

/*
* the sample I used to write this method
* ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.XNAGS30.1033/XNA/GetData``1_B8CC1053 */

Rectangle sourceRectangle = new Rectangle(0, 0, mapwid, maphei);

Color[] retrievedColor = new Color[numpix];


map1.GetData<Color>(
0,
sourceRectangle,
retrievedColor,
0,
numpix);

goalcount = 0;
int i;
for (i = 0; i < numpix; i++)
{
if (retrievedColor[i] == Color.Cyan)
{
map[i] = MAP_CLOSED;
}
else if (retrievedColor[i] == Color.Red)
{
map[i] = MAP_BAR;
}
else if (retrievedColor[i] == Color.Blue)
{
map[i] = MAP_GOAL;
goalcount++;
}
else
{
map[i] = MAP_OPEN;
}
}
}

Wednesday, March 11, 2009

SpinDart

The games are getting closer, but still have a ways to go on getting my art pipeline down in a week. That's where I spent a bunch of time this week trying to get some models out of 3ds Max which I'm new to. I got the models out, then left them on a different machine so this screen shot is untextured models.

It isn't what I started out to make and I may make a different game with this same mechanic next week. Locking the z axis and making this a 2d game helped the time constraints some, but I would like to be able to get that third axis in a week long game cycle.

The game is a "gravity" style game which is one of my favorites. Impossible to control which means the mechanic doesn't really work, but I'm not 100% sure it is impossible to control. Given a shared high score system I think I would see some different approaches to making points, but alas I haven't written the shared high score system yet...




Here is a code snipet that does the collision checking. I didn't use the XNA system which I looked into a little and decided it was easier to write this simplified code.

private void checkCollision()
{
// check the position of the ball with that of the spinner
Vector3 vspin; // = Vector3.Backward; // pointed up
Matrix m = Matrix.CreateRotationY(spinnerRot);
vspin = Vector3.Transform(Vector3.Forward, m);

// I know the spinner is 7.2 units before scaling (looking in milkshape)
vspin = vspin * 7.42f * scaleXY;

// now check the position of the ball in z space
if ((ballPos.Length()>vspin.Length()+ballradius) && (distToOriginLineXZ(ballPos, vspin) < ballradius))
{
// collision

// wwh score or death?
score = score + 1;
}

// check if we are inside the center of the spinner
// spinner sphere radius = 2
if (ballPos.Length() < 2 * scaleXY + ballradius)
{
// wwh score or death?
mode = STATE_OVER;
if (score > highscore)
score = highscore;
//score = score + 1;
}
}
private float distToOriginLineXZ(Vector3 pt, Vector3 oline)
{
// used this reference
// http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/
// p1 = 0.0,0.0
// p2 = oline.x,oline.z
// p3 = pt.x,pt.z

// oline is a line from the origin
Vector3 vi = Vector3.Zero;
float u = ((pt.X - 0.0f) * (oline.X - 0.0f) + (pt.Z - 0.0f) * (oline.Z - 0.0f)) / (oline.Length()*oline.Length());
vi.X = u * (oline.X);
vi.Z = u * (oline.Z);

pt = pt - vi;
return pt.Length();
}

Wednesday, March 4, 2009

Sphere Pong

This week's mechanic I was working on didn't really work, but it was a fun idea. I created a 3d pong game where you move the puck around a sphere and try and keep the ball in the middle. The problem is there is no reference point. I need some sort of skysphere or spherical markings or maybe also a tail on the ball so you can more easily tell direction. Ran out of time, but may come back and revisit this one someday.

I'm still learning XNA and the graphics look crummy, but for me right now this is more about learning the api than working on making a good looking game. Forward progress at any rate.
For a code sample a lot of the time was spent in positioning the puck around the sphere. I only finished the x,z plane as it didn't work for that, so no reason to add the third dimension. Here is the code to position the puck around the sphere.
// move the paddle using the upVector (true) or the cross product of the origin and up (false)
// direction is a + or - 1 for up, down, left or right
private void movePaddle(bool usingUpVector, float dir)
{

if (!usingUpVector)
{
// need to take the cross between the up and the origin
Vector3 vp = paddlePos;
vp.Normalize();
// vector change
Vector3 vc = Vector3.Cross(vp, paddleUp) * dir;
vc.Normalize();
vc = vc * paddleSpeed;

// find the new location, will be outside the sphere
vp = paddlePos + vc;

// fix up the distance ot the sphere
vp.Normalize();
vp = vp * radius;

paddlePos = vp;

// the up vector should not have changed, right?

// move the camera behind the puck
fixupCamera();
}
else
{
// for this case, take the cross product
// move in the direction of the up vector (+ or -)
// position against the spehere
// use the cross product to calculate the new up vector
}
}

Wednesday, February 25, 2009

Bounce game

This week I was working on learning and using the physics engine JigLibX. Painful to say the least. I need to be spending my time learning XNA since this is only the third week. No documentation on JigLib and I spent a lot of time trying to figure out the connections between it and the XNA rendering system. I don't have a good understanding of the rendering system in the first place and mix that with a lack of understanding of JigLibX and it was a surprise that I actually got a game done.



In this game the ball is bouncing at a regular rate. The idea is to move the little green dot around and tilt the tiles so the bouncing ball ends up landing on the green platform with the least number of bounces. The ball started in the bottom right corner. One of the biggest time sinks was the fact that there is no hidden surface removal (as you can see in the top right corner platform) and I spent a bunch of time trying to figure that out and didn't get it done. Had to move on. For me the jury is still out on JigLibX, but it seemed like it had a lot of potential, just needed more samples (that included hidden surface removal) and documentation.

If you want the source, send me a message and I'll consider sending it to you.

Wednesday, February 18, 2009

First Full Circle XNA Game

After going through the tutorial last week I decided my best bet was to create a full circle game. That's a game with a main menu, the game, and a game over screen that moves back to the main menu. This is a shot of that main menu (very simple).


There also needs to be some sort of scoring or timing sytem. This will typically end up being the template for the rest of the games from this point forward. I used the art work from the tutorial and created a grid. Then added on model that could move up, down, left and right (only 2d) in the grid. One of the models is spinning and the idea is to move the red model on top of that model with as few moves as possible (looping around the other side is a key mechanic). In the screen shot, pressing the right key will move on top of the spinning ship as clicking the left key will take three moves. Get it?

For a piece of sample code, this is the row column stuff and grid keyboard movement I have written a million times. Maybe I can come back here next time and just cut and paste.

private int rowFromPos(int p)
{
return p / tilerows;
}
private int colFromPos(int p)
{
return p % tilecols;
}
private int posFromRowCol(int row, int col)
{
return (row * tilecols) + col;
}

private void positionXYFromIndex(int idx, ref Vector3 vSet)
{
vSet.X = fLeftX + colFromPos(idx)*gapX;
vSet.Y = fTopY + rowFromPos(idx)*gapY;
vSet.Z = 0.0f;
}

if ((newState.IsKeyDown(Keys.Right)) && (!oldState.IsKeyDown(Keys.Right)))
{
int row = rowFromPos(curSel);
int col = colFromPos(curSel);

col++;
if (col >= tilecols)
{
col = 0;
}

curSel = posFromRowCol(row, col);
positionXYFromIndex(curSel, ref selPosition);
moves++;
score--;
}
else if (oldState.IsKeyDown(Keys.Right))
{
}

if ((newState.IsKeyDown(Keys.Left)) && (!oldState.IsKeyDown(Keys.Left)))
{
int row = rowFromPos(curSel);
int col = colFromPos(curSel);

col--;
if (col < 0)
{
col = tilecols - 1;
}

curSel = posFromRowCol(row, col);
positionXYFromIndex(curSel, ref selPosition);
moves++;
score--;
}
else if (oldState.IsKeyDown(Keys.Left))
{
}

if ((newState.IsKeyDown(Keys.Up)) && (!oldState.IsKeyDown(Keys.Up)))
{
int row = rowFromPos(curSel);
int col = colFromPos(curSel);

row++;
if (row >= tilerows)
{
row = 0;
}

curSel = posFromRowCol(row, col);
positionXYFromIndex(curSel, ref selPosition);
moves++;
score--;
}
else if (oldState.IsKeyDown(Keys.Up))
{
}

if ((newState.IsKeyDown(Keys.Down)) && (!oldState.IsKeyDown(Keys.Down)))
{
int row = rowFromPos(curSel);
int col = colFromPos(curSel);

row--;
if (row < 0)
{
row = tilerows - 1;
}

curSel = posFromRowCol(row, col);
positionXYFromIndex(curSel, ref selPosition);
moves++;
score--;
}
else if (oldState.IsKeyDown(Keys.Down))
{
}

Sunday, February 1, 2009

XNA learning started

I am mentoring a group of students at Chapman in a game development contest to build a game around the U.N. Millennium goals. I'm having a ton of fun with it.(http://imaginecup.com/Competition/mycompetitionportal.aspx?competitionId=21).

That said, I don't have any code duties on that so to learn XNA I've been back to trying to write a game a week, this time using XNA instead of Java (http://www.woodsgoods.com/gaw). I don't think the quality will be there, but I'll try and post some screenshots and lessons learned moving forward.