Early version demo available!

After some time with no updates, I’m pleased to announce that there is a demo available! :)

It can be downloaded at http://www.filesavr.com/omegasector - just download and unpack the rar file, and then run the bat file. The jar file is executable as well, but the memory pool needs to be increased from the default, thus the bat.

A little disclaimer: The demo only shows very small portions of what is the scope of the entire game. A demo level with a few different enemies and a couple of weapons is showcased. The complete game will feature a story and plot, as well as a multitude of ships, weapons, and other effects.


But until then, do enjoy the demo :)

Menu Screenshot

Thought I would post a screenshot of what the game menu looks like :)

Menu Screenshot

Click here for full resolution!

And the beat goes on…

First, I apologize for the lack of updates recently. As it happens, I’ve had an accident, and broken my wrist in two places. (boohoo!). More specifically, the Scaphoid bone. Lucky me.

But I’ve got a nice scotch soft cast on now, so I can finally type (read: code) again. At least to some extent.

So what’s been coded lately? More audio! I didnt want to put unnecessary limitations on the audio part of the game, having to cut clips due to performance issues. Nah, I want to be able to play at least 32 sound clips at once. So, there’s been some optimization. And I’m approaching 90% happinness with the code. It has some drawbacks (Each SoundEngine instance has to pick an AudioFormat and stick with it!), but the advantages are huge. I’m happy to say that the delay for playing clips is 0-2 ms for small clips (1-3 seconds), and up to 15 ms for longer clips (test was 20mb .wav file). This is very acceptable :)

(And yes, this was tested together with graphics and logic!)

I’m crossing fingers and toes that it all works out like it looks like it will at the moment.

Stay tuned. I might not code as fast I’d like these days, but that only leaves me more time to consider what I want to code before I do it. I guess some people wouldn’t call that a bad thing :)

More on Sound!

So, now our game can play sounds :) I added an explosion-like sound that plays whenever a ship is hit by a weapon. And then I went on a rampage, shooting down ships left and right. And sure enough, all the explosions (at least those my ears could single out!) played. Now, this is hardly a stress test. Weapons themselves need sound effects, and we need backgroud music, and other “environmental” audio effects. But I have to say it is looking good. When the time comes, this all needs to be testet on other computers, - until then, I’m positively surprised by Java sound!

Now, onto the next challenge… Sound samples and atmospheric music! Heck, I’m no musician. I hardly know how notes. But I’ve downloaded some free software for creating music:
Audacity and Sony Acid Express. I doubt I’ll create any masterpieces though :-)

If anyone know of any decent repositories of sound samples for our game (Ambient atmospheric music for menu background, adrenaline pumping music for some levels, and decent samples for weapons, explosions and the like), drop a line!! I’ve been visiting The Freesound project and Soundsnap. I’ve had some success, but o’boy there is alot still needed.

Choosing an Audio library

It’s time to start looking into audio. The game is looking alright already, but the experience is not the same without sound.

Since we want to keep the game platform independent, we cannot choose an audo library that will only work on one platform.

After some consideration, it has boiled down to 2 choices: JOAL (Java bindings for OpenAL), and the standard Java sound (javax.sound packages) libraries.

Although JOAL seems like the “better” library, I get a feeling it’s a bit overkill for our game right now. It seems too complex for our needs. Even the most basic examples feature quite alot of code that in my opinion is not immediately intuitive.

The Standard Java sound packages seem easiar. I wonder though, if they’re buildt to handle many clips at once, - and whether it will be responsive enough to work in an action game. (Unlike some other genres, the Omega Sector and shooters in general are kind of fond of explosions, weapon effects, various other fancy effects, all which require sound effects).

Unless someone here jumps in and recommends one other the other, I’m going to go ahead and try to use the Java sound packages. I’m going to stress them from the beginning though, because I don’t want to invest too much time in the case that they’re not up to the task.

But the bottom line is that I don’t know too much about audio libraries. It’s the thing I’ve always skipped and left undone, so I’m definitely looking for good suggestions here.

Latest week

The latest week have been filled with sickness and lack of time and energy. I’ve rewritten some of the base-classes for the Particle Systems to make them more streamlined and easy to implement (and a potentially large gain in performance depending on the particle system). A couple of new weapons have been implemented, and a couple of new ship types. But that’s it, unfortunately. I am sure the next weeks will be more productive!

Space and distance in a 2D environment

Finding the distance from entity A to entity B is often useful. Sometimes options could be available only within a certain distance, or only outside a certain distance. Calculating the distance from point a to point b is easy. The method below shows how.

public static double getDistance(double x1, double y1, double x2, double y2)
     return Math.sqrt( ( (x2-x1)*(x2-x1) ) + ( (y2-y1)*(y2-y1) ) );

The method finds the distance between the point (x1,y1) -> (x2,y2).

Now, sometimes you are not really interested in the distance itself. Sometimes, the relationship between several distances is more interesting. Let’s say you want to look at a group of entities, and you want to find the entity with the shortest distance from a source point. In this case, the method above is unneccessary slow. Math.sqrt() is not a particularely efficient method, so leaving it out would be good. And we can. Since we’re not interested in the real distance values (only the relationship between distances), we can use the following method:

public static double getUnsquaredDistance(double x1, double y1, double x2, double y2)
      return ( (x2-x1)*(x2-x1) ) + ( (y2-y1)*(y2-y1) );

if getDistance(a,b) > getDistance(a,c) then the same holds true for getUnsquaredDistance. a,b will be larger than a,c.

With this method, we can more efficiently compare distances. If used in combination with what I wrote in the previous post, we can design a way to find entities efficiently.

We’re currently adding weapons that should fire some kind of “heat-seeking” bullets. These bullets should lock on to the closest enemy entity. To achieve this, we iterate over our collection of entities (either filtered on a category, or not),  calculate the distance(relative) to each entity by using the method defined above, and return the entity with the lowest distance.

Basic collision handling in a 2D environment

In our setting, most things that appear on the screen should have collision capabilities. However, different entities need different “rules of engagement” so to speak. As such, we have split entities into different categories. Our categories are “Bullet”,”Ship”,”Ground Unit”, and “Player”. (I hope the descriptive names are self explanatory). Each category is represented by an ID which is a power of 2 number, so that an entity can be apart of several categories. For example, our player ship might look like the following:

@Override public int getCollisionId()
        // If the ship is invulnerable, don't allow collisions!
             return 0;
        return CollisionHandler.ID_PLAYER | CollisionHandler.ID_SHIP;

So, if our Player ship is invulnerable, it will not handle collisions. Otherwise, it will handle collisions targeted at both ID_PLAYER and ID_SHIP. With these categories in place, we can manipulate our collision handling easily and efficiently. We can design weapons that fire Bullets that only target Ground units, or Ships, - or if fired by a Player make sure that they do not hit another Player (friendly fire). The following example code shows how it can be checked whether an entity belongs to a specific category.

        //otherEntity belongs to the ID_BULLET category.

And the containsCollisionId method is defined as this:

public static boolean containsCollisionId(int id, int category)
      return (id & category) != 0;

This is how the Omega Sector handles collisions. With the help of the code pasted here, we can iterate over entities and check for collisions between them, we can apply category filters to increase performance, and entities can dynamically change their collision rules during their lifetime. (Picture an entity that goes from being on the ground to flying in the air. Its collision categories might change, to reflect that f.ex “air to air” bullets should now hit the entity.

PS! Excuse the formatting of the pasted code here. It doesn’t seem trivial to make the code look good, unfortunately.

Latest progress

The latest progress is within areas where I usually tell myself “Oh, I’ll do that tomorrow”. Detail stuff. I’ve added a couple of states to the Player ship object. “Invulnerable” is one state. This comes into effect whenever you lose a life. You’ll be invulnerable for a couple of seconds, and the graphics display a blinking ship as indication. It’s a classic :) The other state is “AutoPilot”. This basically means that the Player ship object is unresponsive to keystrokes that would normally cause the ship to move or fire. This is useful together with “Invulnerable” whenever the ship enters a new level (It’s a detail, but I always liked that the ship actually entered the screen and positioned itself, and not only “popped up” in the middle of the screen suddenly). Additionally, the “AutoPilot” will be useful in scripted parts of levels.

In addition, I’ve finally added ship-to-ship collisions properly, and most enemies have a score now ;)

Oh yes, and the game can be paused now.

So, alot of small and seemingly insignificant things, but they make everything appear a whole lot better.

Impact and Shield effects

Today I’ve been playing around with the effects in relations to a ship being hit by a weapon. Our ships may or may not have shields, and it’s much cooler if the shield gives a different visual display than a normal impact does. Besides, anyone who has ever watched sci-fi knows shields kick ass. (They recharge! Your hull doesn’t).

There’s still some work left on these effects, but after a good day’s work, I’m pleased. I’ve put together a basic animation that shows a ship getting hit twice. Once when it has shields, (blue effect), and once without.

Shield and Impact Effect animation

It might not have been mentioned explicitly before (I take it for a given!), but if anyone has questions about why we make the decisions we do, or how we implement them, do ask :)