Friday, December 30, 2005

Graphics vs Gameplay

Which do you think is more important?
I read an article today on my internet travels.
I believe that without gameplay a game is not worth playing. However without the graphics to tempt people, they are not likely to pick it up in the first place.

If you were able to create a game that looked bad but had fantastic gameplay, and then you somehow managed to get that game into a game-players hands, I think that person would become interested in the game. The problem is how to get people to actually play the game, there are a few possible solutions:
  • So far, from what I've seen, most publishers solve the problem with fancy graphics
  • Another possible solution is "reviews"
  • Or Demos - these can be cut down and missing features from the full game though (Jets'n'Guns)
  • Trials - time or usage trial. These are fully functioning games that only last for a certain length of time. Most small developer companies I've seen, seem to use this method. (e.g, Xeno2 (30 min), Platypus (60 min) ,
If more of the development resources are spent on making the graphics of a game look good, then that would mean less resources are available to make sure the gameplay is as good as it can be. It usually takes a lot of time and money to create the art for a game. Plus there is a fear that you must not be too creative or original, so the game is stuck with high visuals and reduced gameplay.

Tuesday, December 27, 2005


I played a demo of flat space the other day. I wasn't impressed. I took up a mission and just couldn't get to the grid reference I needed to finish it, I was one square away and it just said out of range. So I quit, uninstalled and then installed FreeSpace2 in the hope it was better, but alas it was virtually the same game.
I did manage to finish a mission, but trying to get to grips with that map and the controls was so frustrating. Once I arrived out of hyperspace, I was flying around not knowing where I was going! Having no scanner and flying blind is not much fun. I should mention, there is a targetting mechanism, so you can target a base and then at least head in the right direction. I do prefer an overall view however, so I know what is around me, i.e. with some kind of scanner. Perhaps you can buy this later on in the game though, I couldn't be bothered to play long enough to find out. The graphics were nice though!

The Bad
I didn't like the mouse controls much, I found them rather frustrating. I can understand having to use comms as it adds to the atmosphere, it is rather frustrating I feel though. I would rather have automatic docking with a base whereby when I'm in range it docks with the base itself, rather than have to target the base by pressing "t" and then press "r" for radio comunications and then click "2" to talk to the base and then "1" to ask for docking permission and if I'm in range permission will be granted whereby I can move my ship into the ring and then press "D" to dock! Some things really shouldn't be overcomplicated.
I wasn't too happy with the general UI, I don't like modular dialog boxes that I have to close. For instance when viewing equipment I would've liked to be able to click on one device to see it's stats and then click on another device and see its stats, and not have to close the stats window every time.
Freespace desperately needed a training mission. The first one was so frustrating I just gave up on it.
Missions should be finished as soon as you arrive at the appropriate delivery base. I shouldn't have to click the Complete mission button. Thats just a waste of my ever so precious gaming time, time that could've been better spent exploring or blowing things up. Speaking of which when I blew up an asteroid, smaller asteroids were visible before the big one blew up!... a minor bug I guess. Looks good though when it blows, probably better than mine will.
I know I'm being picky at times, but I do need to be.

The Good
So what was good? Graphics were smooth. Music was cool. I liked the idea of going into the base to dock and that there is a docking ring. Nice at first, bit annoying later on.
There was a variety of player types: Trader, mercenary, bounty hunter, etc. Plus the player could have special abilities. The game also featured guilds, so trading would raise your standing in one guild, doing taxi mission would raise your standing in the courier guild or destroying and alien fighter would raise your standing in the Alien Fighter guild. Plus you can only buy certain specila equipment if you have a high rating in a certain guild. Guilds are a very useful feature.

It would not be fair if I didn't mention that FlatSpace was created by a very tiny company. Cornutopia Software ( Mark Sheeky being the big guy behind it all. Despite all the flaws I've pointed out, it is truly a hugely impressive achievement for one person.

Monday, December 26, 2005

Screen Flow

I created a quick mock up the other day to give me a good idea about how many, what screens I needed and how they would flow.
So far it looks like I'll need 7 main screens in total:

  1. Loading
  2. Intro - (pre-rendered?) Movie and/or credits
  3. Main Menu - Others that show up on the main menu but not whole screens, just dialogues:
    • New Game Skill chooser - Hard, easy, etc
    • Load Game
    • Options - Needs to be independant, so that we can replicate it in the in-game menu
    • Rankings / Graveyard / Highscore board
  4. The Game
  5. In game menu
  6. Finish Game - Screen that shows when you finish the level:- briefing, Next level chooser, etc
  7. Buy Now - when the game is quitting shows this screen for 10 seconds before closing.

So far I've done 1, 3, 4 and 5. I've not finished any of the screens I do have and some like the main menu I'm not happy with and will need to be redone from scratch. None of the sub screens from the main menu are yet done.

I need to get rid of the test sreens I've got in; I was using these to test the engine. I then need to put in some skeleton screens in so I know how things will flow, even if these screens consists of nothing but a simple picture or the text "Intro" on it! Once the skeleton is done, I can begin to flesh it out and build up some better looking and more functional aspects.

Monday, December 19, 2005

Darwinia and a The Big Universe idea

I've been a bit busy with work lately and have not had time to do anything on this project.

I had a quick go at playing Darwinia, it was a bit of a dull game as I knew I would win, it was just a matter of time. It had a good selling point and it was quite well thought out. An interesting thing was the map, it's a half sphere. with points plotted out for city like places that you can go. Lines connect the points and there are stargate type portals that allow you to transfer from one city to anoter. One city produces energy, another raw polygons, another makes the final product, etc.
The map was a nice idea, I think i might use something similar, but it does then raise the question to me, of how big I want to make my game universe? The bigger it is the more I need to consider how everything will balance out, plus I will need to create some sort of model for all the species to interact and trade with each other, so that there is an equilibrium. I would love to do it that way, so the universe is vast and there is lots to explore and learn. I could then have ancient civilisations, specialised technology, strange aliens who you come by, bars, pirate bases, guilds, traders, pirates, bounty hunters, militants, navies, ship wrecks with items you can pick up, and places you shouldn't visit without the right hardware!

I fear if I do go down this path too soon, I will never get anywhere near a finished product, as I will spend far too much time developing the trading simulation engine. So perhaps this vast universe I want, will have to wait for another day/version. Or perhaps just make it totally random and forget the balancing act!

Sunday, December 18, 2005


I was playing the demo of Jets'n'Guns.
It's a side scrolling game, with lots of explosions, particles flying everywhere, men (sometimes in spacesuits) shooting you with guns and bazookas, plus you can upgrade your spaceship.

I like the idea of the men ejecting from their doomed craft. Then the brave people start shooting you, as if a little man with a pistol, has any chance against a massive metal spaceship with upgraded hull and shields! But it is a nice touch.

In the demo, some of the upgrade options are unavailable. You are able to buy some new weapons and upgrade them. The best part is that the demo seems to repeat the same 2 levels or so, which means you can constantly keep doing those levels to earn money. Then you can use that money to upgrade your ship, adding shields, bombs, missiles, lasers, etc. So even though you are playing a demo, you still get quite a good idea what the game will be like.

Sunday, December 11, 2005

How to choose

I've never been able to know how best to make a decision.
Do I go with my emotions and what I feel (intuition) is best (best for who?) or do I go with logic, make up a list of good and bad and then compare, or use probabilities (how do you accurately decide the weights?) and decide what has the greatest chance of succeeding or use some statistical methods to basically crunch numbers get a choice out.

picture from: logic will sometimes get the most logical result but it won't always be something I'm happy with. For example how does one choose what uni to go to? Do you look at just the uni'a results average for a course, look at the outside area, the SU, the student campus facilities, the course content, the lecturers, what other students who have passed the course have gone on to do? There are a number of factors one must consider. In the end one uni may look the best on paper, but it's not until you start that you may realise you don't like it there, then all the little annoyances of the uni start shining through and you wish you went somewhere else.
I don't think using solely logic is the best way to make a decision, especially when humans are involved in the end solution.

People who succeed in life (socially and financially) tend to be people who find a carreer they enjoy. If you are happy in your job you will be happy to work longer and/or harder. After a certain point you can take the wealth of experience you've gained, find a niche market and setup a business and exploit it. You can only do that however, if you start the right way; with a job you enjoy!
Emotions are very important with people, it would be unwise to ignore the way we feel when we make a decision. So how does one make a decision? Well it could be usefuly to look at the audience you are trying to target.

Picture from: you are a parent and looking after your child, you do what's best for that child. Sometimes that means making the child sad and allowing him/her to cry for a minute, sometimes it means depriving yourself of things you 'want' but by doing so it allows you to give the child things it 'needs'. Every good parent does what is best for the child, sometimes this inolves looking at the long term benefits. Teaching a child to be a good, respectful human and endowing the child with good morale values is something every good parent can do. They do not do this for personal gain but for the greater good. I believe most parents don't teach their child these values so that the chlid can look after the parent, but do it because the parent believes in what they teach, they have faith in doing what is right, being a good person and helping (most) people in need.
In this case the child is the audience and the parent does what is in the best (long term?) interest of the child. This is not necessarily what is best for the parent and not necessarily what the parent would want (presents, gifts).

Picture from: one makes a film, one must look at the target audience. Are you making a drama? An action film? A comedy, what type of jokes/humour will you use? Whatever film it is, the film will be customized and built around the target audience. There is usually no point in using action film techniques (CG 3d special effects, pyrotechnics (explosions, etc.), fast paced action edits if you are making solely a comedy type film, unless you are making an action/comedy.
From what I know some of the most successful directors make films they would enjoy to see. I've heard the same principle applied to games development. That being the case, the success or failure of a game (at least from a small company) is down to the person/people that is the creative genius pushing their ideas forward and going with their 'gut instinct'. Ultimately making something that they would like to play.

When at work there are different types of people. There are those that are straight forward, decent, honest people who can sometimes be odd but who are the same no matter what the circumstances. Then there are those that change what they say depending on who they are around, this is usually so that the other party can understand what they are saying better, in effect putting their ideas in terms the other party will understand. Then there are people who say one thing to your face and act totally differently when you're not around, should you make friends with one of those people you wouldn't know which face is truly theirs. They seem unable or at least unwilling to just be themseleves. They can be so caught up in the need to satify others and fit-in that they may well have forgotten who they truly are.

A game designer can not use solely logic to make a decision. They must use their true emotions, beliefs, creativity and experience in the field. This being the case, surely they aren't able to be two faced people, as they must be true to themselves to be able to express their inner most emotions towards the game. If they were the only creative 'push' behind the game, making the big design decisions, then that game would have a lot of that person in it, just like a music artists' music has a lot of them in it.

So how does a games designer make a decision? The answer depends on the designer, and only experience can say how much of their personality they should put in it. After all how do most people buy presents for someone, they take the point of view, if I like it, then they should too!

If I like the game, and I enjoy playing it, then others should also.

Of course the end result (sales) says how much other people like that games designers' personality and surveys narrow it down, to say what they like or don't like. This is then the experience that tells the designer how much of their personality they should pour into a game.

Friday, December 09, 2005

Quake 4

I got to play Quake 4 the other day. It's well made, better than Doom3. I thought the levels were better, the lighting is certainly better thought out, they actually use shadows to make it a little scarrier. The classic joke of a small enemy making a big spooky shadow appears, it's not until you get closer that you realise!

It's a dark (mood) gorry game, but not too much, in my opinion. There are blood stained floors, after a monster has dragged a fellow companion away, which you just so happened to be in time to see, but too late to do anything about! Then there are dead soldiers littering the levels. Some are nailed to the wall or in contraptions being electrocuted with a thunder bolt type gun, which you later pick up. Some humans are in mechanical contraptions with their limbs chopped that make groaning sounds as you approach, some are even headless.
Ok it sounds worse than it actually looks, but It all adds to the atmosphere. Being in enemy territory, the enemy are experimenting on humans or at least trying to convert them to cybernetic "Strogg" drones.

I quite liked the health revitalisers you have on the wall ( a concept borrowed from Half Life I think). It would be good if I could use this concept also. Perhaps have drones, energy clouds or mini-lightning storms on the wall edge to raise the shields. Perhaps if you have no shields (drained or not turned on) then these things will damage your armour!
In Q4 there are other soldiers that will sometimes accompany you to acheive your objectives. There is a medic that can restore your health, if you ask him and a tech guy who can restore your armour. I liked the idea of such things in medal of honour. In MOH the number of health packs the medic dishes out was restricted, in Q4 it doesn't seem to be, although it is only available while the guy is still alive! Also in MOH you couldn't shoot while being 'repaired' by the medic, so you had to pick the right time to ask for his help.

Thursday, December 08, 2005

update - fx files again

A quick search on goolge revealed this site: [Translated]

Of interest is the effect.GetParameterBySemantic(null, "WORLD");

so it is possible to check up on what variable types there are and then return an
"EffectHandle". Once we have the Effecthandle we can then set the value like so:
myEffect.SetValue(hWorld, matWorld)
Where hWorld is the EffectHandle returned from the GetParameterBySemantic method
and matWorld is the value to set, in this case the world matrix

So after reading the code on the site I produced a class to hold the effect. I tested the program and guess what happened... my once nice clean space ship just dissapeared!
I ran into this problem before, it's something to do with those parameters I need to set.
Now I know the code before today was working. Luckily for me I keep backups of everyday. So I compared the code and it looked almost the same. Originaly I ran
"MyEffect.CommitChanges()" and I multiplied the matrices differently and set the values a little differently (I found out the parameter type and then got a handle to it).
I basically copied and pasted my old code for settings the values and pasted it into my render routine in my effect class. Then my once nice clean space ship got a lovely coat of gold.
Hoorah, I said quietly.
After a little looking and commenting out, it turned out that, before when I used the WorldViewProj matrix I had set it to Matrix.Identity.
Anyway now it's working.

So today before it was working I had:
dim matWorldViewProj As Matrix
and I was using the following to multiply the matrices.:
matWorldViewProj = Matrix.Multiply(matWorldViewProj, matWorld)
matWorldViewProj = Matrix.Multiply(matWorldViewProj, matView)
matWorldViewProj = Matrix.Multiply(matWorldViewProj, matProjection)
A silly error I guess, multiplying "matWorldViewProj" before it had a value.

So now the working code that multiplies the matrices is like this:
matWorldViewProj = Matrix.Multiply(Matrix.Multiply( _
matWorld, _
matView), _
I could've used "dim matWorldViewProj As Matrix = matrix.Identity" to solve it also, but I thought I might as well multiply the matrices this way. This seems to have solved the problem.

This screenshot shows the MetallicFlakes.fx file in action. There looks like there is a refelection as you move the camera around.

I also found this site:
which has lots of articles, there are a couple that might help with selecting an object in 3d space with the mouse i.e. Ray Picking.


Task list for today:

  • a Seperate RenderToSurface code into a seperate class
  • r Add Environment mapping
    This task is not a high priority, so I'll do it later when the required items are in place and working
  • a Add support for effect files into my DX9_RenderMesh class
    Not quite completed, but a working prototype acheieved

Seperate RenderToSurface code

I've seperated the RenderToSurface code blocks into a seperate class. This class is give at the end of this blog (Appendix A).

To create the class one would write:
'Create the class, set the pos and size of the surface
cRts = New DX9_RenderToSurface(160, 120, New Size(160, 120))

'setup the view matrix - if this isn't done then, it just uses the current view settings
cRts .ViewMatrix = Matrix.LookAtLH(New Vector3(0, 2.5, -7), _
New Vector3(0, 0, 0), New Vector3(0, 1, 0))

'change the backcolour from the default DarkBlue
cRts .BackColour = Color.Green

In the Levels PreRender sub I now have:
cRts .StartRenderIntoSurface()
Draw(True) '<-- internal to the class
cRts .EndRenderIntoSurface()

This took me about 2 hours to do, I'm now a little bored of programing for the moment, so I'm off to do something different I might go watch a movie or read one of my Rob Grant books.

Add Environment mapping

I decided not to do this today. I've added the task to my to do list, but I made it a medium priority as it's not vital for the basic functionality of the game.

Add support for effect files

I've got the effect files working. From looking at other code it originally looked like it would be fairly easy to implement. However the need to set values for items in the fx file such as time, WorldView or WorldViewProjection, which is those matrices multiplied together, made it difficult at first.

multipying the matrices like this works:

worldViewProj = Matrix.Multiply(worldViewProj, mW)
worldViewProj = Matrix.Multiply(worldViewProj, mV)
worldViewProj = Matrix.Multiply(worldViewProj, mP)

However the following will not:

worldViewProj = Matrix.Multiply( mW, worldViewProj)
worldViewProj = Matrix.Multiply( mV, worldViewProj)
worldViewProj = Matrix.Multiply( mP, worldViewProj)

At the moment before I render my mesh I'm having to set the "effect values" and then begin the effect. This is obviously not a good way to do it, because the "effect values" will change depending on the effect being used.
e.g. The glow.fx requires "WorldView" and "Projection" variables to be set whereas the simple.fx requires "WorldViewProj" to be set.

At the moment I'm thinking I rather:

  • Seperate out the effect into a seperate class
  • Just set these values once when the effect is created and trap errors, errors are thrown when one tries to set the value of a variable that doesn't exist in an effect file. However that wouldn't work for all effects, as some need the "time" variable to be constanly changing.
  • Find a way to detect what type the variables are (PROJECTION, WORLD, VIEW WORLDVIEW, WORLDVIEWPROJECTION, TIME, etc)

Effects can apply their effect to a mesh using different techniques. The reason being, that some cards won't support certain features and so one can choose the effects' technique most suited to a particular card. At the moment I'm setting the effect technique to use manually, by specifying it in a string. I'm not concerned about this yet because I know there is a way to get the first technique in the file, but I can't remember what the call is. I think I read it on the ToyMaker site somewhere, I just need to read the pages again.

Before the effect was implemented

After the glow.fx effect was implemented

Appendix A

My DX9_RenderToSurface Class - handles drawing to a surface

Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
'at the moment this class is dependant on the DX9_Sprite
' it may be good to cut this class out, and have the DX9_RenderToSurface class
' handle the sprite rendering that way it's all contained.
Public Class DX9_RenderToSurface
'Render to surface vars
Private RenderSurfaceSize As Size '= New Size(160, 120)
Private renderTexture As Texture = Nothing
Private rts As RenderToSurface = Nothing
Private renderSurface As Surface = Nothing
Private spriteSurfaceToRender As DX9_Sprite
Private SurfacePosition As Point
#Region "Public Properties"
Public Active As Boolean = True
Public ProjectionMatrix As Matrix = Nothing
Public ViewMatrix As Matrix = Nothing
Public BackColour As Drawing.Color = Color.DarkBlue
Public ReadOnly Property Texture() As Texture
Return renderTexture
End Get
End Property
Public Property X() As Single
Return SurfacePosition.X
End Get
Set(ByVal Value As Single)
SurfacePosition.X = Value
End Set
End Property
Public Property Y() As Single
Return SurfacePosition.Y
End Get
Set(ByVal Value As Single)
SurfacePosition.Y = Value
End Set
End Property
Public Property Width() As Single
Return RenderSurfaceSize.Width()
End Get
Set(ByVal Value As Single)
RenderSurfaceSize.Width = Value
'recreate the surfaces
End Set
End Property
Public Property Height() As Single
Return RenderSurfaceSize.Height()
End Get
Set(ByVal Value As Single)
RenderSurfaceSize.Height = Value
'recreate the surfaces
End Set
End Property
#End Region
'Setting the ViewMatrix or ProjectionMatrix to Matrix.identity will
' cause them not to be set during render, i.e. it will use the current
' View and Projection settings.
Public Sub New(ByVal x As Single, ByVal y As Single, ByVal SurfaceSize As Drawing.Size)
RenderSurfaceSize = New Size(SurfaceSize.Width, SurfaceSize.Height)
SurfacePosition = New Point(x, y)
'default matrices
ProjectionMatrix = Matrix.Identity
ViewMatrix = Matrix.Identity
End Sub
Sub InitSurfaces()
'create surface to render into
rts = New RenderToSurface(d3dDevice, RenderSurfaceSize.Width, RenderSurfaceSize.Height, _
Format.X8R8G8B8, True, DepthFormat.D16)
renderTexture = New Texture(d3dDevice, RenderSurfaceSize.Width, RenderSurfaceSize.Height, 1, _
Usage.RenderTarget, Format.X8R8G8B8, Pool.Default)
renderSurface = renderTexture.GetSurfaceLevel(0)

If Not spriteSurfaceToRender Is Nothing Then spriteSurfaceToRender.Dispose()
spriteSurfaceToRender = New DX9_Sprite(renderTexture, New Vector2(SurfacePosition.X, SurfacePosition.Y), RenderSurfaceSize)
End Sub

'These will render the scene to a surface.
' The actual rendering of the scene must be done by another class
#Region "StartRenderIntoSurface, EndRenderIntoSurface"
'This sub will begin the rendering to a surface, after this sub
' finishes, the calling class will have to render the scene
' and then cal EndRenderIntoSurface to finish it off.
Public Sub StartRenderIntoSurface()
If Not Active Then Exit Sub
' Render to this surface
Dim view As Viewport = New Viewport()
view.Width = RenderSurfaceSize.Width
view.Height = RenderSurfaceSize.Height
view.MaxZ = 1.0F
rts.BeginScene(renderSurface, view)
d3dDevice.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, BackColour, 1.0F, 0)
'setup the view
If Not ProjectionMatrix.Equals(ProjectionMatrix.Identity) Then d3dDevice.Transform.Projection = ProjectionMatrix
If Not ViewMatrix.Equals(ViewMatrix.Identity) Then d3dDevice.Transform.View = ViewMatrix
End Sub
Public Sub EndRenderIntoSurface()
If Not Active Then Exit Sub
End Sub
#End Region
'This renders the textured surface (sprite) to the screen
Public Sub RenderSurfaceToScreen()
If Not Active Then Exit Sub
'todo:record renderstate before changing
d3dDevice.RenderState.AlphaBlendEnable = False
End Sub

'The all important Dispose method.
Public Sub Dispose()
End Sub
End Class

Wednesday, December 07, 2005

To Do

This is my updated, prioritised to-do list.
Items in the priority section are not in any order.

High - Must Have

  • aAbility to move from one Level to another
    • Beginning Levels should be short, and get progressively harder and longer
  • Ability to show a story line either via pre-rendered videos or by using the engines DX generated 3d characters.
    If using pre-rendered videos, it maybe worth making it an optional download, as the videos could end up being 30MB or so.
  • aParticle Explosions
  • Save and Load game progress
  • Raster Pictures:
    • Backgrounds - Level, Menu
    • Level loading
    • End level - Completed, died
    • Intro/Splash screen
  • 3D Meshes - Create or find some free ones
  • Sounds - sound effects and/or voices
  • Music
  • Resource Manager - to hold and load meshes, textures, sounds, music, etc.
    (Updated 7/Dec/05)
  • Rendering (Updated 7/Dec/05)
    • a Lights - Number limited by cards capabilities
    • Effect files - vertex and pixel shaders

Medium - Would be Good

  • A pluggable architecture. Allow the additions of extra (3rd party?) weapons, upgrades, particle systems, levels and other features such as expansion packs.
    I really would like two versions of the game, one semi-realistic looking and one cartoon looking complete with the Smack and whallop star shaped onomatopoeia explosions and comic style story.
    * A useful plugin would be to allow scripts to be run, if not just for the cinematics. Perhaps even make this fundamental to the internals of the game?
    I've read that reflection can be slow when used in the game loop. So need to measure speed before implementing the plugin architecture(dynamic loading of assemblies) and after to see how much of a performance loss the plugins cause.
    (Updated 7/Dec/05)
  • Online updates - Allow the program to download updates.
  • Multiplayer - via a LAN or internet
  • Animated 3d meshes - This is trickier to do so I might leave it until version 2 or make it an upgrade at a later date.
  • Physics engine - so players ship could have a grapling hook/tractor beam and drag enemy ships around. Accomodate for ships being dragged into a black hole or at least dragged slowly, like a magnet.
  • Possible Pre rendered animations (AVI, WMV)- Player Died, upgrade received, medal received, players face during combat, introduction and story
  • Rendering (Updated 9/Dec/05)
    • Bunp Mapping
    • Environment maps
    • Shadows - hard line shadows to begin (shadow volumes) , with Soft Shadows (Shadow Mapping) later on. The game won't really have any major need for shadows, so this isn't a high prioority, perhaps not even a medium.
    • Progressive meshes - Level of detail changes depending on how far away mesh is from the camera

Low - Would be nice

  • User Level editor - A level editor an end user could use
  • Story editor - Allow the user to make their own stories and then package it up with their levels to effectively make their own Expansion Pack for the whole world to enjoy

Render to Surface/Texture

ACarPC project but, understandably, he was too busy at the time. I think I have enough confidence in DirectX now to create a pretty 3d interface for the CarPC. Perhaps if I have time I might have a quick go, although I'm not entirely sure at the moment what I want the final look to be.The program has only had 500 downloads since June 2005 and besides it's not as if I can use it, as i've got no car!

Since August I've been trying to learn DirectX and my long time friend above recommended a book to me, it's the only book I've bought on DirectX: Managed DirectX 9 (Kick Start) by Tom Miller. I've not read it fully yet, I've only been using as a reference.

Rather than read a book and then code, I prefer to just dive straight in and see where I end up. If I run into any problems or I want to know how to do something, then I'll look it up. After all why read the manual on how to program a VCR when you can play with the buttons and figure it out. After all these items "should" be designed to be (relatively) intuitive and if they're not then perhaps one needs to think like the creator and have a logical engineering style mind, either way I should be ok!

A couple of days ago I implemented a feature to render the scene to a texture. It was quite simple to acheive. Hopefully this will mean I can later manipulate that texture, a blur effect or some other filter. It will mean I can show a different view of the battle in the corner of the screen, like a rear view mirror in a driving game.
A question does crop up in my mind, will this be of some real benefit to the user, or have I just added it to demonstrate what can be done in directx?
Well if I can apply filters then it will be of benefit, as the game will look more pleasurable, however if it's just the "rear view" then it may not be of much use in this game. Having this extra camera view might be of some use when the player dies, we could focus/zoom in on the enemy that killed the player, or if a missile was launched we could use this extra camera view to show the missile as it moves to it's target.

I've not posted any code yet in this blog, mostly because my code tends to link around to different classes and occasionally calls methods in public modules, plus it doesn't look to good in plain black and white!

So here's how I did it.
First thing to do was to declare some variables:
'Render to surface vars
Private RenderSurfaceSize As Size = New Size(64, 48) 'size of the texture to be drawn
Private renderTexture As Texture = Nothing 'texture to hold the rendered scene
Private bRenderIntoASurface As Boolean = True 'are we going to render it?
Private rts As RenderToSurface = Nothing 'the render to surface object
Private renderSurface As Surface = Nothing 'the surface rts will use
Private spriteSurfaceToRender As DX9_Sprite ' the sprite that will handle the drawing of the texture onto the screen

DX9_Sprite is a custom class of mine, it basically just wraps up the Direct3D.Sprite object. Sets the size, position and loads the texture.

I have a routine that initialises directx stuff, this is called when the device is reset (OnDeviceReset event). Into this, the following code was added:
'create surface to render into
rts = New RenderToSurface(d3dDevice, RenderSurfaceSize.Width, RenderSurfaceSize.Height, _
Format.X8R8G8B8, True, DepthFormat.D16)

renderTexture = New Texture(d3dDevice, RenderSurfaceSize.Width, RenderSurfaceSize.Height, 1, _
Usage.RenderTarget, Format.X8R8G8B8, Pool.Default)

renderSurface = renderTexture.GetSurfaceLevel(0)

spriteSurfaceToRender = New DX9_Sprite(renderTexture, New Vector2(0, 0), New Size(RenderSurfaceSize.Width, RenderSurfaceSize.Height))

So I can now tell if we want to render this surface by checking the bRenderIntoASurface var. I can tell what size, I have surfaces and a texture as well as a sprite to render the final texture output to the screen.
I then proceeded to add the routine that would actually render to a surface. This code is basically from the books mentioned above.

Sub RenderIntoSurface()

' Render to this surface
Dim view As Viewport = New Viewport()
view.Width = RenderSurfaceSize.Width
view.Height = RenderSurfaceSize.Height
view.MaxZ = 1.0F

rts.BeginScene(renderSurface, view)

d3dDevice.Clear(ClearFlags.Target Or ClearFlags.ZBuffer, Color.DarkBlue, 1.0F, 0)

'setup the view
d3dDevice.Transform.Projection = Matrix.PerspectiveFovLH(Math.PI / 4, _
cEngine.ScreenWidth / cEngine.ScreenHeight, 1.0F, 10000.0F)
d3dDevice.Transform.View = Matrix.LookAtLH(New Vector3(0, 0, -7.0F), _
New Vector3(), New Vector3(0, 1, 0))

Render() 'renders a single frame


End Sub

Render() is a method that will call the render method for whatever "scene"/state (game, menu, splash) is currently active. In essence this just renders the scene for a single frame. At the moment the problem with this, is that the d3dDevice view and projection lines above are just ignored as the Render method will overwrite them and set them to whatever the camera class specifies. So I need to sort that out.

For testing purposes I just added the code into my render loop, so I now have the following code:
If bRenderIntoASurface Then RenderIntoSurface() 'This will crete the surface

cEngine.BeginRender(Not bUseblur) ' Begin the DirectX part of the rendering

Render() ' Render the graphics

If bRenderIntoASurface Then
d3dDevice.RenderState.AlphaBlendEnable = False
spriteSurfaceToRender.Render() 'This will actually render the surface to the screen
End If

cEngine.EndRender() ' End the DirectX part of the rendering and present the scene

cEngine.BeginRender calls the Direct3dDevice "Clear" and "BeginScene" methods.
As you can see the "RenderIntoSurface" method is called before cEngine.BeginRender.

That is pretty much all it took. Now I know the code works I have to extract the code and inject it into a seperate class. That way I can have my level show the "rear view" but the main menu won't!

Update: I've now moved the code into my Level class and fixed the few issues, only took about an hour! The following is the effect the render to surface technique produces:

If I move the main camera around, the render to surface view in the top left is static to whatever I set it to, so the main view changes but the render to surface view doesn't.

I had to add a prerender sub to my render loop. I also modified the Draw routine - it's now
"Sub Draw(Optional ByVal ISPreRender As Boolean = False)"- to check if its being called for a prerender (i.e. being called to render the scene to a texture), if it isn't a prerender it will update the cameras view and projection and render the prerendered sprite otherwise it won't.

Tuesday, December 06, 2005


I found a some well written articles today on a site: . I thought the whole site was well written. I read the shader and effect articles and came away with a decent understanding of where the pixel and vertex shaders fit it in. I must include support for effect files - I should add that to my todo list.

Channel 9 has some great videos on it. Some are well worth a view.

I also found the theZbuffer , which has (amongst other things) a blog list of developers working on managed code. Basically the whole site is geared towards programmers developing with managed Directx. There is soo much to read there.

I read a blog today ( last updated on the 22nd May 2005. Looks like he may have abandoned his plans of creating an engine. An interesting note is that he's set a milestone which he wishes to achieve.
Milestone 1:
  • Simple Engine Managment - Windowed/fullscreen/D3D Device.
  • State System - Each "view" of the game will be a state. e.g. Intro, Credits, Menu, Level.
  • Event System - For controlling state changes etc.
  • Rendering System - For rendering and updating the scene objects.
  • Input Control - keyboard only.
  • Scene Object System - Simple meshes and sprites (nowhere near the final version).
  • Resource Manager - Meshes and Textures.
  • Some kind of demo.
I thought it might be helpful for me to compare my efforts over the past month or two with this milestone, to give me a better idea of where I am. So far I've accomplished all the items on that list in some shape or other except Resource Management. That certainly made me feel a little better. I just hope I actualy get something produced and not abandon the project. Perhaps it's time to set my own milestone, so that I have something to work towards? The problem with a task list is being able to break it all down, that takes experience and since I've never used DirectX before, experience isn't something I have an abundance of!

As they say, when you're programming the last 10% of the program takes 90% of the time.

Scripting to use?

There are a few roads that one can go down to integrate scripting into a .net application.

  • VSA - Visual Studio for Applications
    • No SDK that I can find
    • This was discontinued in 2003 and will probably be replaced by Visual Studio Tools for Applications
    • Reports of memory leaks which are probably due to the inability to unload assemblies, hopefully this would not affect my application. A possible solution would be to load the assembly into its own AppDomain and unload that.
    • Requires about 300 lines of code for the class to manage the VSA scripting engine.
    • Couldn't add a textbox for the script engine to use. Classes seemed to pass along fine though.
  • LUA - and Lua Interface for .NET -

  • Microsoft Script Control
    • Widely supported
    • Uses an ActiveX control. So this would need to be installed - overhead
    • Very little code require to use
  • WebService
    • Can be slow unless asynchronous
  • Python - Perhaps overkill for such a small application.
  • CSharpCodeProvider - The DX 9c SDK has a sample that demonstrates scripting to move an object. The scripts are normal cs files. The example also sets Permissions so "bad" scripts can't be run. The codeProvider is certainly something that need looking deeper into.

From what little research I've done, it looks like the MS Script control would be the best way to go, especially if I'll be adding the ability to add plug-ins (i.e. dynamically load assemblies) at a later date.

Scripts Purpose

I did see a mention on the exDream blog that he used Lua and c# to create the effets. So it is possible to achieve some good results with Lua.
Scripts could be used for debugging and cheating. It would be simple to change or modify game values such as health or weapons damage. It could also be used to decide how the particle effects are generated.
The cinematics could be created and layed out with the scripts. So in essence the scripts choreograph the cinematics dictating what to draw, what sound files to play and what lighting to use, as well as the animations and movement of objects.

Monday, December 05, 2005

Design Decisions

Design Decisions

This is an updated list of all the design decisions that need to be made.

  • The Boss Level ~ Should this be an actual big boss with lots of guns and whistles or should the level have lots of small/normal enemies but with some game play restrictions. Restrictions could include: no shields, No extra weapons, no missiles, time limit, game speed change (faster), blur or movement restricted or a speed limit so your ship is slow to move.
  • Game modes ~ A quick skirmish mode where add-ons, bonuses and upgrades are dropped from destroyed ships and / or a career mode where upgrades must be bought and the game follows a story line.
  • Scroll Type ~ Should the space game be a:
    * Left to right scrolller - Like R-Type
    * Bottom to Top scroller - Like Xenon
    * A more 3d perspective, facing the back of the ship but allow it to go up the y axis and across the X axis.
  • a Menu system ~ Should it be a simple 2d menu or a fancy 3d menu. Must take into consideration the menu will stay loaded into memory.
    Perhaps have 2 menus; one in-game menu (resume game, end game, Save game, options,etc.) that can be brought up when in the game and another more elaborate main menu (start game, options, load game, movies, Quit, etc) which will be loaded and unloaded as required.
    Two menus will be used: one 3d Main menu and a lighter 2d in-game menu.
    (Updated 2/Dec/05)
  • Scripting ~ Should scripting be implemented from the start? This would allow the mesh objects to have their transformations (size, pos, etc) to be done via script, which would make it easier to change to different meshes. It would also be of great benefit during the cinematics as a script could be written for each one, allowing for easy creation and user exapansion packs. It may also provide some benefit to the computer AI.
    Allowing for any plugins or scripting would greatly complicate matters. One would have to consider what objects those classes can see as well as accomodating for how they can interact with each other. It will not be acceptable to expect all plugins to be installed on a pc. What would happen if it's not?
    Scripting could be implemented at a later date via a plugin, assuming a plugin architecture is adopted.
    (Updated: 2/Dec/05)
  • Story telling - How should the story be told? Start at the end and then flashback to the beginning? Break the story into chapters? Have no breaks in the game and just tell the story continuously?
    At the moment I'm tending towards having chapters - personal preference. I like the idea of having a summary of your accomplishments and progres at the end of a "section".
    (Updated 5/Dec/05)

Story Telling

In single player how should the story be told?

Flashback style - Start the game at the last level, make sure the player dies on that level and then when (s)he is dead, backtrack 3yrs to how the player got there.
Like Medal of Honour.

Chapters - The game will be broken down, into say 7 chapters/episodes. At the end of each chapter the player will be presented with a section of the story, or a cut-scene, as the game progresses the story will unravel.
Like the original Doom.

Continuous - The game will start from the beginning, giving an introduction to set the scene, they will then do some training and the action will begin. Cut-scenes maybe added whenever appropriate or have logs appear at random times for the player to read or hear. Briefings could be carried out while in space, so that seconds later you are thrown back into action or the action may even interrupt your briefings.
A bit like Doom3 in that the story unravel as you go through the game.

Sunday, December 04, 2005

Concept Art - Hangar

This is a possible look for the hangar before launching and after a mission has finished, this will be home. It's a bit scarce at the moment, needs some junk (weapons, spare parts, wires, tubes, tools, maintenance people, fuel, etc) to be lying around and stuff hanging of the walls.
Might be an idea to have the ship look battered if you dock with low health? Or would that be more work to implement than it's worth.

Rendered in GameSpace LT. I'm a little surprised at how good the render is, Caligari has certainly improved the final rendered quality since I used their product (TrueSpace4). Obviously it won't be anywhere near to this quality when rendered in my Directx game.

The Air Lock will exit the game, the blast door will open (it will probably move up) to let the ship fly out, the circle floor will go up to let the ship fly out to battle or down to storage or maintenance.
This space ship is just a quick mockup I tried out to see how easy it is to model with GameSpace. The face count of the ship without nurbs is 584. The rest of the scene is 116 faces. The reason that is important is because GameSpaceLT will not export an object with more than 650 faces.

Friday, December 02, 2005


I saw a couple of good articles today on adding scripting to a .Net application.

Not sure how or if I should accomodate for scripting. At the moment this is more of a distraction and not a high priority. I'm thinking about it because, if adopted, it would have useful benefits and make the final application more flexible. It would also affect how I do certain tasks, like the cinematics. It could also mean certain aspects of the game could have hot fixes or at least allow users to customize certain parts.
There is of course certain overhead asociated with scripting, so I need to look at alternatives and see if it's really worth it and where it would really be used. Some tasks would be easy to do with a settings (ini or xml) file. However I beleive cinematics would be easier to create with scripts.

If I do add the ability to use custom written scripts, I'm not sure how easy it is to expose my objects to the methods in those scripts. This is something I'll have to look deeper into and play with, before I can make any decisions.

Perhaps scripting is an "exclusive or" with plugins - one or the other but no need to do both?