Pre-Order the Game!

Desura Digital Distribution

Monday, December 27, 2010

Small update

I squashed several bugs and refactored some of the old code so it's more clean and easy to fix if any problems pop up.

I've decided to change from random 6 planets per star system to user defined amount. At the new game screen, there are two new options. They are Minimum Planets and Maximum Planets per star system.

By default this is 0 minimum (no planets at all) to 6 maximum. You can change it to be 1 minimum and 1 maximum, and every star system will have only one planet (aka MoO 1, except for some system having no planets. With only 1 planet, the generator will populate only half of the stars with a planet if the minimum is set to 0), or you could change it to 0 minimum and 5 maximum (aka MoO 2)

The maximum "Maximum" value is 100, and minimum cannot be higher than the maximum amount, but can be equal if you want to force equal amount of planets per system.

100 planets per system may be a bit excessive, but I don't want to force limits on some players who want more than 6 planets per system. My goal is to give more choices to the players, so they can try many different scenarios, therby increasing the replayability of the game.

Currently I'm working on scrollbar class, so the players can scroll through research items, construction items, etc. When that's done, I'll focus on the galaxy screen and start implementing fleet movement and exploration.

Wednesday, December 22, 2010

Optimizations, Empires, and Exploration, oh my!

The galaxy generation code bothered me a bit. In a previous post, I talked about optimizing it so it's somewhat faster. But if I do 800x800 random galaxy, it takes my computer over a minute to generate the galaxy (it's a quad core with 4 gig of memory), and there were only like 4,000 stars when it was done. Surely my computer can place 4,000 stars randomly faster than that, so I brainstormed for a faster algorithm. Then it hit me, I can use the quadtree concept I used for galaxy drawing to generate the galaxy. Here's how it works:

Parent node encompass the whole galaxy, and have subnodes that divide the galaxy. This continue to branch until each node are only 1x1 in size. I then tell it to remove nodes that are in illegal areas (for shaped galaxies). Then I tell it to randomly find a node and give me its location. After getting the node, I place a star there, then remove the adjacent nodes. This continue until there's no more nodes.

The end result? The same 800x800 random galaxy that took over a minute to generate now generates it in about 2 1/2 seconds! This is a major optimization! As a result, I'm satisified with how it works, and its speed. I seriously doubt anyone will play in those huge galaxies, but just in case they do, they won't laugh at my generation code.

I've started importing some stuff from the old code (before I started refactoring the whole thing), and did some code improvements and cleaning up. Planets are back in, and each star system can have up to 6 planets. The "IsExplored" is added, and the function "SetHomeworld" is implemented. Starting a game from the new game screen now creates homeworld for each of the player.

I also added an EmpireManager that will manage all the empires. When a player hits end turn, Empire Manager will iterate through each empire, and if it's computer player, execute the AI code, otherwise halt and let the next human player play. When all empires are done, then end of turn will commence. There's no "End Turn" yet, but the Empire Manager will help organize the code for me.

The exploration functionality is there, so when you start a new game, you only see your own home system's name. All other stars don't have their names displayed.

Now that my goals as stated in previous post are accomplished, my tasks now are to import all the old code and re-implement them in the new code. This includes colonization, exploration, fleet stuff, end of turn processing, and other stuff. When those are done, you'll be able to start a new game, select the galaxy shape/size, select players, and start it, then explore/colonize. I might throw in planetary development, but no promises!

Thursday, December 16, 2010

Still working on it!

Sorry about lack of updates. Things kept me busy, mostly me getting sick :( But I've become better.

I've worked on the game, and it now transition between different screens (clicking on new game takes you to new game screen). I also modified the player options. Instead of having three dropdown menus per row, I combined two (human/computer and difficulty) into one, so it looks like this:

Human
Computer - Simple
Computer - Easy
Computer - Medium
Compuer - Hard
Computer - Impossible

One thing to note, it's possible to have more than one human in the list of races, which allows for hot seat multiplayer, or for you to control two or more races. Or you could even have only yourself in the galaxy (for testing an expansion strategy perhaps?).

I've also optimized the galaxy generation code so it creates a new galaxy a lot faster (about 1/28th the time it took previously). But it can still be optimized more, I may look into methods for that. But for now, it can generate a galaxy with about 2,000 stars in less than 5 seconds. I doubt anyone would play a galaxy that huge, but the option is there if they do want to.

I'm currently working on the galaxy screen, and optimizing the drawing process (I don't want to iterate through all 2,000 stars if I'm zoomed in and can only see 4 or 5 stars). I've discovered a method that will help speed up the process, which is the quadtree. It's kinda like a binary tree, but with 4 children per node. I'm also working on the galaxy setup when you click on "Start" after setting up the new game options, it populate the galaxy with races that you've selected.

After those are done, I'll re-import the old code I had before I started the whole refactoring process, which includes colonizing planets, fleet movement, planetary management, population migration, empire income/expenses, ship construction, exploration, supply range (fuel range) and maybe some other stuff that I forgot. Then I'll release that version for testing!

Monday, November 22, 2010

Camera working, and ship placement algorithm done!


As you can see, the ships are arranged so the biggest ships are in the middle, with smaller at top and bottom. The algorithm works like this: Sort the list of ships from smallest to largest. Fit as many ships as possible on the frontmost column (facing the enemy) starting from smallest, but place the largest ships in middle. If more ships than the column space, then put the rest of the bigger ships on the next column, a bit farther from the enemy, and so forth until all ships are placed. This took me a while to finally figure out, but when I figured it out, the solution was so simple I'm kicking myself for not thinking of it sooner.
I've also tweaked the camera class so it can work with either the galaxy viewing, space combat, or ground combat. As a result, I can move around the space battlefield and zoom in/out.
I've also figured out a simple solution to the UI problem with the new game screen, so things are looking up! I think I will leave the space combat screen as is for now, and finish up the new game/main menu, and add transistions between different screens. Then I'll reimplement the galaxy screen from the older version, and hopefully it'd be kinda playable.

Wednesday, November 17, 2010

First space combat screen!

I've decided to put the new game screen on hold for now, and focus on creating some other screens, because the user interface was giving me a headache. So I decided to work on the space combat screen because that's the most fun part of the game! Seeing your ships pwn the enemy ships (or vice versa, which isn't as fun)!


There will be max of 16 different ship sizes, I've taken a screenshot of the initial combat screen (all it does is display the ships properly, along with the amount of ships stacked). The ship on top left is the smallest (16x16 pixels, or size 1). The ship under that is size 3, the ship on top right is size 5, and the bottom right is size 16.


I've thought long and hard about how the space combat should be like. This is what I've decided. Ships will stack, like in Master of Orion 1. However, the combat field is bigger than the screen, so you can look around, zoom out/in (maybe), etc. Defending ships will always be on the left, while attacking ships are on right.
Since this game will incorporate some physics (if you don't see a beam hitting a ship, it don't hit, and vice versa, similar to X-Com), weapons will perform a bit different from MoO 1. Here's the sum:
A weapon with many mounts (say, 10 cannons), will each fire in succession, so it will shoot 10 times visually. The topmost ship will take damage, and if it is destroyed, the next shot will hit the next ship, and so forth.
"Streaming weapon" means that it penetrates the ship, dealing damage to it, but continuing beyond the ship to potentially hit another ship. Imagine rail gun from Red Faction. It won't "carry over" to the next ship in stack.
Exploding weapons (such as anti-matter torpedoes) impacts all ships in the stack, so it is more powerful the more ships are stacked. Black hole Torpedo is included in this category.
Missiles will be treated individually, if enough damage is done to destroy a ship, the remaining missiles will hit the next ship, and so forth.
There may be other special weapons, and special shield characteristics (a shield that bounces off energy weapons for example) that may affect the tactics.
I'm excited to see the combat screen fleshed out!

Friday, November 12, 2010

Player selection layout implemented, somewhat

Here's a screenshot of the new game screen. It will have up to 12 players. If you're playing a local game, you can select either human, computer, or none for each player. Having more than 1 human controlled race will allow for hotseat multiplayer.


I'm still working on the layout, but implementing this showed a very big bug. The dropdown menu that is drawn before the next one, but overlays it, will be drawn underneath the next one. You can see this in action in the screenshot, at second to last player.


I'll have to think about how to fix this, but at least I'm making progress!

Wednesday, November 10, 2010

Dropdown menu is done for now, TextBox is next

The dropdown menu code is functional, with the exception of scrollbar. I can click on up/down arrows and it'd change the list accordingly. But I don't want to dwell too much time on this, so I'll leave it as is, since it's working, and focus on the last important User Interface element, the TextBox.

When TextBox code is finished, I'll have all the important UI elements available for me to use in all parts of the game. Things will progress a lot faster. I hope to have a playable version by this Dec.