Saturday, March 29, 2008

Converting XNA PlayerIndex to string and int

It might be obvious, but I needed it today for the networking stuff to pass player data around. I wanted to convert the current Playerindex to a string or int and vice versa.:


PlayerIndex pix = PlayerIndex.Two;
string ps = pix.ToString(); // "Two"
int pi = (int)pix; // 1
pix = (PlayerIndex) Enum.Parse(typeof (PlayerIndex), "Three");
ps = pix.ToString(); // "Three"
pi = (int) pix; // 2
pi = 0;
pix = (PlayerIndex) pi;// "One"


Friday, March 28, 2008

XNA Randy and Lindgren Networking lib

Inspired from two articles I found on ZiggyWare I wrote this short Network sample.
It uses a tile map of Randy and he Lidgren Network library.



Download it from here (link updated on March 29th)

You find the initial articles here:
Moving A Sprite In A Tile Map:
http://www.kersson.com/articles/article.aspx?ar=42
Lidgren, A Safe alternative to using XNA's Networking:
http://www.ziggyware.com/readarticle.php?article_id=168

You should start the application 2 times.

Press H or S to be the Host
Press C to act as a client

Move Randy around by using the cursor keys.

Depending on which application has focus you will move Randy around and in the other application you will see the Network Randy moving around.

Wednesday, March 26, 2008

.NETDJ Article Online

My first article about the XNA Car Cup game is now online.

Read more here: PDF

Sunday, March 16, 2008

Simple XNA Walking Man Animation includes 2D Shadow

A small update to my walking man:
It contains now a 2D shadow for the guy....



Source:

Simple XNA Walking Man Animation

My daughter wanted to see a man walking on the screen. You can see the outcome below.
Special thanks to Gary Darby, Intellitech Systems Inc., who posted a few years ago some Pascal source and the images.....

The amount, the size as well as the speed of the runners is configurable. Enjoy!



Source:

http://hamboeck.googlepages.com/XNAWalkingManAnimation.zip

Saturday, March 15, 2008

Animated Starry Background

As my wife was out with the kids I played around with the VertexPositionColor class and the DrawUserPrimitives in XNA. The outcome is this sample of a starry background where the stars change the color on a random basis.

The image does not really show how cool it really looks like :(


Source Code:
http://hamboeck.googlepages.com/XNAStarBackground.zip

Thursday, March 13, 2008

Marco Monster's Car Physics Demo in XNA

Today I had a little bit of time and I found a very nice (work/learning wise not really graphics wise) little demo about a small car, which one can drive around and all the interesting values when it comes to in game physics and a fast driving car are shown on the screen.

It was written a while ago in C++ and uses Allegro. I thought it would be nice to have a XNA version. I do not know if this is already available or not, maybe the geeks have this already for a while. If you do not have it please feel free to play around with it.

BTW, I have finished my second article for the DNDJ about my XNA Car Cup Simple racing game already, but this might be something for part 3 ;)

People aready start pushing me, but it is done when it is done :))
So stay tuned, there is much more to come. If you have any ideas or wishes, let me know!!



It is still slow, far from beeing perfect, but I am too tired today to look into it again, but I bet you get the idea and there will be an updated version soon....

UPDATE: I uploaded a newer version today, I replaced the drawing method for the lines, I am using the PrimitiveBatch class from the creats.xna.com web site, which makes it much faster.

The keyboard keys used:
Escape ................................. Exit
F12 ...................................... Reset
Up/Down/Left/Right ....... Drive the car around
Q/W .................................... Zoom in/Zoom out
R/F/Space ......................... Slip around (Rear, Front, Both)

Source code:
http://hamboeck.googlepages.com/XNACardemo.zip

Tuesday, March 11, 2008

XNA Car Cup Article for DNDJ Part1

A while ago I bought my XBOX360 elite. As a C# freak I quickly jumped on the XNA Game Studio train. The first outcome of this is a game development series for the DNDJ where I explain some parts I developed for the XNA Car Cup game. The first part is going to be printed this month, below you can find the full source code for VS2005 Prof. and XNA 2.0.

Source code for part1:
http://hamboeck.googlepages.com/XNACarCupSimplePart1.zip

CSharpCodeFormatter