Tuesday, September 23, 2008

Blog Post update.

Check out the date for reference. Today I began the task of writing Tutorial 1's code, and tonight will do Tutorials 2 and 3. Unfortunately, the fact that I was late today resulted in Rob also being late, so, I hope to get myself in gear and crank out all the work I have to do this week. I hope to be caught up by tonight, however.

Tutorial 1 is very simple code, but it exposed a bunch of the little interesting chunks in Project Darkstar's client API. For example, it forces you to program in a multithreaded way. While you're trying to log in, you have to spin your wheels until you get a reply from the server. So, in my hack of a tutorial (A tutorial is meant to get your feet wet in a subject, of course, so it's a little hackish), there are 2 classes: The client listener and the TutorialWorld class. The tutorialWorld's purpose is basically the same as it would be in a game world: It has a while loop that keeps the main thread busy. Essentially, the loop is something like:

While(NotBail) { If(LoggedIn)P{ DO STUFF } }

Since the main loop is just reading the 2 booleans, writing to them is safe from the Darkstar Client Thread, which from the client code, looks something like:

public void LoggedIn() { world.LoggedIn(); }
public void LogInFail() { world.Bail(); }
public void Disconnected { world.Bail(); }
public void HitTheFan { world.Bail(); }

Technically, the main thread's while loop could feasibly be expanded to "if(LoggedIn) {Do Game Stuff} else {Do Waiting Stuff}" for a visual game. However, for the sake of this project... nah. Not needed.

Tutorial 2 here we go.

No comments: