Thursday, April 12, 2007

A Technical View of the Project So Far

This post presents a technical view of the project so far. Generally I don't go into internals on this blog, because the audience is largely non-technical (the children involved are part of the audience). Most of the focus is around the concept and design of what SplotchiTown is, and how the children interact within the project. After all, the goal is really around them, to see what they can take out of it.

However, it is a software project, and there are of course many technical aspects, so I will add posts labeled "technical" every now and then when I feel there is something to be said. Warning: non-technical users may get lost in the technical posts!

So to start off, a little about the tools and development environment. I am currently using mono 1.2.3 on an Ubuntu Feisty (beta) laptop, with monodevelop 0.12 as the IDE. By the way, I think the teams involved in these projects (and related projects like Stetic, the UI designer embedded into monodevelop) are doing an awesome job. I can't wait for the debugger, however!

The application itself is a Gnome# application, so using Gtk# and Stetic for the UI. It's basically a one-window job at the moment. The graphic section uses a Gnome Canvas. I pondered (and am still pondering) the use of a GtkGLArea and rendering in 3D, but I might leave it until later. For now, simple is good.

I've decided to keep the application structure fairly simple and literal. I have talked to the kids about what 'class' and 'object' mean, and I want to back it up by being able to show them pieces of the code at times, and in particular pieces of the model classes (like 'Creature'). With too much abstraction and cleverness, they will not understand any of it. So I'm keeping it quite literal.

Time in the world is measured in real seconds. So the environment has a time, in seconds. And creature age is also measured in seconds. There are two timers. One clicks every second, and is responsible for non-visual updates (like digestion). The other is every tenth of a second, which is responsible for visual updates.

So far I have some model classes, as follows:
  • 'Thing' is a base class for all things in the world. It implements behaviour such as placement and movement in the world.
  • 'Creature' is derived from 'Thing', and implements the key properties of a creature in the world, such as energy, health, age, emotion etc. It's behaviour so far includes consuming food, "digestion" (food converted to energy over time) and death. Much of the work of the system is going to go into the behaviours of the creature.
  • 'Food' is a simple class at this stage. A food object is given to a creature to consume. Each food object has amounts to contribute towards energy, health and happiness of the creature consuming it. The contributions can be negative. For example, a bowl of rice will contain alot of energy, but probably not much happiness. A lolly may have no energy, negative health but alot of happiness.
Two classes exist for visualising things on the canvas:
  • 'ThingVisual' corresponds to 'Thing'. It doesn't implement much behaviour at present other than detecting if the underlying things' position has changed, and if so, changing the position of the CanvasGroup object that represents the thing on the canvas.
  • 'CreatureVisual' corresponds to 'Creature'. It handles the visual behaviour of the creature, which at this point is displaying the appropriate image for the creature based on it's properties. The logic for selecting images is at present crude and hard-coded. It uses a CanvasPixbuf object to hold the image. The images are compiled as resources into the application.
Food digestion in the creature is an interesting area. I wanted to model digestion within a person. At present, food is converted to energy in chunks, so it takes a few seconds to digest the food and convert it to it's energy potential. The food object has numeric contributions to energy, health and happiness, and all three measures are converted the same way, ie over time. Two enhancements I want with food are the ability to digest the 3 measures non-linearly (a bell curve possibly for the energy component), almost immediate with happiness. I also want the rate of digestion to be relative to both the food (e.g. rice is easier to digest than meat) and the creature (i.e. the creature has a metabolic rate).

The next two areas that need attention are:
  • Selecting creatures and giving them instructions
  • Movement of creatures, which includes handling the presence of other things (or creatures).

1 comment:

B said...

You are a very clever person!