Sunday, May 6, 2007

More visual progress

I have been working many evenings on getting all the visuals going for SplotchiTown. I had a brief session with the children last night to update them on what I was doing. I kept it short because they were all tired from a busy weekend. They just wanted to press the space bar to make the creature jump, the way the car did!

The two main things now are the creation of a "creature", and having a map.


Here is the map. The creature is the white blob. The rooms (to be) are:
  • front left - bedroom
  • front centre - hallway (may be a little wide)
  • front right - bathroom
  • back left - dining room
  • back right - living room


Here the creature walks off the world for a close up. You can see some of the polygons on the creature's body.


The creature walking through a wall. There is no collision detection yet.


Here the camera view is from above and slightly behind the creature, to give the creatures' view of the world.

The creature is a mathematical construction. The bottom half is a hemisphere, the top half a stretched hemisphere. The display list is mathematically calculated using several horizontal slices and 32 radials. The legs use the same display list, basically an octagonal "cylinder", calculated the same way. The eye is a textured rectangle. I don't have a texture for the creature's body yet. The legs use a separate display list from the creature so I can animate their movement later.

Creating objects for the space is going to be one of the biggest challenges I think. I lack the skill to know how to make 3D object shapes. I've got Blender which makes it easy (well, easier) to create the models, but I don't know how to get it's models into my program. I need to work on that soon to make faster progress.

On the map side of things, I've drawn a birds-eye view map, which has 6 rooms and some outdoor spaces to build things. I've implemented four of the spaces so far, but can't really extend it visibly without changing the fixed camera model.

The map itself is an XML file that describes the domain objects that define the space (so far only walls).

Monday, April 30, 2007

Cool Changes Happening

After processing the list of feature requests in the previous session, I had a serious think about visualisation of the SplotchiTown environment. Many of the features are very visual and the 2D GnomeCanvas used so far will be limited in how well it can present those concepts.

So I've built a test application using OpenGL, which I've never used before. It's quite a learning curve, and in a way it will make SplotchiTown harder to code, but man, the visuals are way cool!

I've been working on the test application since the last blog. It lets the user drive a little "car" around a flat plane with 3 walls around it. The car can jump, and the camera rotation and height can be adjusted.

Here are some pictures:


The default view.


The car jumping.


The camera on the car.

I had a quick session with the children to tell them what I was doing. I drew on the whiteboard what our program looks like in 2D, and what it may look like in 3D. They got this because it's just like most of the PlayStation games that they play.

The clincher was this, with the "wallpaper" enabled when I pressed the 'W' key:







They have bought into the concept. Now it remains for me to get the previous creature working in OpenGL!

Monday, April 16, 2007

Childrens First Play

I had a fairly long session with the children late yesterday afternoon. We covered a number of topics.

First, I pinned up a couple of sheets I had done. One was a "dictionary", with easy definitions of class, object, property and method. The other was essentially a UML class diagram showing a single class, Creature. The class showed the properties we had talked about previously (name, age, energy, food level and health), and a single method (die).

Then we did a little exercise. I got them to go into the lounge and stand in a place. I told them that the creatures in our program are in a flat space, like the lounge, and tried to elicit from them what other properties and methods we might have to give to our creatures. They all identified that the creature had a place, a position in the world, but the methods around this were a bit of a stretch, so I told them we needed a method "moveTo" which instructs a creature to move somewhere in the space. I asked Benj to stand still, and for Emily to stand in the same position as Benj. She stood right in front of him, and I said "no, stand exactly where he is", which of course she couldn't. So we concluded that creatures cannot share exactly the same space.

So, I added Position as a property of Creature, and MoveTo as a method. I very quickly explained with the aid of a diagram what coordinates are, which are the data type of the Position property. Olivia got it - she had seen it at school. Benj and Emily were a little bemused, so we moved right along.

Seeing that they were pretty focussed (especially for the time of day), I pushed into new territory. I explained that a creature was a kind of thing that appeared in our world, and asked them if there were different things, and pointed to our lounge as an example. They enumerated various things in the lounge such as chairs, bookshelf, TV etc as being other things. I asked if these things would have the same properties and methods as a creature, and there was a mix of yes and no.

So I drew up a new diagram on the white board, this time with two classes, Thing and Creature, side by side. And I drew an arrow between them, the UML symbol of inheritance. I explained that a Creature was really a type of thing. I said some of our properties and methods apply to all things, but only some apply to creatures, and we went through the original Creature class, and for each I asked them where it belonged on the new model. They got it pretty quickly, that Position and movement belong in Thing, but energy belongs in Creature. So that was good. We had a little discussion about 'Age', because all things have an age, but we are really only interested in the age of creatures in our system, so we left Age in Creature.

I introduced a new class on the whiteboard called Passive Thing, and said this was a class for things like furniture, which are not alive, don't move by themselves, and just "are". Does it inherit from Thing? "yes!" Does it have position? "yes!" Does it have energy and properties of a creature? "no!"

In that process, I was struck by two things:
  • How children so totally absorb what you are saying if it's pitched in words and examples they understand.
  • How children can quickly grasp even abstract things. Emily, only 7, understood the essential characteristics of inheritance almost immediately. She could see where things inherited in the class diagram, and where they did not. She was surprised with herself, too, that she got something seemingly as complex. I have in the past explained inheritance to non-technical adults - it takes them alot longer to grasp it.
Figuring that I gotten really good mileage on the conceptual stuff, they were rewarded with seeing the program as it now stands. I showed them how to create a creature, how to move it and feed it. I showed them how the "face" of the creature changes according to it's properties (I actually showed them the source code that calculates which image to use depending on the energy and health levels - Olivia connected it at once.)

Then I let them each have 5 minutes playing with the program (timed - everything has got to be fair!!) It was cool to see them excited by it. The feeling of power over the creatures (you can kill creatures from a menu item - which Benj did with glee!) Creating lots of creatures (Olivia created about 20 creatures, and then realised she wasn't able to keep them all fed, so most of them died!) Emily's main focus was to create a couple of creatures, and give them meaningful and cute names, and meticulously ensure that they were completely happy and healthy, a much more emotive interaction than either Olivia or Benj.

After that, I got out another piece of paper, and asked for ideas of what can be put into the system next. These were the ideas:
  • A house (Benj)
  • Letting a creature sleep (Emily)
  • Furniture and other objects: table and chairs, bed, washer, dryer, sewing machine (All)
  • Food - I said we'd talk more about this next time. (Emily)
  • The creature should grow visually with age, and have more capability as it gets older. (Olivia)
  • Music (Emily) and sound generally (me)
  • Friends and family (Emily)
  • Pictures on the wall (Emily I think)
  • Upstairs and downstairs [like our house] (Benj)
  • Cellphone, and talking (communicating, more generally)
  • Creatures can swim (Benj)
  • Clothes (Emily)
  • Toys and playing (all)
  • Different spaces
  • Light, day/night
  • Trees (Olivia)
I added a few:
  • Creatures can carry things
  • Money, buying and selling
  • 3 dimensional space, specifically a space that is not flat
  • Group behaviour for creatures
And finally, here is the UML diagram we've ended up with:

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).

Visual Progress!

Last night I started work on the visual presentation of the creature in it's world. This will help make the project more tangible for the children, so there is something cute with colour that expresses something.

Here is a snapshot. It shows an area with a happy little green creature on it.



Here is the same creature, but now sad, because it doesn't have enough energy to play.


And here is the creature dead on it's back, because I killed it.


Very rudimentary, but the bits are starting to take shape. Also not shown here is the "sick" creature when it's health gets low. I drew the images in about 5 minutes, including the background (trying depict an indoor space and an outdoor space, something that needs some work!)

I've decided to keep the visuals very simple, just being a two-dimensional world that has objects in it, including creatures. The UI needs to be designed in a way to support multiple creatures, because I think there is really interesting potential there, and I want the children to see that aspect, something they don't see in their tamagotchis.

Olivia and Emily are away for a few days, but I'll get them together with Benj when they're all back and I'll show them where it's at. Mostly to cement the concepts that we've talked about so far, and to keep their interest going. I'll also think of some way they can contribute to the design of what is going on so they feel part of it.

Wednesday, April 11, 2007

Progress

It's been a couple of months without progress, because I have been too busy with real commitments. However, I have recently started working on SplotchiTown again.

I moved the development off the kids home computer to my work laptop, which gives me easier access to working on it, as well as a better working environment.

I've implemented a rudimentary model for a "creature". The creature has energy (0-100), health (0-100), food level (i.e. how full is the creature's stomach, 0-100). A timer has been added to "ping" the creature each second, which allows for time-based adjustments to the above variables. Food translates to energy. Energy is required to maintain good health. Energy slowly decreases on idle.

I got this creature working in the environment. It is very basic, and you can only see the numbers for the variable. All you can do is feed it, which keeps it alive. If you don't, it dies.

I had about 15 minutes with the kids after dinner, so I decided to show them what I'd done. To my amazement, they remembered what we were doing from January. After showing them how the variables change in the program running, I drew on the whiteboard to show them the concept of class and object, which I had told them 3 months ago. Again to my amazement, they remembered what a class was, what a property was and what a method was. So that was successful.

The next challenge will be to extend the interface to include an "emotion" variable, how the creature feels in basic terms. The other variables will have a bearing on this.

I need to introduce food in a more complex form, too. At the moment, food is just a number, so it's like all the creature eats is sludge and that keeps it alive. I will introduce a food class, so there can be different foods. Each food will contribute something towards energy, something towards health (like vitamins), and something towards emotion (e.g. ice cream has a higher "happiness" content that a bowl of rice, for example, but not as much energy content.

There are so many possible directions that I have to keep my mind clear and focussed, and stick to implementing the basic dynamics well first. Getting a good handle on the variables and their dynamics is important to establishing realism.

Another deviation from the tamagotchi concept is to use the visual area spatially, so it becomes like a little virtual world ala the sims (but simpler and with cruder graphics!)

Saturday, January 27, 2007

Humble Beginnings

Here is the first screenshot on SplotchiTown. Just for reference. It is completely non-functional, with no dynamic behaviour.