Post tutorial RSS Altering the ASOD Universe, part 2 (asteroid belts and gas clouds)

This is a guide to altering ASOD to have custom asteroid belts and gas clouds. You need the source from asod.dev.java.net .

Posted by on - Intermediate Client Side Coding

Asteroid Belts
Ok, im assuming you did the part 1 tutorial before this. You should know how ASOD stores and retrieves data on celestial objects and how to place them in a desired solar system. You should also have done the garbage collector tutorial.

First lets look at some sample code that makes the "Asteroid Belt 1" in Ziaac.

space[3] = new cosmos(2, 1001, 9632, "Asteroid Field I");
            space[3].setSolarSystem("Ziaac");
            space[3].setPlanetTexture(Toolkit.getDefaultToolkit()
    .getImage(getUrl(
    "test_asteroid_0003.png")));

The code got a little disorganized on the site, but you can tell what it does. You see it has a planettexture like a planet or station, and is loaded in th same way. You see the name and position are declared the same way and that the solar system is set the same way.

There are differences, look here:

space[3] = new cosmos(2, 1001, 9632, "Asteroid Field I");

Notice the 2 after cosmos( . This is the new type declaration for asteroid belts. By making a celestial's type 2, you are making it an asteroid.

What does Type 2 mean in-game?
An object of type 2 is an asteroid of some kind. It can be mined releasing raw ore.

Gas Clouds

space[4] = new cosmos(3, 5600, 10034, "Riol Nebula");
space[4].setSolarSystem("Ziaac");
            space[4].setPlanetTexture(Toolkit.getDefaultToolkit()
    .getImage(getUrl("test_gas_0004.png")));

That code is for the Riol Nebula in Ziaac. You see that it is essentially the same as an asteroid belt. However, notice the type of 3 instead of 2. This means that in-game it shows up as a gas cloud on the HUD and it released stellar gases when mined.

Remember
Never forget to hook the garbage collector, due to size these objects take up especially high amounts of memory.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.