Monday, January 16, 2012

Intro time

Hey everyone, looks like it's my turn to introduce myself. My name is Cody, and I'm handling the programming side of Offswitch. That basically translates to Marty saying, "Can we do this?" to which I sigh and grudgingly respond, "Yeah, probably..it'll be hard though.."

Anyways, the goal of this whole project for me has been to learn how to program a video game. I desperately want to go into the video game industry, and figured an internship would be easier to land if I managed to come up with a functional game to show off. Now I'm realizing that though the finished product will prove that I've learned a thing or two, there is much more story in the journey than in the destination. With that motivation, I'm going to be breaking down various aspects of the game and explaining how they are implemented, the history and various redesigns, and even go over planned improvements.

On that note, if you aren't at all interested in programming you may want to stick to Marty's posts! Mine may at times reach a pretty high level of nerd talk. Planned posts at this point include controls, the physics system and main game loop, my asset management system, collision, the level rendering (currently being revamped into a tiling system!), and some of the more advanced mechanics such as enemy states and player transformation. Hopefully I can provide some insight into the various mechanics that need to be considered when programming a game, as well as give other programmers a chance to learn from my mistakes.

Oh.. since Marty's intro had lots of nice pictures, I suppose I should give you some source code to ponder. Check it out: the main loop!


//Main game loop
  @Override
  public void run() {
   // start tracing to "/sdcard/calc.trace"
   //Debug.startMethodTracing("calc");
   while (mRun) {

    if(!updateFlag){
     Canvas c = null;
     try {
      c = mSurfaceHolder.lockCanvas(null);
      synchronized (mSurfaceHolder) {
       updatePhysics();
       doDraw(c);
      }
     } finally {
      // do this in a finally so that if an exception is thrown
      // during the above, we don't leave the Surface in an
      // inconsistent state
      if (c != null) {
       mSurfaceHolder.unlockCanvasAndPost(c);
      }
     }
     //Satisfy flag conditions
     if(restartFlag){
      restartFlag=false;
      doStart();
     }
     if(winFlag){
      winFlag=false;
      level++;
      doStart();
     }
    }
   }
   // stop tracing
   // Debug.stopMethodTracing();
   Log.w(this.getClass().getName(), "Thread exited");
  }

No comments:

Post a Comment