Saturday, January 28, 2006

Hugo Goldforce

That's right more name generation. I'm writing up a couple of custom grammars right now I want to build a base of predefined grammars to pick from then I also have one grammar that outputs grammars to generate names - I've got a very crude version of this working already but typing the grammar out hurts my head a little. Reminds me of some of the stuff in Metamagical Themas.

The weeks goal though is regions - getting regions into the game. Currently regions exist in a different project and they work but I think they're too complicated. There's some listener response patterns that causes events to cascade. It passes the unit tests so no worries for now. That's all. Regions require names so that's where the grammars come into play. So I'm finishing off a few modules, creating some resources and then hammering it into my main build. Or that's the plan.

Tutorials


I think I'll be leaving the game programming for monkeys tutorials as they are. If I ever buy webspace then I'll upload more source code. (I currently use some very kindly donated webspace http://www.ravensmyst.com). The "tutorials" where mainly recording exactly what I did mistakes and all. I think that can be useful but I'd like there to be something more definite - so I'm rewriting the main points of the tutorials in Latex. From this I'll be able to generate webpages and pdfs etc. I just started doing this as something to rid the mind numbing boringness of sitting in the staffroom at work. I'm guessing it will take at least 3 months for a first draft to appear but hey, something to look forward to. Perhaps I'm out of date as the new SDKs probably start documenting the framework thing reasonably well probably making getting started much easier!

Friday, January 27, 2006

A Simple Latex Listings Definition for C#

I'm thinking of moving my tutorials into pdf format. I couldn't find a nice formatter for C# code in Latex so I wrote this definition in Listings. (I find Latex's mascot to be a little disturbing.)


\lstdefinelanguage{CSharp}
{
morecomment = [l]{//},
morecomment = [l]{///},
morecomment = [s]{/*}{*/},
morestring=[b]",
sensitive = true,
morekeywords = {abstract, event, new, struct,
as, explicit, null, switch,
base, extern, object, this,
bool, false, operator, throw,
break, finally, out, true,
byte, fixed, override, try,
case, float, params, typeof,
catch, for, private, uint,
char, foreach, protected, ulong,
checked, goto, public, unchecked,
class, if, readonly, unsafe,
const, implicit, ref, ushort,
continue, in, return, using,
decimal, int, sbyte, virtual,
default, interface, sealed, volatile,
delegate, internal, short, void,
do, is, sizeof, while,
double, lock, stackalloc,
else, long, static,
enum, namespace, string}
}


As I said pretty simple. Also look all those keywords! I'm embarrased to say I don't know some of them! Volatile? What's that? And stackalloc? I'll have to do some reading!

Saturday, January 21, 2006

Blood or Cream - why not use both?

I combined the mighty power of Amazon and mighty power of C-sharp and the less might power of blogger to create a "What am I reading now list". Why is bloggers power less mighty?, you might ask. Well currently there are two methods to access the blogger API, atom and XML-RPC (I vaguely remember the name from computer science but don't ask me what it stands for) and they both offer different functionality. Wonderbar. Also there's no way to republish the blog via the API, as far as I can, tell without creating a post and them promptly deleting it. Also the template must be in ASCII but this is mentioned in some far flung known issues page rather then the method docs. Any way using a bit of both I managed to get what I wanted.

What did I want?



I wanted to have a currently reading list on the front page of blogger. But I didn't want to always be editing the template and editing the html to edit it. It's a mundane task and that's what I hear computers are good at. So I fire up my shiny new application that lets me search amazon, then I choose the books I'm reading and press next. It shows me shows me some html, so I can add extra comments if I so fancy, and them with a button press it publishes it to my blog.

Anyway I've not done a proper update yet, so it may dissapoint some of you to know that I am in fact not reading Savages and Beasts: The Birth of the Modern Zoo by Nigel Rothfels. That was just a book I was using for testing.

But Dan what about your game?



Yes, today I've been a little distracted and tomorrow I'll be busy. But look yesterday I made a groovy generic data structure. Game-wise the bit I'm stuck on it planning really. I need to think through what I'm going to do before I start doing it.

Also 24 season 5 has started. Curse you Jack Bauer and your terrorist brutalizing ways.

Edit: Yes I obviously do need to make it add a few more line break tags in there...

Friday, January 20, 2006

The Oddment Table

I've only ever heard of oddment tables from one place - a Mr Ray Dillinger on the rec.games.roguelike.development group.. Here's the post in question.

Now I always thought this was pretty good idea but recently I decided it might be nice to implement it in a reusable fashion. First though let's quickly go-over what it is.

Basically it's a list and you ask for an item and recieve one at random. Each item has a different chance of being recieved, and this is called it's oddment. The item you pick remains in the list.

An easy way to think of this might be as a deck of cards. Shuffle the cards and pick the first card from the top. There are only two jokers in there. There are 56 non-joker cards and 2 joker cards. If you pick the top card you are unlikely to get the joker. A oddment table representing this situation would add each of the 56 non-joker cards with the oddment value of 56. Then you'd add the two jokers each with an oddment value of 2. It's that simple.

In a game, especially an RPG game, we might like to think of event cards or encounter cards. Let's say we had wilderness encounter deck, one might encounter rats quite commonly so we add rats with an oddment of 50 but a big box of treasure that's fallen off a cart is rather less likely, so we might put that in with an oddment of 1.

using System;

using System.Collections.Generic;

using System.Text;

using Debug = System.Diagnostics.Debug;

 

namespace EINFALL.Tools

{

    public class OddmentTable<T>

    {

        // Allows comparison of generic types.

        //See: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=193203&SiteID=1

        private static readonly IEqualityComparer<T> comparer =

            EqualityComparer<T>.Default;

        protected List<Entry> entries = new List<Entry>();

        protected int oddment = 0;

        protected Random random;

 

        /// <summary>

        /// Each item must be associated with it's oddment

        /// in the list. This simple structure does that

        /// for us.

        /// </summary>

        protected struct Entry

        {

            public T Item;

            public int Oddment;

 

            public Entry(T item, int oddment)

            {

                this.Oddment = oddment;

                this.Item = item;

            }

        }

 

        /// <summary>

        /// Create an Oddment table using a precreated

        /// Random object, that will be used to decide the picks.

        /// Useful for repeatable results.

        /// </summary>

        /// <param name="rand">The random object to use</param>

        public OddmentTable(Random rand)

        {

            random = rand;

        }

 

        /// <summary>

        /// Default constructor will seed a random

        /// number generator with the current ticktime.

        /// </summary>

        public OddmentTable()

        {

            random = new Random(System.Environment.TickCount);

        }

 

        /// <summary>

        /// Add an Item and it's Oddment (chance of being picked)

        /// </summary>

        /// <param name="Item">Whatever the Oddment table was intialized to.</param>

        /// <param name="Oddment">The Oddment is the likely hood of getting it.

        /// It should be a non-zero positive number</param>

        public void Add(T item, int oddment)

        {

            Debug.Assert(oddment > 0,

                "The oddment number passed in was" + oddment +

                "\r\nIt should be a positive non-zero integer");

 

            entries.Add(new Entry(item, oddment));

            this.oddment += oddment;

        }

 

        /// <summary>

        /// Randomly pick an Item from the table, where

        /// the items are weighted by their oddments.

        /// </summary>

        /// <returns>The picked Item</returns>

        public T Pick()

        {

            int pickNo = random.Next(oddment);

 

            /// I want to go from 1 to n, not 0 to n - 1

            /// Odds of 0 shouldn't count for anything, in my mind anyway.

            pickNo++;

 

            // This will record the total of the oddments as

            // we tranverse through the table.

            int oddmentTotal = 0;

 

            // Run through the table, total up each Oddment

            // if the Oddment total is bigger than the pick number

            // then return that Item

            foreach (Entry entry in entries)

            {

                oddmentTotal += entry.Oddment;

 

                if (oddmentTotal >= pickNo)

                    return entry.Item;

            }

 

            return entries[entries.Count].Item;

        }

 

        /// <summary>

        /// Gets the number of elements contained in the Oddment table

        /// </summary>

        public int Count

        {

            get

            {

                return entries.Count;

            }

        }

 

        /// <summary>

        /// Remove the first instance of an item from the oddment table.

        /// </summary>

        /// <param name="item"></param>

        public void Remove(T item)

        {

            int i = 0;

 

            // Search through the enteries

            // until we get one with the same name.

            // There maybe a faster way to do this but I don't know how

            for (int j = 0; j < entries.Count; j++)

            {

                if (comparer.Equals(entries[j].Item, item))

                {

                    i = j;

                }

                else

                {

                    if (i == j)

                    {

                        //Remove nothing.

                        //Possibly better to throw exception.

                        return;

                    }

                }

            }

 

            int oldOddment = entries[i].Oddment;

            entries.RemoveAt(i);

            oddment -= oldOddment;

        }

 

 

 

    }

}

Thursday, January 19, 2006

No time passes, or some does.

This weekend, provided I carve myself some big fleshy chunks of time, I'll be adding a quad tree to the maps, a very very basic quad tree but one that will allow me to have lots of stuff moving at once without collision code becoming sluggish. I'll also be adding metadata to the maps. I got one level of this done today pretty much.

After this is done, the next step is tieing the metadata into the map creation algorimth.

Future:

I'm looking at the Masters Computer Games Programming Course in Hull and the one in Teeside. If there are others I'll apply there too. I'll be back in England for August - and I'm informed it's fine to apply at this time. So anyone else who's thinking of doing these courses, well I may be joining you.

I have no idea which is the "best", Teeside seems to be the highest requirements but I've always been told it's a bit of dump and more of a money making excerise than a University. But it appears I may have been misinformed.

Also I've been poking at the blogger API a tiny bit. I may knock up a program this weekend that will allow me to keep at "Currently Reading" list going which would be nice.

And thats it, nothing too great happening.

Saturday, January 14, 2006

Please share your happy with me

Turns out the problem with blocking was rather tricky ... strange seeing as I had forced it to work earlier - which probably meant an ugly hack.

There was a function that wasn't working correctly for boundary conditions.

It was a function that from some point in directx space it should return the index of a tile in an array, that's formatted in a nice grid on the screen. (i.e. a map). Due to the nature of my program, the map might start anywhere in space, so it's not aligned to an nice origin of 0,0 for instance.

It's fixed now, which means I can work my way back up to the blocking problem - which probably would be spontaneously fixed too ... but I ripped out all the code and scattered it liberally through several text files - yay me.

Okay blocking seems to be basically back in. That's nice. At some point I also managed to break fullscreen mode. So that's potentially back on the list of todos as well.



Unit test-tastic. The yellow light means I haven't written the innards to the test. Also I've only put old code in unit tests if it was causing me trouble. 58 tests taking a whopping 1.8 seconds to run.

Friday, January 13, 2006

Do you know your precise position in the universe right now?

This weekends goal is killing off the blocking bug. Blocking works in one corner of the map but not the other. Something odd's going on.

At school I've been doing a little programming on one of the more exiting parts of my game. There's lots of Lua C# itermingliztion. It's quite fun but there's a chunk of code that's missing before it's complete.

Also I need to put regions into my game before it will work at all. Regions will allow you to know when you're in cities and that sort of thing. I want them to be any size and quite flexible. So I can use them to mark a pressure trap and the inside of a house for instance. To do this efficently means, at the very least, a quad tree. Fun fun. I'm hoping to get quite far this weekend. It shouldn't be too long before I get some nice screen shots but for that I need nice art ... :(

Thursday, January 05, 2006

My Favouritest Games

I got this idea from Terry Cavanagh's website, Distractionware. With the bugs gone from my game, for the moment, I felt it was a good time to reminisce before introducing new ones. Here are are some of games that have influenced me. In reverse order of awesome-superness.


10. Bubble Bobble.



This game is quite simple but one of my favourites. It's best played with a friend. You play Bub or Bob two dragons that for some mysterious reason are descending to the bottom of a volcano or something. Each level is one screen wide and filled with a number of enemies. Each of you can breath bubbles - these can capture enemies and you can also jump on them. (Each time a bubble bursts it's 10 points). Once an enemy is in a bubble you jump on him and he dies and turns into fruit. If you pop a lot of enemies at the same time - you get better fruit (sometimes gems and other random items - that give you points! We all love points!). If you do really well - at the end of the level a massive piece of fruit (or gem or cake or whatever) drops down and you must rush to grab it before player2 gets it. And that's the key thing about Bubble and Bobble on the one hand you're cooperating but on the other hand you're in fierce, bloody, competition with each other for the bonuses, higher scores and pieces of fruit, and cake! It's a mechanic that's also in other games but I’ve never experienced it so intensely as in Bubble Bobble.

9. Privateer



Privateer basically copied Elite but it had better graphics and better missions and a plot thrown in there too. I loved it because you could go and do anything but it didn't ever feel empty or impossible. I enjoyed being a pirate or a smuggler having to deal with the police ships and inspections. The main mechanic was to keep making money so you could upgrade your space ship with cool new weapons - or even buy a whole new ship! It had the same space combat system as Wing Commander, tried and tested - a lot of fun. A great game.

8. Super Mario World



Super Mario’s strongest feature is the interface. It's something that's been tweaked to perfection. Very addictive basic game play but there's still a lot of hidden things to discover. A game that shines with polish.

7. Master Of Orion



It was going to be this or Master of Magic but I think Master of Orion is just a little bit better. A wonderful, solid strategy game, choose a race and try to take over the galaxy. There's technology to reserch and you can even design your own ships. My personal favourite ploy was to create a really cheap small ship with a single nuclear missle - usually I could build a few 100 a turn. Then I'd make a massive stack so I'd have thousands and thousands of these one missle ships. They packed a massive punch even though an enemies lazer cannons could dessimate hundreds of them. You could also spy, conquer planets, even board ships. You also got to decide what buildings where built on your planets. A very absorbing game.

6. Final Fantasy 7



When I heard this was coming out on Playstation I replayed all the old Final Fantasies on the emulators not understanding that they didn't really follow on. Still this was an amazing game, which really sucked you in. Sephiroth is possibly the coolest bad guy from any RPG. The plot barely made sense but was still attractive - I couldn’t help but hope that at some point, near the end, everything was going to be clearly explained with plenty of flash backs and I’d find myself saying “Ohhhhh now I see”, unfortunately this wasn’t to be. The music and CGI videos were unbelievable for the time, what’s more unbelievable still is that they were used extremely well and always added to the game and didn’t become wearisome. It was a game on a new kind of scale, epic.

5. Monkey Island



I really do wish they still made adventure games. Adventure games, though single player really lend themselves to being played with more than one person as everyone can contribute. Monkey Island was great, funny and very engaging to play. You played a rather rubbish pirate who's out to make his fortune. There are the undead, monkeys, sword fighting, spitting, grog, excellent music and extremely good puzzles. I'll always remember watching the credits right to the end (which where also very humorous).

4. System Shock 2



System Shock 1 was good but it took a leap in graphics to do what system shock 2 does best ... shock you (though I admit jumping many times playing the first)! The game is a little like Ultima Underworld set in space, but instead of being trapped in a mammoth dungeon you're trapped in a mammoth space station. Nearly everyone's dead - you're on your own - you have to discover what happened. A great set up for a game. You can read people’s logs files, pick locks, bash things with pipes. There's loads of different ammo, items, computers to hack, mind powers and when you find out you’re not alone you will jump. The atmosphere is creepy, the place is deserted so when automated holographic records come on – you’re given a near heart attack. Exploring the station itself is cool, parts are locked and you pass lots of areas inaccessible until much later - it almost teases you with them. "Look! Look! There's a lift button for the research deck! I bet there's loads of cool weaponry there! But it seems the lift is broken oh well!"

3. Ultima Seven Part Two


Another incredible game from Origin - any game where you can kill a dog, takes it's corpse to the crematorium, cremate it and then put the ashes on your mantel piece - deserves to be in anyone’s top ten. The game was wonderful but perhaps more importantly was the world that the game was set in. It was a living world; people went to work, ate and slept. They lit candles, shut doors, muttered and complained. It was great. There were wagons, flying carpets, boats, dungeons, crates full of dried fish, cities with different currencies and a paperdoll system that allowed you to dress you male party members in drag. Now that's a game.

One of the great joys of Ultima Seven is taking a house. This usually involves killing the owner (if you pick someone important this tended to break the game later on :( ). Then you'd stock the house with crates that you'd lugged in from various cities – to store your shiny magic trinkets and treasure. Also you could cast a spell that made automons - robot like creature. They would make your bed, open and shut the windows and do other wonderful stuff like that. One final thing about Ultima is that the plot line is quite mature; almost unlike any RPG today, moral choices aren't clear cut. Wonderful stuff.

2. Doom



There's not much that needs saying here. I guess this appeals to me most because I had access to local area network. Doom was a wonderful game to play both cooperatively and in deathmatch mode. It's a shame cooperative play seems to have fallen out of favour in recent games. The bosses where wonderful and it was delightful to see what new hell spawn would pop up next.

1. Ultima Underworld



For some crazy reason not many people seemed to have played this game but it's brilliance through and through. You're trapped in a gigantic dungeon and you must escape. It was released before Doom but had a much more complicated 3D environment. An early demo of this game inspired John Carmack to write Wolfenstein 3D. The dungeon, itself, is full of traps, monsters, hidden areas, weapons and armour. Exploring all of it, as you worked your way down, was extremely enjoyable. In the best Castlevania / Metroid stylings there was plenty that was initially inaccessible but later something deeper in the dungeon would grant you access (the levitation spell for instance.) Of course it was so much more than Metroid or Castlevania, it felt more like a living world. There were NPCs to interact with and perform quests for, a groovy spell system that had you hunting around for rune stones and trying to guess spells, a paper doll system allowing you to mix and match armour and a solid combat engine. Truly a land mark RPG that nothing has really approached since. (That said, Ultima Underworld Two was very good as was System Shock)


Notable Mentions: Fallout, Thief, Morrowind, Daggerfall, Dune, Dune II, Deus Ex, Sonic, Shining Force Two, Front Mission, ADOM, the first two years of Ultima Online, X-com, Eye of the Beholder Two, Lands of Lore, Day of the Tentacle, Final Fantasy Tactics, Vagrant Story, Colonization.

Eat your banana with care and dispose of the peel correctly.

Wonderbar. I've just killed my awful crashing bug - totally by accident.

Yesterday afternoon I became side tracked. The goal previously was 5. fix blocking (which I thought I'd done but it now seems I've merely done it for only one case *groan* why am I writing something so complicated?). 6. Stable Map Transfer 7.Crashing)

Well six and seven looked like far too much hard work. I was scouring my code looking for likely gotchas when I decided parts of it needed cleaning. So I've broken down some classes. Also I decided that I needed to implemented the new rendering function that I've had rendering around. I've been doing this all morning because the rendering code is reasonable complicated. I was also adding lots of unit tests as I went. I decided to refactor something with the strategy pattern as I had a bulkly class doing far too much - it's still pretty big and I noticed where all my problems had been coming from.

Basically I was recursing to an entire function when I merely wanted to rerun the very end part. So I seperated the very end part out into it's own function and this bypassed some camera-updating code - stopping the camera behaving crazily.

Reading through this it must sound like my codes an awful nasty ball of string. It's not that bad :D But I'm in the process of moving lots of it around to make it nicer to work with. Anyhoo my two major problems preventing me from starting stage three are now complete.

1. The nasty graphics bug I was having
2. Problems moving my player from one map to another.

Yay! Happy :D

I was only suppose to program to 12 today, then I was going to study but I'm going to finish this up.

A word on tutorials

I know there's been a bit of a drought. I'll probably start back up when I return to school and must sit at my desk with nothing to do :D Most of the tutorials still need updating for the latest DirectX versions and that's what I'll do first. Slowly, very slowly but regularly. If the third tutorial isn't updated by the 13th please chastize me. (Also I'm thinking of breaking out Latex and writing them in an expanded - larger number of pictures format and then make the pdf avaliable.)


Tags:
|

Tuesday, January 03, 2006

A four armed lover.

I've been cleaning the code and killing off bugs this morning.
It's painfully slow work but I feel like my pace has improved.

The first bug meant sometimes people could be rendered twice all over the place. I hadn't even noticed this potential problem until I started routing through the code. I was looking to solve a problem where changing maps caused the image to flicker. This was a real basic problem that should never have been.

All games with intelligent actors should generally have two loops per game frame.

1. Process All the Actors (movement, death ..)
2. Render

For some reason that I don't understand, I had at some point decided these where best together

1. Process+Render

So I had two maps.
The first I processed and rendered.
Then I processed the second map - here a character moved a went into the first map.
Result - character wasn't rendered for a frame.

Very simple very stupid.

So that's fix. The second problem I'm working on now is the camera that messes up after crossing too many map boundaries. Once this use to work. I've love to trap it down with unit tests but currently the codes too muddled and requires too many extra classes - it's something I'll work on uncoupling.


Tags:
| |

Monday, January 02, 2006

No motivation

I've started my chunk of free time now but am totally unmotivated.
Today I've fixed up a few bugs but that's it.

Possibily I'm still suffering the pain of jet-lag, I never suffered this bad before. I think the day in Tokyo followed by the overnight bus to Toyama was the real killer. This morning I was up at four but it's better than the previous day were I tried to go to sleep at 12 but never actually managed to go to sleep at all.

I have lots of interesting books to read at the moment - a few software ones (code complete and others I'll give my opinions on them as I read them.)

I'm also worrying about this summer. I've decided to end my contract and I don't know what to do afterwards. I'm considering more university or employment. If someone reading works for a nice game company and is looking to hire some bright young chap - I'm all ears. Location isn't an issue to me really.

So I'm looking for a new rush of inspiration.