When you take a step into Java, sometimes people find it easier to learn things when there is something visual. Java is an effective platform to build a UI on, but if you’re a beginner or even an intermediate user of Java, it can be certainly overwhelming. So there is Greenfoot.
What is Greenfoot? It’s a framework, from the makers of the Java editor, BlueJ, that allows people to code in Java using a simple and robust API to code a visualized game. That’s a mouthful, I know, but it’s a lot easier to understand broken down. Basically, Greenfoot has a worldÃ‚Â and from there you extend it to be your world and stage for everything that is interactive. Then you have ActorsÃ‚Â which can be nearly anything, like Spaceships, Fish, people or circles. You get to code the rest from there. Any thing involving logic is done by you and all of the visual stuff is just put into a folder then referenced using the fancy methods provided by Greenfoot.
One of the things Greenfoot aims to do is to provide young students (preferably over 13) something that will get them interested and committed to programming. Games are usually a sure fire-way to get that to happen. And it’s more than justÃ‚Â games. It’s logic too. You have to logically handle the actions when two visual objects hit each other.
Greenfoot comes with a few ready to go examples to play with. One of them is called AntsÃ‚Â and it’s pretty interesting. You first have two ant hills and then ants proceed to come out both of them and (the ants are loyal to their colony, after all) they go in search of food. Once they find it, they leave a scent trial behind where other ants are directed on a smaller path where they too eventually stumble upon the food source and again leave more scent trial behind. It’s visually excellent. The code is moderately simple though. You have the Food, Scent, Ant and Anthill classes. The ant hills generate 1 ant per game turnÃ‚Â (game turns are movements and you can set how many per second) until there are 40 (it could be more or less, I didn’t count) ants. The food is automatically placed and off they go.
My teacher is using this in his Intro to JavaÃ‚Â class. He’s also pushing for it in middle schools across the district. My teacher is working on his own little game. The name of it escapes me, but it’s basically a space ship that flies around and tries to avoid hitting an asteroid. For every one you hit, you lose 10 points. After two seconds, you gain a point. If you hit 0, you lose. How long can you last, is basically the winning condition. I suppose the game could become quite complex.
Greenfoot is pretty neat, check it out.