
WAKE - Matt Brocklehurst
![]()
Introduction
Well hello folks, I'm Matt Brocklehurst, a British coder, currently working on a game called WAKE. My articles will follow the progress of WAKE from its current stage (design stage) right up to the finished game. If you're considering creating a game yourself, these articles may be of use to you, so you can learn from my (or other members in the WAKE team's) mistakes, saving you time and grief!!! Well first off, you can find out more about WAKE at http://wake.sourceforge.net/ - secondly, I'd like to hear your comments and ideas about anything related to myself, WAKE or any other one of my programs, so feel free to e-mail me at matt@mattbrocklehurst.co.uk. Well, I'd better explain what WAKE is all about really first of all, as this entire set of articles will be based around the game!
Wake is a computer game being created for the PC platform. It takes elements from various PC games, the better elements of them all, and places them into one. You control a sheep which, using a variety of different weapons, has to go and destroy the various other enemy sheep on the map. Various multiplayer modes exist, such as team death match, where you work in a team to eliminate the opposing side, to every-sheep-for-himself tournaments, where every sheep has to fight every other sheep round by round until the overall best sheep wins the tournament. The game is played from a side view, on a map that can be destroyed. The maps feature objects which the sheep can hide behind, protecting themselves from then enemy, until of course, some sheep sends a grenade flying next to the object hiding the sheep. The grenade will remove the object as well as the sheep hiding behind it from the map completely!!!! Various weapons exist, ranging from an Uzi to a Grenade Launcher. Various tactics will have to be employed to make sure you survive. Is it really the best option to walk totally in the open above ground? How about going underground, and blasting a tunnel so you can come up behind your enemy? This is WAKE!
An interesting concept really, merging the best of two or three games into one game. As this is my first *real* game (I've written many before, but all lie unfinished on my hard drive!!), I've decided to get the design right first of all, rather than starting to implement it right from the start. So WAKE started life as a paper drawing, in scrap scruffy writing, but do you think Quake didn't?! A couple of odd sketches here and there before I went to sleep, and a couple when I got up, and the game idea evolved into the one listed above. The hardest part then was to find a team of people to work with, since I'm not artistic, or musical - I'm just a plain simple coder, not a jack of all trades. Anyway, trying to pull a game off on your own (known commonly as a lone wolf) is not an idea to be taken lightly. So I began searching the Internet for artists. I tried a few forum postings, but the posts got ignored, as usual, by most artists. If you look, 90% of all posts looking for artists get 0 replies, people just ain't interested. So I searched various IRC rooms, and found some willing artists. The next major hurdle was that a couple of them wanted money up-front, which is understandable - why should they work for nowt? I do not have the cash to invest in something that may fail, I never will, but that's just me being stingy with my cash. The promise of payment when the game got published didn't appeal to many, understandably, but I managed to retain two artists, and one was a maybe, who as yet has not returned any e-mails I've sent him. One was actually gained the night I write this article, just to show you how up to date all this information is. The other one's been with me for a couple of nights. He's very skilled; he's already modelled the sheep, and he's doing some of the sheep animations as you read this. He has also promised to do some music for WAKE, which I'll pick up tomorrow. Whether or not the music will be used in the final game is another story, another article, but I'll let you know how it went next month!
My physics code is really bad, and so's my AI coding, so I've got a mate helping me code it. I was originally planning to do the game in C++, but as he's only just converting to Delphi (Pascal) from Visual Basic (euuugh) under my guidance, he didn't want to have to try and learn C++. So I changed my mind and went back to good old Delphi. Not having done any direct DirectX calls in Delphi, I've opted (at this stage) to use the DelphiX components, which give you easy access to DirectX from within Delphi. Various programs have been written to date that help us to understand how to do something, which is one thing I recommend. Write lots of small programs that all do specific tasks - for example, Dale wrote a program that handles the physics for snow and rain, and another separate one for pushing blocks off cliffs. I wrote one program to test alpha-transparency, and another one for testing the speed of tiles getting blitted across the screen. Once you've got the basis of the game working in separate .exes, you can then shove all the code together. This saves you changing one thing, trying to get it working, and altering another part of the program so it no longer works. This may seem a sloppy way of working, hundreds of different projects, but just remember, it's saving you having to tear your hair out when something random happens, and it's easier to test one simple program then a complex multifunctional program.
The major problem I hit arose from my choice of using 32x32 tiles to draw the map. How would I make specific sections of the tile transparent, so it looked cut away and revealed the image behind the tiles? A large alpha-bitmap was suggested in a conference between me and Dale (okay okay it was on MSN Messenger - but conference sounds better :), so I quickly implemented that in my test program, but it lagged like hell - LAG is a large delay between one event and the next - in this case the screen dropped from being drawn at 90 fps on my Athlon 700 right down to less than 3 fps!!! This makes sense though, it's checking large integer values constantly, in my case 1600000 integer values 90 times a second, well 90 times a second was the rate I wanted, obvisouly not even the Athlon can keep up with that - how'd I get 1600000? I hear you ask: mapwidth*mapheight - the size of the alphamask. Much better using a smaller data-type, maybe a Boolean I thought. How you get a bitmap to use only Booleans I don't know, and I didn't fancy altering the component. So back to scratching my head with Dale in the MSN Messenger room. I suggest an array of Boolean, he agrees, I try it, and hey presto! back to 87 fps. I've dropped 3 frames a second :( but that is unoptimised code remember, it's making the entire map transparent and I only lost 3 fps!!!! When it's optimised, I'd only make the visible area of the map transparent and ignore the rest. To speed it up even more, I choose to calculate the alpha-mask only when the map has been modified, no point in calculating it every frame if it's identical to the frame before - makes sense!!! So I now have a new DirectX surface in memory that holds the map, complete with transparency effects, that I blit across to the backbuffer each frame - if that didn't make sense, don't worry!!! Basically I'm calculating it only when needed, storing the calculated version in RAM, and copying it to the screen every frame update.
Well that's the stage WAKE is in at present, what's due between now and next month, hmmmmm, well hopefully most of the sheep anims will be done by then, maybe some map textures, and hopefully a lot more code!!! I'm hoping to get the entire engine done in a few weeks, then we can concentrate on all the hard stuff!!! Most of the GUI graphics are already done, and my 3D renderer said he's done some music, so maybe that will make the game feel as if it's coming together already!! Nothing better than to have audiovisual output, rather than a couple of hundred lines of code! It impresses non-techie people more anyway, a nice rendered anim, rather than:
procedure someproc(test1:integer);
begin;
a:=(sin(272)(mod(*273));
if(a<>random(2824824)) then
begin;
if(b<>random(38383)) then
someproc2(11);
else
someproc3(11);
end;
frmMain.dxdraw.flip;
wsocket.sendstr('3223236962309'+#13+#10);
end;
Oh yeah, and don't e-mail me saying that code don't work, I'll break your neck - it's gettin' late, and it ain't supposed to work :P However if you can make anything interesting happen by making a maximum of five changes to the above procedure, send it to me, matt@mattbrocklehurst.co.uk, next article, I'll post the best one and its author!!! Oh well, happy coding/game designing!!
Matt Brocklehurst,
web: http://www.mattbrocklehurst.co.uk/
mail: matt@mattbrocklehurst.co.uk
Feedback