• entries
65
133
• views
77526

# Do Androids Dream of Electric Chairs?

229 views

So, I've been working on the Intangibles. Otherwise known as the Unscreenshottables. Those things that improve the innards of the whole system, but you can't really show off.

But first! A screenshot of something (to prove that my renderer can display more than just chairs):

Click to enlarge

One goal of this whole thing is that absolutely NO game logic will exist within the main EXE. It will all be loaded from script files (and eventually managed code assemblies).

I've gotten that up and running. The "scripting language" that I'm using is, in fact, C#. Basically, a script is an entity in the world, or an event, or any number of other things. They all derive from the IScript interface, which really requires three functions be implemented: OnCreate, OnTick, and OnKill.

I've exposed certain things to the scripting, like the math functions (vectors, matrices, quaternions), Camera control, texture/model loading, etc. There's no direct access to the renderer, it's all through the world data. You add objects into the world (which is setup by the main script), and it handles the rest.

I'm trying to make it as simple as possible.

Here is a sample script (for the rotating chairs that you have seen in videos past):

using System;using Cubic.Scripting;using Cubic.Math;class RotatingObject : IScript{  IGameRenderable renderable;    float angle;  float rotSpeed;  Vec3 position;  static Random ran = new System.Random(190329);  IScriptHelper helper;  const float objectRange = 400.0f;      public RotatingObject()  {  }    public void OnCreate(IScriptHelper helper)  {    this.helper = helper;        string[] filenames = new string[]     {       "ChairModel.xml",      "ChairModel2.xml",      "ChairModel3.xml",      "ChairModel4.xml",    };        // Randomly pick a filename from the list    string filename = filenames[ran.Next(filenames.Length)];    angle = 0;    // Choose a rotation speed    rotSpeed = ((float)ran.NextDouble())*0.006f + 0.002f;    if((ran.Next()&1) == 0)      rotSpeed = -rotSpeed;    // Random position in a cube    position = new Vec3(((float)ran.NextDouble() * objectRange) - objectRange*0.5f,                        ((float)ran.NextDouble() * objectRange) - objectRange*0.5f,                        ((float)ran.NextDouble() * objectRange) - objectRange*0.5f);    // Load the file (the true means to load synchronously, instead of caching the load for later)    renderable = helper.CreateRenderable(filename, true);    renderable.Position = Matrix.Translation(position);    // Add it to the world (static update - which means it can move in place as long as     // the bounding volume is sized big enough to cover the object's entire range of    // motion    helper.AddToWorld(renderable, ObjectUpdateType.Static);  }    public void OnTick()  {    // Rotate, and update the position matrix.    angle -= rotSpeed * 5.0f*3.0f;    renderable.Position = Matrix.RotationAxis(Vec3.Normalize(new Vec3(1, 1, 0)), angle)* Matrix.Translation(position);  }  public void OnKill()  {    helper.RemoveFromWorld(renderable);  }}

All-in-all, not terribly complex. It doesn't have to deal with the renderer, or any major craziness. It just loads its object, adds it to the world, and goes about its thing.

There's also a main script, which handles the initialization of the entire system (its filename is hardcoded into the exe - it is really about the only hardcoded thing in the system). Also, type scripts: these are scripts which are used as references by the other scripts, so the scripter can define custom types that can be used throughout the system.

There is currently no sound or network code, but graphics and input are working (well enough for now, anyway).

I still need to add actual mouse pointer support (instead of just mouse deltas), and I want to set up a menuing system, and then I'm going to work on scripting a little card game (which I will, sadly, not be able to distribute because it will be based off of an actual for-sale game, in this case Cheapass Games' Cube Farm).

It should prove a nice little test of a simple game.

Also, I've been working on text and UI display, some elements of which I have working:

Click to enlarge

Yes, that screenshot is back to all-chairs. Chairs are a classic!

But enough talk. HAVE AT YOU!

There are no comments to display.