Wednesday, April 6, 2011

Lunaris



Well, I finally have time to post the game I've been working on now. Welcome to the world of Lunaris. Lunaris is a game where you and your friends race through a beautiful 2D world engulfed by darkness. Along the way, you will discover new paths or hinder your friends as you avoid deadly spikes and bottomless pits. Our game supports dynamic lighting and drop in/out support for up to 8 people on multiple computers. If you don't have multiple computers, no sweat, we have support to play locally on a single computer. But why bother telling you about our game, check out our video created from our cool game designer, John Doran.

I hope you enjoyed that. But you are probably wondering what my responsibilities where? I'm the tool's programmer for Lunaris. I was responsible for the window engine and stencil editor. I will go through each in detail as to what it's for and challenges I had along the way.

Window Engine
You are probably wonder why one needs a programmer dedicated to window programming. One of the major goals we wanted to accomplish was to create a series of tools so that we can basically generate any game possible. Lunaris is basically one of the products of that goal. Because we were going for these series of tools, we decided early on that we did not want a single window where every possible tool lives in. We wanted different editors to exist independently from the game window. From there, it was logical to build a window system that generates new windows without ever leaving the game.

Know what we wanted, we encountered quite a few major problems along the way. Creating a single window is simple. You can basically find them online or just google search it. We chose to take it even further by making our game multi-threaded. If you ever worked with window API's before, you know that the window codebase is really old and was never built with multi-threading in mind. Not to mention, we had to display each window differently unlike most tutorials you find in multiple window development. This was just a quick and broad run-through of the challenges I had to face. For more specific challenges, look at the list below.

- Legacy code from window's API
- Race condition when drawing to a specific window
- Window-to-Window communication in a threaded environment
- Drawing artifacts
- Re implement all basic window controls like resize, fullscreen, etc

Stencil Editor
I'll begin by explaining what a stencil is in terms of our game. A stencil is essentially a template for those who know C++ or instances in Flash. Everything in our game from the buttons you press to the tiles that make up the world of Lunaris are entities. The stencil's job is to tell the game engine how a entity works. There is a one-to-many relationship of how stencil works. For example, we can thousands of different buttons, but they all use the same stencil to give it behaviors and functionality.

Now that you have a basic grasp of stencils, I can go into detail with my stencil editor. The editor is a developer's interface to our library of stencils. Here, you are able to create new stencils, edit existing ones, and just define the stencil in code without ever entering Visual Studio or the like. In the video you will see below, you will get a better understanding of what's going on. As for challenges, I had to face the fact that we were using our own scripting language. Because we were developing our language at the same time I'm working on this, we were blocking ourselves as everything about the language wasn't perfect in any regards.

As I did so with my window engine, here is a bit more detailed list of challenges I had to face.

- A majority of the GUI material like listboxes, scrollbar, etc DID NOT EXIST; I either had to make them or make them flexible enough for multiple uses.
- Our scripting language wasn't to the level we wanted it to be early in development
- Non-sensible crashes or compiler/run-time errors
- Way in over our heads in terms of development time and code to accomplish




To close up this post, I'll go through what the video above is doing. The first thing you see is the game window until I open up my stencil editor.

0:23 - 0:42 = Demonstrating the power of my window engine as both the game and my editor are working independently of each.

0:42 - 0:55 = Notice how I close the game window and yet, my editor is still functioning properly.

0:55 - 1:08 = Here, I'm showing how I select a particular stencil and look through its properties like variables and functions it contains. Notice how in the variables tab, I can see what each variable is initialized with. As for the functions, notice the function name along with the type of function it is.

1:08 - 1:18 = Showing how to add new functions to this stencil.

1:25 - 1:39 = I'll now demonstrate a simple example of using my stencil editor. We're going to change the size of the cursor.

1:39 - 1:53 = I "could" change the size of the cursor in code by using our in-game text editor, but that seems too much for such a simple task.

1:53 - 2:06 = Instead, let's change the initialization of the cursor from Vec(40.0f, 40.0f) to Vec(80.0f, 80.0f).

2:06 - 2:40 = Apply our changes and the game resets back to our current state. VOILÁ. Our cursor now is twice the size it was before. Notice also that closing the properties window and reopening it shows that our changes have been committed.

2:40 - 3:03 = Just so that my teammates won't yell at me for this change, I'll return the value I changed to it's original value and commit that.

Wow, long post. If I left anything out or something is unclear, please post a comment or email me anytime. I'll have a download link of our latest build of our game as soon as it's ready. Cheers.

Friday, February 4, 2011

A Different Look at Unit Testing

Today, I just wanted to put something out there that just came to light. So, recently, I've been working with my game team at DigiPen for awhile now and I noticed how often we ended up asking each other for whatever they were responsible for like text, graphics, physics, etc. Questions came up like "How do I get this text to show up?", "what am I missing to get this to work?", "how do you use this something() function call?" I started thinking of how I would help fix this. Then I started thinking of unit testing. Weird, I know. I understand how unit testing is there to help flush out initial bugs early on before they grow like a virus. But what happens after the unit testing is finished and done with? Why not use them as sample code for the other programmers?

For example, a programmer in charge of the level's editor needs to add text to various spots. He could try to find the guy who worked on the text system or look through their database of code for something similar to what he is trying to do. If the company set it up so that every unit test is stored somewhere for easy access, that programmer can easily read and figure what he needs to do while staying productive. I'm not trying to condone asking questions or communicating with your colleagues. I'm just saying that by having access to well established unit tests or just any type of unit test in general will greatly remove any or all black boxes the programmer may see or encounter.

Personally, I'm fine answering questions about the system I've built. But if I get too many questions of the same thing, then it's probably best I create a unit test of how it should basically be used than constantly giving the same answer. Not only am I helping my fellow programmers understand how my stuff is being used, but I also test to make sure my stuff to top notch.

Well, anyways, that's my two cents for today. I just thought I share this as I thought this was an interesting way to stay productive.

Update for GDC

Alright, so I've been updating my site and resume a lot lately, as you can see. I just uploaded a new version of my resume today with a few grammatically fixes that just came to light. Hopefully no one noticed them.