Wednesday, January 30, 2013

Spaceship Warrior Pt 1 (Level 1)

Adrenaline rushes through your veins as the Drop Beast's blood drips from your bare hands.  You have tasted victory, and now have a hunger which can never truly be satisfied.  Back in town, you hear whispers about a new creature plaguing the outlying farms, each of it's 200 teeth the size of a broadsword, harder than diamond, and sharper than a sharp pair of scissors.  The creature is known as Spaceship Warrior, and rumors say that it possesses the power of both libgdx AND Artemis.  You let a slow smile creep into your face: fate has favored those farmers today.  You're on the job now.

You ask around for any information you can find, and discover that a magical scroll is required to summon the monster at will: MercurialEclipse.  You've heard of it before.  This scroll can summon forth anything, you will have to be very careful in its application.

Once it has been properly installed within you Eclipse spellbook, begin the summoning ritual.

On the Google code page, click the "Checkout" link.  Where it says "Command-line access" copy the link, starting with https://...  Back in Eclipse, click File->Import.  In the list of options, find Mercurial->Clone Existing Mercurial Repository, and click Next.  In the URL field, paste the checkout URL from Google and select finish.  In the Project Explorer on the left side of Eclipse you should see a new project called "spaceship-warrior".

Eager to test your mettle against its creations, you browse its source through a file-tree and find, which resembles the launch file you created for Drop.  You tell Eclipse to run it, but, alas.  The selection cannot be launched.  Confusion and rage twist your body as you let out a blood curling scream!  AAAAAAGGGGGGHGHGHGHGHHHHH!!!!!

Once you calm down, you realize the problem.  Somehow, Eclipse does not recognize this as a Java Project, and has no clue what to do with these files.  You quickly form a plan.

WARNING: My solution is probably a pretty stupid workaround.  There must be an easier way, and you may want to find a better solution.

Create a new Java Project, called spaceship-warrior2, then copy the "lib", "resources", and "textures-original" folders into your new project, leaving "src" alone for a moment.  Then, clicking into the "src" folder, you copy the "com" folder (which will come with all its subfolders) into the "src" folder of your new project.  It instantly converts the file folder structure into a package structure like we expected.  Unfortunately our new project is still riddled with errors.

Our problem is that we still haven't included the appropriate .jar files.  Look in the "libs" folder and you will find a collection of "kryonet" jars and "libgdx" jars.  I don't know what they "kryonet" jars do, but they aren't important to include.  Add the libgdx ones + sources.

The beast comes into focus, but there are still errors in the project.  What haven't you done?!?!?!  You recall that the creature also harnesses the power of Artemis, and though no Artemis jars were included in the download, you know exactly where to find them.  You see there is only one jar, and its associated source.  You quickly add them to the build path and watch all the errors fizzle away.  You are eager to begin.

Proceeding to launch, the beast phases into existence, but before you can strike it, disappears again.  Righteous anger flows through your veins.  There were no errors!  What could have gone wrong now?!  You check the console, and find that textures\pack could not be found.  But you personally have no trouble finding it within the "resources" folder.

I'm not yet sure why this happens, but the problem is that the "resources" folder hasn't been added to the "classpath" yet.  Go back to the Build Path under "Libraries" (where you added all the .jars) and click "Add Class Folder".  Add the "resources" folder and run it again.

A large window comes up, filled with stars and a ship which you control.  You blast your enemies to smithereens.  Victory at last.

You gain 50 XP.  Progress to level 2: 50/400

You take a few moments to browse through the code.  Some things look similar, some look foreign.  One thing is for sure, Spaceship Warrior will not be such an easy foe as Drop was.

1 comment:

  1. If you don't want to create a second project, you can do this after cloning:

    1. Delete the "spaceship-warrior" project in Eclipse. DO NOT remove it from disk.
    2. Go to the project folder on your file system and delete the ".project" file.
    3. In Eclipse, create a new Java Project with the exact same name, i.e. "spaceship-warrior"
    4. Continue following the tutorial from the paragraph, "The beast comes into focus..."