Tag Archives: ODII

Orbital Defense II – Update 2

 

2013-02-12a

I got a lot done today in my work to update Orbital Defense.

My goal was to get player units working today.  For the basic functionality I really only need one unit in place so I just updated the basic attack unit.

First up I added in the graphics for it.  In the original I wanted the satellites to rotate or at least have some bit of animation.  With LibGDX it’s pretty simple to handle animation so I now have them rotating, which is nice.

One thing I had to fix in the conversion was the placement of satellites.  The coordinate system is different between the standard android canvas and LibGDX.  Basically the Y axis is reversed  in Canvas 0 is at the top, in LibGDX 0 is at the bottom.  I knew this was something to keep an eye out for so as soon as I tested it and saw the results I knew the change I had to make.

2013-02-12bNow that I had satellites placed on the screen I need to get them to move.  Moving something smoothly around a circle takes a bit more code then one might imagine but luckily all the code I had written still worked perfectly.  I needed to make some adjustments based on changes I’ve made to where variables and methods are coming from, but nothing about the calculations needed to change which is always handy.

Since satellites could orbit I figured they should next be able to attack.  Since I have meteors already in place, we have targets for the satellites.  This was code that once I took a look at it I was able to reduce it down to far fewer lines.  The general logic is still the same, i just get where I need to be a lot quicker and removed some of the redundant branches.  Basically it checks to see if it still has a valid target, and if not finds one.  Once a target is found it fires on it if the satellite is ready to fire. My original code for this logic took up about 50 lines, my new code for it takes up 20 and performs the same job in a more efficient way.

Part of attacking is that you want to see it on the screen, so I had to work out some better code for that.  Previously I only had the attacks on screen for a frame or two, but with faster running frames this doesn’t really work so it’s all time based now.  It is still only on the screen for 0.15 seconds but it is enough that you see it happening.  I will probably adjust that number further as I work on things more.

Once I had code for satellites attacking in place I could just copy the same code for enemy attacks. Even though I don’t have any enemies that shoot in place yet, the logic stays essentially the same.

I do have meteors though, and the way that those attack is by hitting things, so I needed to put collision detection in place.  One thing that is nice for simple collision detection in this game is that everything is more or less bounded by a circle.  What makes that simple is that all you need to do to check for a collision is find out the distance between the center of the two objects and see if it is smaller than the radius of the two objects added together.  Everything in the game has an impact damage assigned to it so I just subtract from the health of both objects.  Of course I couldn’t leave things that simple though and I currently have two special types of satellites that don’t obey the same collision rules.  The easy one is the Bulldozer satellite, specifically designed to take out meteors and other objects.  It takes no damage from impact.  The more difficult one is the Bouncer satellite.  Bouncer satellites deflect meteors and neither takes damage.  Handling these requires figuring out tangents and reflecting angles and all that jazz, which I had figured out previously and have code for.  Right now I’m hoping my old code will work fine, as soon as Bouncers are added back in I specifically need to test them.

After all this added code I can then just simply check the health of all allied and enemy units and destroy the ones below 0, with a little quick explosion that I think I want to expand later on.

Basic game play is more or less in place with all these additions.  What I really need to do next is add information to the screen.  You currently do not know planet health or current resources, vitally important data to actually know how the game is going and what actions you can take in the game. I think I will work on those tomorrow as well as start working on the main menu screen and other non-game screens, which will all be new with the change to LibGDX.

In completely unrelated news, my Flynt Flossy shirt came in yesterday which is awesome.  Here is Turquoise Jeep’s latest video:

Orbital Defense II In Progress

So I kind of started One Game a Month last month, though my first game didn’t really fully come together what with being sick and having a prototype to build for actual work.  For February I’ve decided to update an old game of mine, Orbital Defense and making Orbital Defense II.

ODII 2013-02-11a

The first order of business for the update is that I’m converting it over to use LibGDX.  This is the framework I’ve used for my later games.  I think it will help it run better and just look nicer overall.  I’m still in this stage of the process, to the right is a screenshot of the current progress.  The star field is twinkling, the Earth and the orbital zone are there and meteors are being created and run across the screen.

I still have a long ways to go, I need to add in all the other units, take care of unit collision and attacks, add the info bar and unit selection bar, etc.  There is plenty to do here to have it converted and ready for the next step.

The next step will be updates.  Since this is a tower defense type of game one big one I want in there are upgrades for satellites.  This is really something I should have had in the first version but I just didn’t have a good plan in mind for how to go about it.  I feel like I do now and it will work out nicely.  I also want to add more satellites for the player to use, and perhaps a selection screen to decide which satellites you use.  I want it to also have levels and more wave style gameplay for enemies instead of the random enemies it currently throws at you based on difficulty level.  I’d like to do something more with the graphics as well, at least update how it looks so units are quite so cheap looking.   Overall I just want to make it a better game that continues to be fun.

That is a lot to do, and the way I work I’m not sure it will be done this month so this might be an entry for another month.  Either way, this is something I’ve decided to do so hopefully I end up with something interesting.