I spent a little time clearing up the last bug, and I've now got to the point which all my projects seem to reach and then never progress any further from. This is the dreaded 90% complete phase, which normally means that you have the other 90% of the work still to do. Yes it works, but its just not at all polished. I'd really like to get this done to a decent standard, I'm sick of wasting time doing projects that only get half finished.
In true coder fashion, this of course will mean a full rewrite. I was thinking of how I could add in menus, and realised that I need some kind of state management system in order to this nicely which brings us another classic dilemma - do I use an existing framework or reinvent a wheel. I'm going to go for a halfway house; I found this which I like the look of and can steal some ideas from, so hopefully it won't take too long to get something working. I have a late start tomorrow (due to server patching in the evening - ugh) so I hope to have a good go at it tonight.
In other news, I just finished watching the first 4 seasons of Babylon 5, and if you are a sci-fi fan I highly recommend it. It's just so much better than Start Trek, it reminds me a lot of Firefly (but with bad cgi in the first couple of seasons :P )
A week or so ago I got the Orange Box (having never played HL2 before), and I just now finished Episode 2. I did a similar thing with the original Half Life, playing it a few years after it came out and I ended up being very underwhelmed by it after hearing all the hype. This is partly why I haven't bothered with the second until now, but it was only GBP15 and apparently Portal is very good (which I am saving for a rainy day).
As I was expecting the original game was good, but not great. The engine is very pretty, the physics are spot on, but it just doesn't quite hold together very well. It felt like I was playing lots of separate sections which were loosely tacked together by a story. First was the intro bit, then some sewers, then a boat ride, a Resident Evil type bit, a bit where you drive round in a buggy, a prison, city fighting, and then a futuristic alien citadel. Individually there was nothing wrong with any of the sections, but there wasn't much feel of continuity between them. The other main gripes are that the weapons all feel underpowered, there isn't much variety of enemies, and every puzzle is a physics one which requires the gravity gun. Apart from that though, a decent enough game.
Episode 1 took things downhill. Very short, no new enemies or weapons, and not a great deal of story behind it. Just as things seemed to be getting going, it was all over.
Episode 2 however saved the day. The game felt a lot more like a coherent universe, the story was much better, and there were some really nice set pieces. There was even a bit of psychology going on - I was convinced at multiple points that I was about to be betrayed by Magnusson. Subtle hints had been dropped the whole way through, and getting to the end and finding that actually hes a good guy after all was a refreshing change from the usual cliched plots that we normally get.
I tried a bit of TF2, not sure if I'll get into it though. I've become accustomed to Quake Wars recently which demands a bit more thought and cunning than your average fps, so it seemed like a bit of a backwards step for me but we'll see
So I got the texturing working after fiddling about for a bit, it turns out to be surprisingly tricky to texture a basic Mesh.Box!
I have a static class which holds all the textures, with each object holding a string reference to the texture it needs. When it comes to be painted, the string is passed to my texture class which either returns the texture straight away if it is already loaded, or tries to load it if it isn't. I suspect this is probably quite basic compared to what I'd need if I was doing a serious game, but it has the advantage of having all the textures in one place so that when the device resets I can just clear them all out and they'll get loaded again automatically the next time they're needed
The textures are pretty poor at the minute, but they'll do for now
Now the Christmas faff is over, its time to get back to coding. A few things done today on the gameplay side of things:
Completed lines are removed. I went for the simple solution of just having the blocks above them drop down one space which is how the original works, as opposed to some of the newer versions which have chain reactions and such as blocks fall into gaps.
The blocks now advance down the screen as you'd expect, and their speed is determined by your current score. I need to work out a better calculation for this, at the minute its just a fixed increase of speed per point scored. Something more quadratic would be better I think
I sorted out the problem with the keys being activated too quickly, they now have a 'cooldown' time which depends on their action (eg movement cools down quicker than rotate). I may also need to link this into the game speed at a later point, so that as the game gets faster the blocks can be moved around faster
Since thats pretty much the core gameplay done, I'll probably get some textures etc working for the next post
Some decent progress today, which is good as things will no doubt slow down over Christmas. I've got the blocks included and moving/rotating within the trough, and once they hit a surface from above they stick and a new one is spawned (though they don't fall on their own yet). The next step is probably to get completed lines disappearing, which shouldn't be too difficult. However already theres a slew of other issues which have cropped up which will need sorting at some point:
1. Performance Now, my machine is easily fast enough to do what I'm doing but the fps never seems to get above 40. I can only assume its due to the way C# is handling things. I'm using a paint/invalidate render loop which isn't ideal, but I've also tried the OnApplicationIdle method and didn't see any improvements. I'm creating almost all my objects at initialisation, so I would be very surprised if its the gc causing all this. I've even tried a paint/invalidate loop which just clears the screen and does nothing else, and I'm still stuck with a measly fps :(
2. Out of focus behavior When it goes out of focus, the app suddenly hogs half the cpu (compared to about 2% normally), and still intercepts keyboard input. I need to find out how this is usually handled
3. Device lost As I'm not using very complex assets, its not such a big deal to reload my meshes when the device is lost but I'm thinking there must be a better way to do this. I can't see this being practical in a large game with many complex models
4. Memory When I launch, about 20Mb of memory is eaten up, which seems a bit high for what I'm doing. After a minimise/maximise this then drops to 4Mb. I suspect this could be the gc playing tricks