Design a simple game and implement it in the class that extends the World class.
Worm Game: A worm (consisting of a head and a list of segments) moves in 'its' direction on each tick, unless the user selects s different direction through the key stroke. A food morsel appears at random in the play area. If the worm eats the food, it grows by a new segment. The game ends when a worm either runs into the wall, or it 'eats itself', i.e., the head attempts to move is such way that it would eat a part of itself.
UFOs: An UFO is falling from the sky - moving slightly sideways as the wind blows. The user can move a gun platform left or right, and shoot a shot with the keystroke of letter 'x. Keep shooting, till you either hit the UFO, or the UFO lands on the earth. Add more shots, more UFOs, etc.
Ant Game: An ant travels through the play area controlled by the arrow keys. As it moves, is looses weight from hunger. When it finds food (a number of food morsels appear at random in the play area), it grows bigger. The game ends when the ant is too small to live, or get too big to move. (You choose what is too small or too big). It can also end when the ant hits the wall.
Star Thalers: Star Money, Star Thalers by the Grimm Brothers
There was once upon a time a little girl whose father and mother were dead, and she was so poor that she no longer had a room to live in, or bed to sleep in, and at last she had nothing else but the clothes she was wearing and a little bit of bread in her hand which some charitable soul had given her. She was good and pious, however. And as she was thus forsaken by all the world, she went forth into the open country, trusting in the good God.
Then a poor man met her, who said, ``Ah, give me something to eat, I am so hungry.''
She handed him the whole of her piece of bread, and said, ``May God bless you,'' and went onwards.
Then came a child who moaned and said, ``My head is so cold, give me something to cover it with.''
So she took off her hood and gave it to him. And when she had walked a little farther, she met another child who had no jacket and was frozen with cold. Then she gave it her own, and a little farther on one begged for a frock, and she gave away that also.
At length she got into a forest and it had already become dark, and there came yet another child, and asked for a shirt, and the good little girl thought to herself, ``It is a dark night and no one sees you, you can very well give your shirt away,'' and took it off, and gave away that also.
And as she so stood, and had not one single thing left, suddenly some stars from heaven fell down, and they were nothing else but hard smooth pieces of money, and although she had just given her shirt away, she had a new one which was of the very finest linen. Then she put the money into it, and was rich all the days of her life.
Exercise: stolen fair and square from TS!2 workshop
Develop a game program based on the story of ``Star Money,
Star Thalers.''
The program should consume a natural number and drop that many thalers (from the top of the world) on the girl (at the bottom of the world), one at a time. The thaler should move randomly to the left or right and downwards, but should always stay within the boundaries of the world (canvas). The girl should react to 'left and 'right keystrokes, moving a moderate number of pixels in reaction but always staying completely within the boundaries of the world.