May 2008

100k visitors and some Projekt “W”

Since relaunching my page with WordPress back in march 2007, there have been over 100,000 visitors to my page. Although this does not sound much at first, I guess it’s pretty good for a personal page (together with the fact that there were roughly 75,000 visitors to my page before that relaunch) and I hope that all those visitors enjoyed my projects, demos, applications and tutorials. And for those interested in numbers, I just saw that the traffic generated by my page for the first five months of 2008 (including views and downloads) has topped 1.5 terabytes, with most of the traffic coming form downloads generated by my games. In my eyes this is a nice summary, and I hop that it’ll continue like that!

And now back to my current work, “Phase 2″ for Projekt “W”, this time with some stuff from behind the scenes (aka the code, mostly this will only be interesting for programmers) :
You may remember the battle selection screen I’ve been showing off that’ll allow you to select if you want to battle it out yourself (on the hex-based battlefield) or if you want to have it simulated. One not-so-easy part in terms of coding was to implement this for when the AI attacks a human region. The AI itself is placed in it’s own unit (ProjektWeltherrscher_AI.pas) and has several procedures and functions for doing construction, army management and so on.
As with most AIs out there, the one in Projekt “W” is using a lot of loops (and is basically a finite state-machine) and within one of those loops it attacks enemy nations. In “Phase 1” there was no problem as it would only have to simulate the battle and output a message to the player’s message log. But in “Phase 2” the player should be able to choose whether to fight manually or to simulate the battle, even if he is attacked by the AI (and not only when the player himself is attacking a region), which meant that I somehow had to add a way for the AI to change to the battle selection screen without breaking out of the AI’s loop.
But this AI class is now used by the game’s main class (located in ProjektWeltherrscher_Global.pas), which means I can’t access the game’s class from the AI’s unit (this would be a circular reference, something not allowed within Pascal/Delphi), but I didn’t want to sacrifice my clean project structure by just moving the whole AI class into that unit in order to be able to access the game’s class from the AI.
So after a lot of thoughts on how to deal with this, I decided to go for a simple callback function. Most programmers should know what a callback is, it’s a function that is declared like a variable which can be assigned. So now the AI class has a callback that is assigned from the game’s class (remember, the game class can assign the AI class, but not otherwise) and that get’s called whenever the AI attacks a human-controlled region. That function now switches to the battle selection screen, waits for the player’s choice and then opts out to give control back to the AI loop. It’s easily implemented, but not often very obvious and a lot of programmers get headaches on how to solve such circular references, so hopefully this will help one or two of you guys out there!

New feature for “Phase 2”

While doing some miscellaneous coding and design-related stuff for “Phase 2” of Project “W”, I had a sudden inspiration for a new feature in order to get more dynamics into the gameplay. The new feature I therefore implemented is a stock market.
Nothing revolutionary (I guess most games similar to Project “W” have that feature too) but it’s bringing much more dynamics into the game’s flow. In “Phase 1”, you can only make resources with the regions themselves, but the new stock market will allow you to make a lot of resources (or loose a lot) within a short amount of time, but with a lot of risk.
On the surface, this feature looks straight forward, but it’s a bit more complicated in terms of implementing. One thing you cannot simply do is to calculate random values for the stock prices, as that would make it look random and unrealistic. Therefore each corporation at the stock market has a current trend (rising, stagnating, falling) that’ll change after several days, as well as a risk factor. A company with a low risk will have fewer trend changes but it’s share will never explode or go down the drain. The shares of a company with a high risk on the opposite may explode at one point and give you a lot of resources, but may also have you loose a lot of money. So in the end it’s up to the player whether he wants to risk a lot and win/loose a lot or if he wants to invest into a more stable share.
Note : The companies traded at the stock market are global companies not tied to any of the nations, with each company specialized in one area, e.g. military or chemicals. Also note that the list on the screenshots is not final, “Phase 2” will contain a lot more companies.

PjW stock market PjW stock market

And if you look at the screenshots closely you’ll spot that the control center has now changed a bit. Instead of six buttons, there are now eight buttons. One additional for accessing the stock market and an additional one for directly accessing the unit construction window. I wanted to have the later one in from the very beginning, but that would have left me with an odd number of buttons in “Phase 1”. Together with other small changes in the user interface it makes the game even more accessible now.

Resuming work on “Phase 2” of Projekt “W”

The last news concerning “Phase 2” of Projekt “W” dates back to february, but I recently decided to resume work on “Phase 2” again (after playing a lot of Guild Wars in a new guild) and over the last couple of days I finished a new part of the GUI that you’ll see when you attack a region.
If you’ve followed my postings on “Phase 2” you should know that the player will be able to either simulate the battles or to fight it out himself on a turn-based hex battlefield. So compared to “Phase 1” I had to implement something that’ll allow the player between those two methods.
My first take were two bland icons a simple window, but that looked so horrible that I decided to drop it in favor of a much better looking separate screen for the GUI. So now there is a nice and clean looking new screen with icons that’ll let you choose how you’d like to deal with the fight, and this screen will also pop up a nice result symbol and will then show you the military losses of each party. Note that this is still a work-in-progress and is subject to change, but basically the following screenshots will give you a hint at what it’ll look in the final release. And yes, those are taken from the game, no mock-ups made in Photoshop, which means that I also did some coding over the last fews days to get this working as supposed.
PjW battle UI WIP PjW battle UI WIP