29 March 2007

So, Rein and I decided to have a little compo. To learn DirectX and make something cool. The first thing I've been able to come up with is a remake of an old game that used to go by the name of 'VGA planets', not the VGA planets, mind you. With such a name, it's just not possible to find in amongst the birdmen and the borg ( I think they've assimilated the original).

Spec:

We have a bunch of planets which remain stationary, players' space ships which are fitted with inertial drives which can be turned off. A ship has fuel and a gun. The gun fires a round that is influenced by the gravity of the planets. The goal is to fire a round that hits your opponent. Probably turn based unless I can figure out a good way to balance timing of firing and try to stop dodging.

Features

Based on my initial thinking I'd like to include these features:
  • bump-mapped planets
  • point sprites spinning into the active player
  • glowy bullets
  • tracers
  • asteroids floating in and around the space
  • side-scroller-esque (or ala crimson land) power ups
  • a pong mode (bounce shields around planets)
  • did I mention glowy bullets
  • maybe some different guns
  • and npcs to feast on
  • landing on planetary bases/docking with orbiting stations for bonuses is hard but rewarding
  • teleport uses a full tank of fuel
  • network play
  • zooming battle field
  • visual of each players ship at full zoom in the corners

Physics

Draw grid for gravity, green standard, bending in and getting darker, and bending out and getting yellower for anti-grav. Tilt-based thrust, optional gyro for stabilising; a gyro should align you to the field at that point.
  • elastic physics - springs and things
  • tilt to steer physics

Posted on Thursday, March 29, 2007 by Unknown

No comments

26 March 2007

So, I had a plane trip ahead of me, and I wanted to be able to use .net StringBuilder with operators, below is the bstring class I wrote to do this. It's pretty straightforward, except the * operator behaves like python's and additionally is faster than a looped StringBuilder because of the pre-calculation (and allocation) of capacity. Still trivial, but it makes the StringBuilder useful without having to remember its syntax.

In testing it (obviously) beat the string class and also was indistinguishable from the StringBuilder in all but the * operator, in which case it was faster.

    class bstring
    {
        private string _tstring;
        private StringBuilder _string;
        public StringBuilder Builder
        {
            get
            {
                if (this._string != null) return this._string;
                else
                {
                    this._string = new StringBuilder(_tstring);
                    return this._string;
                }
            }
        }
        public bstring(string value)
        {
            _tstring = value;
        }

        public int Length
        {
            get { return Builder.Length; }
        }

        

        public static bstring operator + (bstring stringA, bstring stringB)
        {
            stringA.Builder.Append(stringB);
            return stringA;
        }

        public static bstring operator +(bstring stringA, string stringB)
        {
            stringA.Builder.Append(stringB);
            return stringA;
        }

        public static bstring operator *(bstring stringA, int howMany)
        {
            if (stringA.Builder.Capacity < stringA.Length * howMany)
                stringA.Builder.Capacity = stringA.Length * howMany;
            string tstring = stringA.ToString();
            for (int i = 0; i < howMany - 1; i++)
                stringA.Builder.Append(tstring);
            return stringA;
        }


        public override string ToString()
        {
            if (this._string != null) return _string.ToString();
            else return _tstring;
        }
    }

And here's the body of the test class: in the current state it compares a += loop to the * operator:

        static void Main(string[] args)
        {
            bstring bob;
            //bstring joe = new bstring("I am joe. ");
            string bobs = "I am bob. ";
            //string joe = "I am joe";
            int tick = 0;
            int iter = 1000000;
            Console.WriteLine("bstring +");
            tick = Environment.TickCount;
            for (int j = 0; j < 100; j++ )
            {
                bob = new bstring("I am bob. ");

                for (int i = 0; i < iter - 1; i++)
                    bob += bobs;
            }
            Console.WriteLine(Environment.TickCount - tick);
            Console.WriteLine("bstring *");
            tick = Environment.TickCount;
            for (int j = 0; j < 100; j++)
            {
                bob = new bstring("I am bob. ");
                bob = bob * iter;
            }
            Console.WriteLine(Environment.TickCount - tick);
            Console.ReadLine();
        }

and the output, showing approx 50% speed increase from pre-allocation on 100 runs of a 1 million part string:

bstring +
13657
bstring *
7062

Posted on Monday, March 26, 2007 by Unknown

No comments