Archive for the ‘ Game Development ’ Category

A day of updates…

WordPress Update to 2.8, atahualpa update to 3.3.3 and the best one XNA update to 3.1 Avatars and Video :-D

Also we are now working on “Xbox LIVE Indie Games” it’s better that “Xbox LIVE Community Games” but the sooner they drop the LIVE thing the better we’ll all be.

Any-who off to bed now it’s my last day at this job tomorrow :-)

Bank Holiday XNA Project

This weekend I thought I’d try making a complete game. The quickest way to do this was to use one of the starter kits and tweak it up. I picked the Platformer Starter Kit that comes with XNA 3.0. There’s lots missing from the starter kit this is just a short list of things I want to add in :-

  • A menu system
  • More levels using all the enemies
  • lives
  • better scoring
  • a high score table
  • power ups
  • scrolling levels
  • hazards
  • shooting enemies
  • enemies with different abilities

It’s rather a long list and one I could keep adding to that’s the whole point of the starter kit it’s just to get you started.  I’ve also started writing a how-to guide to accompany the game which has slowed progress a bit, but I’ve started writing XNA code again so that can only be a good thing, more soon ;-)

FloatUnion.approxSqrt By Frank Savage (Development Manager – XNA Tools Team)

I was listening to the GDC09 talks and Mr Savage did his performance talk he mentioned a FloatUnion struct for approximate square root, but I could never find it until now…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using System.Runtime.InteropServices;
 
[StructLayout(LayoutKind.Explicit)]
public struct FloatUnion
{
	[FieldOffset(0)]
	public float x;
 
	[FieldOffset(0)]
	public int n;
 
	public float approxSqrt()
	{
		n -= 1 << 23;
		n = n >> 1;
		n += 1 << 29;
		return x;
	}
}

This was more for me, but it’s here if you ever need it :-)

I’ll answer my own question shall I?

Last night I asked this question on Twitter :-

#xna #Csharp Question – Anyone know if bit shifting is still faster than multiply/divide in .NET? E.G. (y<<8)+(y<<6) is faster than (y*320)

But no one answered :-( . So I wrote this quick test.

using System;
 
namespace Multiply_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            int c;
 
            Console.Write("Test 1 - ");
            DateTime StartTimeTest1 = DateTime.Now;
            for (int y = 0; y &lt; int.MaxValue; y++)
                c = (y / 2);
            DateTime EndTimeTest1 = DateTime.Now;
 
            TimeSpan taken1 = new TimeSpan((EndTimeTest1.Subtract(StartTimeTest1)).Ticks);
            Console.WriteLine(string.Format("{0} Seconds",taken1.TotalSeconds));
 
            Console.Write("Test 2 - ");
            DateTime StartTimeTest2 = DateTime.Now;
            for (int y = 0; y &lt; int.MaxValue; y++)
                c = (y &gt;&gt; 1);
            DateTime EndTimeTest2 = DateTime.Now;
 
            TimeSpan taken2 = new TimeSpan((EndTimeTest2.Subtract(StartTimeTest2)).Ticks);
            Console.WriteLine(string.Format("{0} Seconds",taken2.TotalSeconds));
 
            Console.WriteLine("\n\nPress Any Key...");
            Console.ReadKey(true);
        }
    }
}

And this was the result :-

Multiply Test Results

Multiply Test Results

Yep still faster.

Finaly some XNA.

OK I was doing my usual potter around the net tonight when I found “Draw Horizontally Centered Text in XNA” and thought I have to tweak this…

///
/// Take a string and draw it centered horizontally on the screen.
///
public static void DrawCentered(String myText, int ScreenWidth, int yPosition, Color drawColor, SpriteFont spriteFont, SpriteBatch spriteBatch)
{
    // Get the size the spritefont will be drawn on the screen.
    Vector2 textSize = spriteFont.MeasureString(myText);
 
    // Get the position we need to draw the text at for it to be centered.
    int centerXPosition = (ScreenWidth / 2) - ((int)textSize.X / 2);
 
    // Draw the centered text.
    spriteBatch.DrawString(spriteFont, myText, new Vector2(centerXPosition, yPosition), drawColor);
}

I hate passing parameters i don’t need and you should strive to avoid magic numbers so I moved the int ScreenWidth to be a local variable and pulled the required value in from the SpriteBatch with the following line :-

            // pick up the screen width.
            int ScreenWidth = spriteBatch.GraphicsDevice.Viewport.Width;

And as a sort of old school codey kick removed the division from the int centerXPosition calculation and replaced it with some bit shifts to bring us to

            // Get the position we need to draw the text at for it to be centered.
            int centerXPosition = (ScreenWidth &gt;&gt; 1) - ((int)textSize.X &gt;&gt; 1);

so in all my replacement method is :-

        ///
        /// Take a string and draw it centered horizontally on the screen.
        ///
        public static void DrawCentered(String myText, int yPosition, Color drawColor, SpriteFont spriteFont, SpriteBatch spriteBatch)
        {
            // pick up the screen width.
            int ScreenWidth = spriteBatch.GraphicsDevice.Viewport.Width;
 
            // Get the size the spritefont will be drawn on the screen.
            Vector2 textSize = spriteFont.MeasureString(myText);
 
            // Get the position we need to draw the text at for it to be centered.
            int centerXPosition = (ScreenWidth &gt;&gt; 1) - ((int)textSize.X &gt;&gt; 1);
 
            // Draw the centered text.
            spriteBatch.DrawString(spriteFont, myText, new Vector2(centerXPosition, yPosition), drawColor);
        }

Have fun with that, and thanks to Kris Steele for the original article ;-)

Someone stole my game idea!


Hot New Video Game Consists Solely Of Shooting People Point-Blank In The Face

Tutorials, Dodge v1.02 & L4D.

I’ve not transfered the Tutorials over from Xblog.org, and added the Dodge v1.02 page to projects.

Now I need to get on with some work on the editor. The only problem I have at the moment is I seem to keep playing “Left 4 Dead” which is counter productive, to the extreme.

Also webbers Xbox has developed tRRoD, so now he has to give me all his games, but he wont.

No really I’m still alive

Well looks like I did manage to fail on the regular posting thing.

I’ve been working on the game engine just not how I thought I would. I’ve started working towards a slight adjustment on the Bert plan, Instead of the original story we used for Bert I’m going for a Zombie Survival Game. I did a quick-ish Zombie Infection Simulator based on Kevan Davis’ Original Java script.

zombieinfectionsim-001For my version I used SystemX as a base and added a modified version of Chase & Evade from the Creators Club Online, and O.M.G. the logic SUCKS! it’s so slow that with 1000 objects the system starts off at 2fps and scales up to around 20fps when the zombie:Human ratio levels out but then slows back to 2fps as the zombies become dominant.

I’ve thought about a few things I can do to speed up the entity’s AI, it’s going to have to wait until I have the map and collision system in place.

I’ve also been researching how the game play is going to work and found some amazing Games almost all flash based but still bloody good, from Sean Cooper’s Boxhead games to Dead Frontier my main problem is how I’m going to make my game stand out from the crowd? the fact that they will be on Xbox360 and PC probably isn’t going to be enough seeing as there are a great number of games covering this genre as it is. I think I’m going to have to aim for a simple Run & Gun style for the first outing and then try to add in more details as we go.

To start with I want to keep it PC only until I get the game closer to finished and then post it up to Creators.

One down Ninety nine to go…

This weekend I went and saw some films, so again, I didn’t get much done.

But, I did finish the Sprite sheet Compiler v1.00. This is the first developer only utility going forward to the full Game developer suite for SystemX this one builds the sprite sheet and compiles it for the game engine to load.

**REMEMBER** This is a developer only tool, it will only work if you have MSBuild and XNA developer suite installed. **REMEMBER**

The next thing I want to work on is the workspace compiler this is the thing that defines a project for the game engine, where the content directory is, want are the sprite sheets, fonts, menus, and the start-up script.

There is still so much to do before I can go public, as yet I still don’t have anything worth a screen shot, and my progress is still slow, mostly from only working no this project Friday, Sunday and Monday night. my plan for working on one small project at a time seems to be holding for now at least. I’m coming up on one month in the new blog space and I’ve managed to keep to my target rate of one good sized post a week, go me!

Better late than never

I’ve been trying to write this post for the past four days and keep getting side tracked. I managed to get the sprite sheet compiler to run successfully this weekend, and produced an xnb file.

The next thing is to reload that xnb file back into the editor so that I can start on the animation system editor, but I think that I’ll probably get the Workspace class to compile as well first.

With the workspace class compiling I can probably add a preview option where the editor can shell out and run the game engine, I’m still not sure how publishing to the Xbox360 will work if I’m compiling the content outside VS, this needs looking at when I get a 360.