My coding project, part VI

Another approach vector

Earlier I started coding straight with the game objects and their controls. At some point I tried to insert some stuff I had left out before but somehow fighting with that .py file wasn't too much fun. The existing code was plentiful and that alone made it unpleasant to refactor heavily in IDLE that I still use, thanks to my laziness. So I started another side project for the rest of the game and other additional neatness. Later I could combine my doings into one nice packet and enjoy/suffer the consequences.

From one state to another one

I decided to start by defining a couple of states for my program to be in. Handling the events would be nicely divided depending on the states:
  • in main menu
  • in map screen
  • in game
  • is paused
Like so. The main menu idea comes from the Apogee platformers I spent ages playing, I believe. The main point is that you can start a game and quit it - the other options, such as save, load/continue (depending on what kind of savestates I end up implementing) and the settings can be implemented much later, but they'd have stand-ins displayed already.

When the game is started, the game world is initialized by a set of parameters, all of which are hardcoded at this point. My Java-background could be seen as a contributing factor to the increasing amount of classes and inheritance.

Constructor of Worlds

I pondered for a good while, what would be essential in this game. The Game naturally has all that's needed to run the game itself, such as the state, settings and rendering of various views. Game has a World object that contains the game world's data, it's size (at the moment it's a 3x3 universe), things like the Factions and whatever they need. The World consists of Sectors, which translate into "levels" where the player will fly with his/her more or less battered cruiser. What does the Sector contain? Right now just its size (in x,y), its owner (either no one or one of the Factions). Later on it's going to keep track on whatever it contains, such as Fleets, Planets and what have you.


At the moment the Factions have a name, an identifying color, race, policy and zero+ Fleets. As far as the racial crap goes, they're either humanoid / insectoid / robotoid / mixed - I wasn't very innovative when coming up with these. The only effect the race has is through the policies. There are three different political ways of seeing the world: neutral, xenophobe, aggressive. The idea is that the neutrals don't care about your race, the xenophobes get mad if you're of a different race and the aggressives don't give a flying crap about what you are as long as you won't be that way for long.

Maybe it was a silly idea but I also decided that there are some ways for the Factions to work with each other. Allies, friendlies, neutrals, unfriendlies and enemies - there are five ways two different Factions can try to relate to each other, if they are able to.

Extending politics

Nobody's interested in giving flowers to passers by, so war is to be waged. To do that I thought that Factions should have Fleets. A Fleet could consists from one or more Capital Ships, that may or may not carry fighter-scale vessels and such. Just to try out the generator I set the world initializer to build a couple of Factions to share the universe with the player. One of them is hardcodedly named as the Subspace Pirates (race: mixed, policy: randomly chosen) and it has one Fleet called "Hammer of the gods" in the starting Sector and it consists of three Ships ("Thunder", "Wind", "Rain"). Fun. The rest of the names to everything and anything are going to be randomized with a bullshit generator with a very obscure resultset, I hope. I like randomness quite a lot, it makes testing quite a bit more interesting because not everything happens always 1:1 the same way, in the same order and so on.
Fleets can be assigned a target sector, so they wouldn't be tied to a certain Sector but they could move where needed, to harass the player or another Faction. At least on the idea level it should work. Of course it'll be a completely different story when I get to the scary part of trying to write a sort of an AI...

On the map or completely lost?

Whenever the game has been started and the World initalized the player gets to admire the wonderful map screen. The first Sector on the top left has a marker for the player's Ship's relative position in the World/Sector. I thought I'd use the same marker in the minimap, if I ended up implementing one later down the road.


At this point, when you leave the map scree, there's nothing else to do. You'll end up with an empty viewport and you can either go back to the map or to the in game menu (continue / settings / exit), which I set up a couple of days ago. Oh, and hitting the k key kills you and you get to see the Game Over screen and then you get to proceed to the main menu. It's all pretty important, in the end.

Perhaps my next step is to use my old classes somehow to get some action on the screen. One huge thing to ponder is the GameObject's speed... do I want to keep the previous implementation (x and y speeds) or do I want to have it divided into speed and angle variables. These things have to be poked at in any case so I can't just rest on my laurels and slack off.

No comments:

Post a Comment