[ Content | Sidebar ]

Archives for 2010

Voyages in foreign parts

May 3rd, 2010

I’ve been abroad! After dodging strikes and volcanoes I spent the last ten days riding around central Europe on strange foreign trains. Here is where I’ve been:


View Europe rail trip in a larger map

Was good fun! Predictably I’ve taken lots of photos of trains, castles, and communist stuff which I shall bore you all with shortly.

The InterRail youth passes are certainly good value although bizarrely if I were one year older I think it would have been cheaper to buy the tickets individually. Ho hum.

Train Game 0.2

April 18th, 2010

I feel it’s about time I released another version of Train Game: so here it is, version 0.2! Like it’s predecessor this version isn’t really playable in any sense, but you can drive the train around a bit. Here’s a screenshot showing the two major new features: trees and uphill track:

Building and Playing

This version is source-only and will only work on Linux/*BSD without significant tweaking, although I do plan a Windows version at some point.

First, download and unpack TrainGame-0.2.0.tar.gz.

In the TrainGame-0.2.0 directory, run:

cmake .
make

You will be notified of any missing dependencies. Note that FLTK is no longer required. Do not run make install! It’s currently designed to run in-place.

To play:

./bin/TrainGame play demo

You can substitute “demo” for anything in the maps directory such as “figure8” or “uphill”. If you want to create or edit a map do:

./bin/TrainGame edit mymap --width 32 --height 64

The controls are quite simple:

  • The up and down arrow keys control speed.
  • The “b” key toggles the brake.
  • The “r” key toggles reverse but only when there is no power applied.
  • The left and right arrow keys change the direction of points when you are near some.
  • The tab key switches between bird’s-eye, floating, and fixed camera modes. Use the mouse to move the camera in floating mode, then hit tab to lock it in fixed mode.

Plans

So, I’m thinking of where to go with Train Game now since the project seems a bit direction-less and perhaps that explains the slow progress.

My current thinking is that there will be two game modes: “challenge” and “trading”.

Challenge mode involves you completing various train based tasks. There are two sub-modes:

  • Timetable – drive a passenger train along a route trying to stop at stations at the correct times and also make the passengers’ journey as comfortable as possible (i.e. no sudden starts/stops). This style of game seems very popular in Japan.
  • Delivery – you are given a series of increasingly difficult delivery tasks to perform with a strict time limit. E.g. “collect 10 units of wood from X and deliver them to Y in 1 minute” or something like that.

Trading mode is a bit more open-ended and also has two sub-modes:

  • Capitalism – you buy and sell goods at different stations. There’s a simple market economy which fluctuates with your actions. It’s a bit like a train-based Elite. With the money you earn you can buy new trucks, upgrade your train, etc.
  • Socialism – there’s no market but you score points for heroic actions such as transporting goods over long distances at high speeds. There are also randomly generated “quotas” that work a bit like an extended challenge mode. The details still need to be worked out…

In both these sub-modes you compete against other AI controlled trains, or maybe even other human controlled trains.

I’m also considering renaming it DoofTrains to make it sound a bit less generic.

What do you think, readers?

Shepperton Lock: a hive of terrorism?

April 18th, 2010

Yesterday I went on a walk from Staines to Twickenham along the Thames. It’s not the most interesting part of the river Thames by any means so I don’t have many photos to share. However, when I came to Shepperton Lock near Weybridge, Surrey I see that the local police force have collected the full range of anti-terrorism posters:

I wondered why Shepperton Lock was such a terrorist hotspot. But then I did remember that this part of England was once overrun by hordes of martian invaders so maybe the residents are rightly scared of outsiders. In fact, I believe the ferry crossing at Weybridge was the site where the first martian was destroyed by cannon?

Speaking of ferry crossings, as excited as I was by taking a small boat across the Thames, £2 is a bit steep for 30s of boat-riding.

Anyway, I’m 16 miles closer to having walked the full length of the Thames! :D

So, farewell then, Slough bus station

April 6th, 2010

If you live in the Slough area it can’t have escaped your notice that Slough bus station is currently being demolished under the guise of the Heart of Slough regeneration project and replaced with a strange hybrid of a crustacean and a fan heater that changes colour with the weather (I’m not joking). The library is also suffering a similar fate.

This is all very reminiscent of the post-war flurry of destruction and redevelopment that built modern Slough, bus station included, that is now so derided. Still, out of a survey of one life-long Slough resident I’ve found 100% in favour of it’s obliteration so maybe it’s for the best.

I’d rather hoped there would be some grand destruction ceremony involving explosives that I could witness but the actual demolition is, fittingly, not very glamorous:

Apparently you can judge the prosperity of a town by counting the number of cranes on the horizon. By that measure Slough is second only to Dubai!

New bus station opens January 2011. I’m sure you’ll all be anxious for updates.

Hooray for the funicular railway

April 4th, 2010

It’s Easter today but even more importantly the East Hill funicular railway in Hastings has reopened! Hastings has not one but two funicular railways, the other one is longer but shallower and appropriately positioned on the West Hill. The East Hill lift has been closed for several years due to an unfortunate accident but is now operating again and has reclaimed its place as the steepest funicular railway in the UK. I have taken some pictures to celebrate this happy occasion which you can see below.

After years of deriding my home town I’ve recently decided I quite like the place. I don’t know whether this is due to my recent move to the Slough/Maidenhead area having been spoiled living in York and Winchester, or because Hastings really has improved under the benevolent rule of Michael Foster.

Still, the town is certainly a trendy place to be now considering all the fancy designer outlets displacing the charity shops in the old town and the influx of the middle classes.

Unfortunately not everything is happy in Hastings today. For what do the incoming middle classes demand above all else? Art galleries! And what do they not want? Wooden huts selling ice cream! Thus Tom’s Cabin on the Stade is to be demolished and replaced with an art gallery despite local opposition. Today was Tom’s Cabin’s last day of trading and the local media had turned out to record the event. I remember visiting the outlet as a sprog but alas it will vend no more. Nevermind. Maybe the art gallery will have some good pictures. Will report back later.

Amazing new technology

March 23rd, 2010

A friend gave me this amazing pig torch today!

What is amazing about pig torch you ask? Pig torch has incredible pump-action technology that means it requires no batteries! Here we can see the pump mechanism:

By pumping up the pig it builds up a store of energy that can be released at any time via its nostrils. Am a little bit worried that pig might become too pumped up with energy and explode. Must be careful.

Filed in musings - Comments closed

Walking around Marlow (again)

March 7th, 2010

I realised it’s been a while since I treated/bored you all with photos of my wanderings around Berkshire. So here are a few photos of my walk today around Marlow and the surrounding countryside.

I don’t think anyone could visit Marlow without wanting to ride on the happy little Marlow train previously eulogised on this blog. I didn’t take a picture of the Marlow train today unfortunately, but here’s one I made earlier to illustrate its essential characteristics:

Here it is going over the bridge at Bourne End. I believe said bridge is currently the subject of some controversy over its repainting or lack thereof due to budget constraints.

Anyway, the important things to note are that it is small, consisting only of two carriages, and it trundles at a leisurely pace. Neither of these are readily apparent from the above photo, thus it fails in its intended purpose.

Fact of the day: in olden times when the Marlow train was steam powered it was referred to as the “Marlow Donkey”, presumably due to the aforementioned characteristics.

Trains on hills

March 5th, 2010

After a flurry of Train Game development the train now goes up and down hills!

Unfortunately all is not quite right in train land as sometimes when going up or down a steep hill the train intersects the waggons or goes way out in front as if on an invisible elastic band rather than a rigid coupling. More work needed I think.

Some thoughts on trees

February 27th, 2010

I’ve been wondering for a while now what is the best way to add trees to Train Game. Trees seem fairly important for a train game seeing as trains mostly travel through the countryside where there are trees. (Except for my daily commute to work through Slough where there are no green things.)

Anyway my first attempt was to use flat quads with an alpha-blended tree textured onto them. These are commonly called “billboards” if you didn’t know. The quads are then oriented to always point at the camera, hopefully giving the illusion of a fully 3D tree. While the maths to calculate the billboard orientation is a bit tricky, these trees are incredibly cheap at runtime. Blodgett was kind enough to use its artistic talents to produce some tree pictures for me:

While these trees look quite good from a distance, when you get up close and especially when look from above the rotation and obvious flatness is a bit disconcerting.

So next I tried a completely different approach to tree rendering. Inspired by examples of procedural plant generation e.g. here and here I implemented an L-system tree generator – albeit a much simpler one than in those examples. Here’s a screenshot showing some examples of trunks and branches:

I think these look rather good. Unfortunately there are two problems: rendering them is incredibly slow, and I found it very difficult to generate decent looking leaves. Since trees are only scenery and I’d like to have a lot of them on the screen at once, it’s not really acceptable to have them use more of the render-cycle budget than the train itself. Simplifying the branch structure and using square leaves, plus some OpenGL performance tricks, gets them running at a reasonable speed, although they don’t look nearly as good:

Incidentally, these screenshots are showing the new map editor which ditches FLTK and replaces it with my own home-made XML GUI toolkit. I’m rather pleased with it design-wise and it plays much nicer with the rest of the game (it renders directly onto an OpenGL texture).

Anyway, back to trees and my conclusion from the L-system experiment is that I didn’t like them that much, they were expensive to render, and perhaps most importantly, they didn’t fit in with the rest of the artwork in the game (in the “childishly cartoonish” style). So I abandoned the code in a git branch and went for the simplest option: make some models of trees.

Thus far I’ve made two tree models – a pine tree and an apple tree – both around 80 polygons. They are very cheap to render – cheaper in fact than the billboard trees since I have an optimised VBO-based mesh renderer.

I really do like these trees! I think they’re cute but I’m a little worried other people will think they’re daft. Anyway, I’m sticking with them for the time being.

In a month or so I will tidy up the code in git and release another demo/preview version. Hopefully there will be some useful features by then ;). In the meantime you could look at my gitweb if you’re curious or clone http://www.nickg.me.uk/~nick/git/traingame.git.

Thank you muchly to blodgett for assisting with tree evaluation!

Samsung Q320 Fn-keys in Linux 2.6.32

February 20th, 2010

If you’ve been following my attempts to get the brightness up/down and other fn-keys on my Samsung Q320 laptop to work in Linux, you might like to know the saga has reached a happy conclusion. Previously I published a hack to the atkbd kernel driver to get these problematic keys to send key release events. My attempt to get this included in the kernel failed, but I was told the 2.6.32 kernel would contain a new mechanism for fixing this from userspace.

Well, 2.6.32 is here so how can we fix the fn-key release problem? Documentation for the new sysfs attribute is a bit scanty as it’s intended to be used only by udev/HAL/DeviceKit, but you can set it yourself quite easily. The relevant file is /sys/devices/platform/i8042/serio0/force_release – this lets you manipulate a bitmap in atkbd.c indicating which scancodes don’t send key release events.

echo 130-132,134,136,137,179,247,249 \
    > /sys/devices/platform/i8042/serio0/force_release

The bitmap editing syntax is quite nice – done in lib/bitmap.c rather than the atkbd driver itself. I got those scancodes from the array atkbd_samsung_forced_release_keys in atkbd.c. They were originally intended for the NC20 but the Q320 keyboard seems to be the same. It works for me anyway.

You still need to map the brightness up/down keys to the correct X11 codes, which you can do like this:

setkeycodes e008 225 e009 224

Job’s a good’un.

All my Samsung Q320 coverage is here.