Sunday, April 22, 2012

StarWright - The Sandbox

Wow, it's been over two months since I last posted about StarWright! But I have been working on the game. In fact, I've been working on a very important change that should make the game much more accessible, understandable, and fun.

A few months ago I watched a talk by Bret Victor called "Inventing on Principle". In it, he talks about and demonstrates a few of his software programs he's created. A common principle of all the programs he shows is that they provide immediate feedback. For example, he demonstrates a scripting program in which he has created a prototype for a platform game. The left side of the screen contains a running game simulation, and the right side of the screen contains the game's programming code. Unlike most old-school programming languages (in which the author writes the code, compiles the code, and tests the code as three separate steps), as Bret modifies the scripting code, his changes immediately effect the game running on the left, so that as he modifies, for example, the gravity in his game world, he instantly sees the character fall faster or slower (or even upwards!) as he adjusts the gravity value.


Bret Victor - Inventing on Principle from CUSEC on Vimeo.

The key here is that all his changes have an immediate effect on how the game is played. This greatly speeds the design process, because every time you change a value, you can immediately see the result. And just as importantly, it makes, in his case, the scripting process much more intuitive, because our human brains are much better at connecting a cause with its effect if the effect happens immediately after the cause, instead of, say, a few minutes later.

I found his talk very inspirational because it made me realize that the "ship designer" user interface that I had created was born from an "old-school programmer" mindset. In the previous version of the ship designer, the player first "designed" a ship, then saved the ship, and then tested it in a separate simulation environment. The problem was, of course, that you couldn't tell what effect a design modification would have until you manually switch to the testing environment. The solution, I believe, is to combine the design interface with the testing environment, so that the player designs their ships directly in the testing environment and can see the immediate impact of, for example, adding that extra thruster.

Merging these two environments together was certainly not trivial. Allowing ships to be updated instantly in a live environment was a challenge, and keeping the nice U.I. features of the designer, such as undo/redo, was a bigger one.

I've dubbed this new merged design/testing environment "The Sandbox". Here are a couple screenshots of what it looks like currently:




Upon first glance, the top screenshot does look quite similar to the old designer interface, which has a similar menu bar at the top and a similar "parts toolbox" (albeit with more parts) on the left. But there are a lot of very nice additions to the old interface:

  • The "Build" and "Play" buttons underneath the menu bar allow you to toggle between the build/design mode (which allows you to modify any ship in the sandbox) and the play/control mode (which allows you to control any ship in the sandbox as if you were playing a real game).
  • There can be any number of ships in the sandbox, and every ship is a live simulation. Added a couple thrusters to your ship and want to see how it flies? Just switch to Play mode and fly it around! Not quite happy with the result? Switch back to Build mode and add another couple thrusters.
  • Any previously-saved ship design can be added into the sandbox by loading it from the Ship menu.
  • To create a new ship design, you plop down a new "grid" anywhere you want, in which you can start placing parts for your ship.
  • To modify an existing ship, simply go into Build mode, select the part you want, mouse over the existing ship, and click where you want the part to go.
  • You can pause or resume the game simulation at any time using the control in the upper right. It's often easier to modify ships while paused. Unpause and the simulation will instantly resume with your new edits.
It's not perfect -- for example, I'm not thrilled with the hard separation between Build and Play modes -- but it's a huge step forward, and the technology behind this could allow me one day to expand the sandbox into a full-blown live level editor.

No comments:

Post a Comment