Monday, November 28, 2005

Japanese for the angry

It suddenly appears that I have been accepted for the Japanese proficency exam! I've not studyed! It's this weekend! There's lots to learn (;_;).

Expect no updates until after the weekend.

On a plus note I finshed nanowrimo but not my story. That too will have to wait until after this weekend.

Saturday, November 26, 2005

The devil has a mustache.


A screen shot of the first part of my conversation engine


It's the first part of my conversation engine! (click for full size) Isn't it nice. Currently it's working but I have managed to find a few bugs already. For some reason one person can happily carry on a two person conversation by themselves. I'm not quite sure how this is happening yet so I'll have to look into it.

Once again this weekend I don't have much time. Just this morning really. I managed to polish off another todo list item last night but I still have near a page left. Only two items on the page are for my goal of two weeks ago though ... the rest are fresh new bugs that I seem to have introduced or merely discovered more thouroughly. It may sound like I'm sinking in a helpless bog but I think things are actually getting better.

So yes the goals are finish up the Conversation Engine, so it doesn't have that bug. It also has crashed on the three person script but I think in that case it's a problem of not handling a malformed script gracefully.

(Of course I'm fixing these bugs by first writing failing unit tests.)

After that the current goals are:

1. Have loading and saving turns (I'm sure I knew what I meant when I wrote this ... I need to check out the code though)
2. Reproduce a texturing bug in a simplified bug so I can ask for help killing it.

Should be doable.

If you're interested in programming languages you should check out Subtext. It has an excellent flash video (how often do read that phrase, I usually loathe flash, but it's helpful here.) I think the ideas presented are pretty sound. A lot seems so obvious when it's explain that's it's a wonder such ideas haven't become popular before. Anyway check it out.

Aen's blog continues his incredibly rapidly developing tile editor. I can't believe he progresses so fast! The editor looks really cool. I really hope it revitalizes the Verge community a bit - I want more Inide RPGS! I want the days of Megazeux and ZZT to return for the Indie RPG scene!


Over on distractionware I was pointed to a very interesting "game" Rameses ( executable link ). It isn't all that interactive but it will give you a strange sensation. It's extremely well written and worth playing, to try something new. It's also small and short, I finished it at work :D

That's it really. I'm nearing the end of nanowrimo but didn't write anything yesterday or today. I'd quite to finish so I'll probably go into crunch mode monday. I'm going to leave it then and maybe revise it in a month or so.

Friday, November 25, 2005

RAD

I was messing about in windows forms creating a GUI front end for my conversation class (so I can test it visually in real time to make it is really working) - everything's a little bit cooler in VS2005. The form creation has auto align bars - even better than that there seems to be support for .... AUTO-COMPELETION how cool is that? My grammar language could do with a nice bit of that.

There are also various other grovy things and the buttons look a bit different too - who can argue.

Tuesday, November 22, 2005

Dll problems

I wanted to do something really simple tonight - just update a .dll file.

It's really given me the run around though, it kept using the old dll that it magic'ed up from somewhere. Eventually I was forced to include the dll parent project as a sub project of my main programs solution. This suddenly allowed everything to work. I don't know where I was going wrong but gah. At least it's better now.

Tomorrow is a bank holiday but I'm still going to be teaching (>_<) also I have social commitments so I don't know how much time I'll have to work on my program.

The conversation engine is complete but needs a little stress testing to make sure it can handle everything. My unit testing ablitity failed me on the final larger structures :o. So I'm not as confident as with the lower structures.

Monday, November 21, 2005

Recently

I've been building up my conversation engine that required a non-recursive permutation function ... I really didn't want to think how to make this work, luckily it's well documented on the net so I grabbed an algorithm written in C. It could work better but I think works well enough for the time being. I got another class unit tested and pretty much finished and started work on a controller class to tie all my classes together.

The only problem I have is that the Controller class requires classes from my game and I want to keep it modular and seperate from my game. I came up with the following crappy solution.

It uses a interface called ITalker implement get and sets for AreYouInAConversation? and that's about it (all that my conversation controller really needs to know). Which would be fine. . .


... but I want to be able to check things like "Are you near a lamp post?"

So this involves a messy cast that happens outside of my class. I pass the ask talker to Lua, Lua asks some other class to try and cast it to a GameObject for GameX. Then lua can use it's various loaded query functions.

Apart from that messy part of the architecture things are okay.

Today I'm playing with my scroll bar once more, it's one of the things I want complete before I move to state two. Currently it displays fine and can be resized. If you hold down the arrow the thumb zooms as fast as it can to the arrow ... far far too fast. I need a timer ... if I was thinking I'd probably have used windows timer but instead I actually have my own in it's own dll.

I don't want my GUI system to require any other dlls, so I broke it into two parts, the GUI pieces that require a clock function and those that don't. This too seems to be a messy decision :(

(The "mouse-feel" is now so much better)

I need to get break as I've managed to sort out plenty of real life stuff today.

*Scroll bar is totally finished - functionality wise any way. It needs prettying up as I use a tutorial with rather unfriendly names (caps differences in variable names *shudder*). It could also do with a few events to make it useful. I'm thinking OnMouseOverScrollButton, OnMouseOverTrack, OnMouseOverThumb, OnValueChanged. This way I can add fancy graphics and the like - a little pointy hand over the button for instance.

I'm actually a little behind where I wanted to be code wise but at least I've knocked one thing off the to-do list.

Saturday, November 19, 2005

More Unit Testing Fun.

I'm really impressed with unit testing. If you think of your program like a building, the unit tests are the scaffolding. I'd used similar stuff before but then I'd throw the small tests away. Bite size pieces of code to make sure everything was working. With unit tests each test confirms that you're code's working and going the way you want to it to.

Anyway I was so impressed I decided to sign up to the nunit mailing list and see what useful tit-bits I could glean.

I'm working on quite a tricky library at the moment and trying to make it modular - at least for now (if it's too hard, or there are too many casts later - I'll merge it).

I'm working tomorrow :( So no game programming. I'm hoping on monday I finally be able to finish off stage two. It's a lot of code but I'm optimistic. I'm also tempted to start making some of my code unit tested but I think I'll resist such a urge for now.

Wednesday, November 16, 2005

Behold the template


using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;

namespace $rootnamespace$
{
[TestFixture]
public class $safeitemname$
{
[TestFixtureSetUp]
public void DoTestSetup()
{
Console.WriteLine("Set up test");
}

[TestFixtureTearDown]
public void DoTestTearDown()
{
Console.WriteLine("Test Tear Down");
}

[SetUp]
public void TestSetup()
{
Console.WriteLine("Do test setup");
}
}


}


Now each time I want to create a class to do a load of tests I select my unit test class and denden immediate test. So yes today I have been continuing my test driven development of Converse. My faith in unit testing as something useful and non-faddish grows as I use it. It really does pick kill bugs. You still need an architecture before you start imo.

Tuesday, November 15, 2005

Unit testing fun

Getting nunit to work with visual studio 2005 is a bit of problem. It's spits out sometype of invalid file error.

You have to go into the config.exe and in the startup tag there are a number of different .net version - every single one was older than my latest version. So I deleted them all and put in the latest number - which required some searching around.

nunit-gui.exe.config



Looks like so:

<?xml version="1.0" encoding="Windows-1252"?>
<configuration>

<startup>
<supportedruntime version="v2.0.50727">


</startup>


</configuration>




Then it all worked rather nicely and test-first I built up a nice new class to go into my Conversation engine. The scroll bar also now displays properly. Anything where you have to hold the mouse button down currently doesn't work but its getting there.

My super tip for nunit is have your main project in one class library (a dll) then create a new class library called tests (or something equally inspired). Go to references add a reference, then click on the project tab and add your first dll where your main project is. Thereby allowing your test library to have access to your main programs classes! Now all your tests are in a totally seperate piece of code. For the coup de la resistance. Go to the test solution properties and add a post build command that loads nunit.

On Succesful build "nunit /run" should do it. I made the nunit bin directory a system variable. (I did this with lua and python to so I can call them anywhere from the command line. I remember in dos this was rather in easy, the path command or something in autoexec.bat? Anywhoo in window go to control panel. Double click system. Click on the advanced tab. Then click on the environmental varaibles button at the bottom. There's a box called System Variables, in the box is a list box, double click on the one labelled PATH. Then append the following to the string ;C:\Program Files\NUnit 2.2.2\bin. All path's are colon seperated. If you fire up a dos box and type nunit-gui or nunit-console it will run the program.)

Read more about unit testing!

Test-Driven C#: Improve the Design and Flexibility of Your Project with Extreme Programming Techniques -- MSDN Magazine, April 2004


Games From Within Tutorials - excellent resource for nunit test advice - what tests to write and why
Test-Driven Game Development (Part 1)
Test-Driven Game Development (Part 2)
Test-Driven Game Development (Part 3)

Monday, November 14, 2005

VS.net 2005

Currently all my old projects are building :D The object inspector looks really cool too. Everythings ready for me to resume development.

Sunday, November 13, 2005

Visual Studio 2005 and Migrating my DirectX C# programs.

Well I've had one locking bug but with time and magic that dissapeared. Then I had a load of problems with dlls and non-matching version numbers.

How did you solve this Dan? Well, of course I messed about for a long time. Finally reading this thread. Where it told me to remove all the references and re-add them. That worked a treat ... at least for my GUI library.

I didn't finish this weeks goal but I did finish last weeks goal :D So at least I got some stuff done. I'm hoping to polish off some more of this weeks goal tomorrow night. I'm busy tuesday through to Friday night :(

When I finally work up the will to clean up my tutorials or write more this tool will be invaluble Copy Source As Html. I found it from the Ten Essential Tools list on MSDN. The list from last year is still extremely valid and worth checking out.

Have fun.

Sunday

Well yesterday I didn't make my goals for nanowrimo. But I did do pretty well on the programming size. Programming wise I could probably finish up the stage-two tasks. But it seems I've somehow been pulled into entertaining children - can't children entertain themselves grahhhh.

I'm currently installing VS.net 2005, it's bit of chore to force it onto my remaining space. Suprise suprise my projects don't compile.

Saturday, November 12, 2005

This week.

Last week I wanted to decouple map references from my map object ... I'm still working on this.

During the week I started building a new library in dll format. It's going to be involved in conversations. It's mainly pulling together lots of little pieces of code that I've been working on. I may work on it today somemore. I also did some very minor city generation stuff nothing exciting yet, though I have a good idea for an algorithm.

Last week I did some refactoring and suddenly lost collisions! I managed to get tile collisions back in and just now and I've added in collisions between actors.

There are now new problems ... (;_;) I get flickering when my character moves from one map to another and if he starts moving from map to map to quickly he and all the other actors dissapear. I'll deal with this after all my current problems are finished. I'm not going to move to stage 3 until it's dealt with though.

I now think I've removed everything that was causing the abstract class map object to be coupled with a map, so I can safetly remove it. This is another step to maing my code less tangled and more modular.

My weekend goals are to tidy up stage 2 ready for stage 3.

+decouple map object
* Done! Game has also become magically faster too. The best kind of optimization is the magic, unexpected kind.

+prevent crashing when actors move on to unbuffered maps
* Also potential done but I need to check. checked it, it didn't work immediately but does now. Yay!

+develop a scroll bar in my GUI (it's been half finished for ever)
* Working much more than it used to be.
If you ever thinking of buying Wordware's DirectX 9.0 User Interfaces Design and Implementation, don't. Being very favourable it could be called a code listing. But the code is incomplete, the naming of the variables and methods seem almost purposefully misleading and the actually logic in some of the code is just off.

That said my scroll bar class is somewhat working. Unfortuanely the scroll bar thumb can scroll right off the bar. Not a big problem though. Far better than the previous scrollbar that didn't even show it's thumb. It's now working apart from if you stretch the bar :( The scaling code just isn't doing it's thing. Sooooo I think I can hack it. I'll make a scroll bar that won't work in every case but will work everywhere I want it to in my game. Afterall I'm not developing an operating system here.


+remove debug users (my menu support a number of users - for people who share a pc or one to have several different games on the go)
+default world image
+in the menu order the worlds by last played
+try to reduce class heaviness especially actor (this is a bad goal as it's vague. I think Actor is much lighter now anyway)
+slow down turns / pause turns
+save / load turn state

The last two sound rather daunting and while they'll probably be hard they're not as bad as they sound.

I will be supremely happy if I manage to get all the above done :D

Currently attempting to install VS.net 2005 but it seems to mean I'll finally have to install Service Pack 2 :D

Wednesday, November 09, 2005

Hear my mighty roar

Mid week programming isn't going to great.
I've been playing with a very simple city generating algorithm that currently produces output. I've been cleaning up the code and just today fixed another bug I managed to cause with my unfinished refactoring (vs .net 2005 looks so sweet - but I have no room on this portable to swing an upgrade. Maybe I can sort something out when I go home)

Unsually enough for me I've been mainly playing with the core code. The goal this weekend is to conclusively finish last weeks goal (decoupling object dependance - I want my mapobject class not to need a map reference) and then tidy up all the remaining stage two tasks.

... at some point I really hope to have a game :D

Sunday, November 06, 2005

Progress

I didn't realized before but I pretty much have a good chunk of full RPG system up and running. I can have NPCs that are controlled by lua scripts then the only big game pieces missing are combat and inventory.

Still refactoring and hunting down bugs.
Nanowrimo isn't really helping me.

Anywho refactoring continues. Currently I've altered bits of code all over the place and I'm trying to get to all work correctly again.

*Every works as it should now. The code in the process of being moved to a more zen-state, though I like compilable stepping stones to guide my way.

(also it's become quite apparent that I really knew nothing about OOD before I started out programming this. Such questions as Intersection where should such a function go in my myraid classes - were answered incorrecty. Each entity is my game had an intersection function. But really is that any object? Is that what this object should have to think about. It would have to know it's position and other creatures position too - its far more appropiate for it to be in the world or map object. At time of typing intersection remains with the entities ... but I'm getting there.)

*Map object still have a reference to a map. Tiles and Actors are map objects. They each have one function that make use of the map varaible. These are all the stand in the way of my goal. If there's time I deal with them tomorrow night.

This mini-wave of refactoring is really helping to clean up my interfaces once again. Errr what else ... oh it would also have been rather hard to plan the perfect architecture from the start. As soon as I finish the house work on stage 2 I'll get to some of the more exciting functional content in stage 3. A lot of it will be stuffed patched in that I've worked out in the snippet complier but there's other stuff that requires writing from scratch.

Continuing Refactorization

... the code will be better after this.

It will be a long way from perfect, it will most likely still be a long way from nice but it will be catching up to workable. That's the target.

Then I'll be doing some game niceities. Basically place holder graphics for various bit's that aren't in. I'll have another crack a texture tiling bug - somethings the last line of a texture is cut off for no appararent reason.

Once city generation is in - it will start to look quite nice and explorable. I'll probably need to work very hard on making it always stable.

How not to code:

Trawling through my code base seems to be like breaking open a rotten orange. I found this gem of an interface:


namespace EINFALL.Game.World
{
///
/// Summary description for ILocalMap.
///

public interface ILocalMap : IAbsoluteBounds
{
void RefreshTilePositions(); //If map DX pos changes
//Check if one MapObject's potential boundary collides with another map
//object
bool ObstructedByMapObject(BlockBounds boundary, MapObject focus);
bool ObstructedByMapObject(PointF point, MapObject focus);

bool IsPointBlocked(PointF p);
bool IsPointBlocked(float x, float y);
int GetTileIndex(Tile t);
int GetTileIndex(float posX, float posY);
int GetTileIndex(int x, int y);

void RemoveMapObject(MapObject m);
void AddMapObject(MapObject m);
//Remove a map object after it finished being used
void KillMapObject(MapObject mo);

//Is some map object potetially going to break the map boundary?
void TransferCheck(IAbsoluteBounds aBounds, MapObject mo, Breaks breaks);

void RenderDetail(float x, float y, Device device);
void RenderBase(float x, float y, Device device);
void RenderSubSection(Point startPoint, Point endPoint,
Device device);
void RenderSubSection(Tile startTile, Tile endTile,
Device device);
void Render(float x, float y, Device device);
Tile GetTile(int x, int y);

void SetMetaMap(BufferedMap m);

//Could probably be turned into getters
Tile[] GetTileArray();
void SetTopLeftDXPosition(float x, float y);
void SetTopLeftDXPosition(PointF Position);
Point GetShellPosition();
int GetTileDimension();

}
}


It seems to have nearly every function as the map class but with near everyone of it's function abstract.

It did make sense, in the beginning, to have a ILocalMap class. . . well at least I think it did. Well I made sense to have an abstract Map class - I was definetly going to have more than one type of map class - that would probably share functionality.

Some how that reasonable intention turned into the above monstrosity - nearly all the functions are only relevant to one type of map! This morning I've been cutting away dead code - that randomly threw up a few errors - miles away in the code! Suddenly there seems to be a endless loop happening now and again in my map functions. I think I've squashed it. I know I've at least fixed one oversight but who knows what else may be lurking.

Anyway I'm slowing hacking away at the code and we'll see how it goes. I'd love some good recommendations for OOD, OOP books actually. Maybe I should grab the a patterns book too?

* Turns out I needed this interface beast so I could have a skeleton map too. One that did nothing but existed while a real map was being loaded from the disk. I'm almost certain that this is the most messy solution I could have come up but it does work.


Saturday, November 05, 2005

Rules Object

We all want our code to modular. Even in an advanced project it would be nice to be able to:


Orc orc = new Orc();
Man man = new Man();
Write(man.Health);
Write(orc.Health);

RenderSystem.Render(man, x,y);


Something as simple as the above using only very light code. We don't have to locate graphics files each time we load a man, or pass in a sound system pointer, or a input object, or rendering system, or skill tree object - As much as possible we strive to make our classes as independant and modular as possible.

Among other things that what I'm striving for today.

How?



Well one of the ways to do this, especially with Actors and the like is by using a mediator class. For actors, sprites, beings, gameobjects ... this mediator class is often called: Rules or GameMaster. That's where you put your interaction rules - how things will interact with each other and the world.

So instead of each actor have something like:

actor.Attack(IAttackable a)


You have:

Rules.Attack(Actor actor, Actor target);


This way your game pieces are more modular and your game logic is kept tight and together.


*Renamed extremely unhelpfully named class (that's been here since near the start).
*Fixed a GUI object so it works as you'd expect
*Pulled loads of stuff out of my Globe class and pushed it back in utility classes of pre-existing objects

[This month i decided my never ending game project wasn't enough and decided to see if I could write a novel in a month with the happy crew of nanowrimo. It's fun, if you think you can catch up you should give it a go.]

Refactoring ...

I'm using a lot of the Replace command today. I've made a lot of classes that have been required for quite some time. The codes becomng more organized but it still feels a little messy. I've not even started on this weekends goal yet :D

Friday, November 04, 2005

Refactoring

I've finished my second stage.
The code needs cleaning though. A lot of stuff is messy and far far too interlinked so I'm going to try and reduce the amount of code and make it clearer. The goal for the weekend is to remove the map dependancy from the map object class. Map objects should be owned by the map class, there shouldn't be a need for a back link! ... at least I'm pretty sure there shouldn't be.

This is tomorrows job any way. Tonight I'm going to relax.