Blog Post 2: Under the Hood

Welcome back!  If you’re reading this, I must’ve piqued your interest, so great!  This will probably be the last week I can devote a large majority of my time to my project as I begin my summer session back at Oregon State this Monday.  I’ll keep working on my project here and there, but keep you all updated regardless of what happens.

Keeping the same format as before, let’s run down through what I did this week.

Monday:
This day was devoted to moving back from Foster City to the Monterey area as me and my fianceè are bouncing between two locations for her work.  The reason it took all day was due to cleaning the apartment, packing up there, and unpacking in Monterey.  If you’ve done this before, you can understand how long this can drag out.  If not, you are a very lucky person indeed.

Tuesday:
What I’m sure you’re all waiting for, I continued working on my Battleship project. I picked up where I left off last week and continued to remove every hint of GridWorld remnants from my play windows. This included: removing buttons, sliders, and extra menu options, replacing the icon picture and text, adding a blue background, and resizing the setup GridWorld window.  I’m definitely far from finishing the final touches to my layout, but I love the improvements already.  Below are the results of this work:

Before:
Battleship Setup Window_Old

After:
Batleship Setup Window-Updated

I also removed the JAR file (a cluster of code files you can use but not modify) containing GridWorld and manually added the source code packages to my project.  The people from the AP® Computer Science GridWorld Case Study kindly provided all these files.  Finally, I could access their source code to morph my project into whatever I want.*

To test, I created an executable JAR file and sent it to another computer to see if it would run.  It did, but with a few hiccups.  The code was running very slow and crashed.  I realized if I was going to be able to give you guys something to try, I would need to go “under the hood” to see where I could remedy a few problems.

Wednesday-Friday:

Thus, through the bulk of these three days, I did just that.  I took a critical look at all my code and found places that had been patched together too quickly.  Being my first time ever programming a game from scratch, things were a little disorganized.

After moving some code around into their proper classes to conform my code to good programming practices, I noticed something funny.  Hmm, why are there “while loops” holding my game hostage while waiting for user input?  I ran my game while looking at my task manager, and to my dismay, found that it chewed up a good portion of my memory while running (well not A LOT, but more than you would expect).

For those not versed in programming languages and such, it’s really the equivalent of your child (or maybe you at a young age) asking, “Are we there yet?”.  However, instead of 10-20 times for the trip, the computer asks the user about 25,000 times per second while you decide where to move.

Well, I had found my problem!  Originally, when I first wrote the code back in April/May, I looked into ActionListeners.  These basically tell the computer when the user did something on the mouse or keyboard instead of the other way around.  However, because ActionListeners were out of scope of my course, and I was running out of time to implement the rest of my code for my final project, I had to settle with while loops.

This was a big lesson learned as I realized that by designing my code around the use of the while loops, I then had to re-design a lot of my code to work with ActionListeners.  I’ve been working on it for the past few days and and still hacking away.

All hope isn’t lost though!  I’m about 90% finished reconstructing parts of my code and it looks and performs better than ever.  I’m planning on submitting my first prototype to the website once this is complete so you guys can test it.

Going Forward:

As mentioned before, I will be in class this coming Monday, so my project updates my be a slower at first, but I will keep you updated with what I’m doing in the meantime as to keep you all in the loop.

Current Goals:

– Create executable to post to the website and update the project page

– Stabilize my school schedule to return to my projects.

Well, I believe that covers everything.  Have a great weekend and I’ll talk to you next week!

* The GridWorld Case study is free software under the GNU public license.  Though I am now changing their source code, all files created by them will still show them as authors and I only include myself as a collaborator to code I add myself (noting where my changes are located).  My only intent is to use an existing Game Engine (so to speak) to build my game from, not plagiarize their work.  That’s not cool, man.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s