
I have to say I'm very sceptical about things like Fruit which rely on reactive animation, ever since I set our students an exercise implementing a simple space-invaders game in such a system, and had no end of a job producing an example solution. Things like getting an alien spaceship to move slowly downwards, moving randomly to the left and right, and bouncing off the walls, turned out to be a major headache. Also I think I had to use "error" to get the message out to the outside world that the aliens had won. My suspicion is that reactive animation works very nicely for the examples constructed by reactive animation folk, but not for my examples. I wonder how you would do it? A translation of the exercise I set, without the hints we had to put in, is as follows:
Earth is being attacked by aliens! The aliens are flying triangular spaceships downwards. At each moment a spaceship flies either left and down, or right and down, or directly down. The directions change at random, except that a spaceship may not leave the window. Against them stands only a (rectangular) gun, driven with the mouse. When the middle button is pressed, the lowest ship directly above is destroyed. However should a ship reach the (horizontal, straight) ground, the war is lost. Implement the following simulation function: spaceInvaders :: Double -> IO () The larger the Double is, the faster the spaceships should be.