Greenfoot_JS
Greenfoot (link) is a great environment to learn Java.
Greenfoot is a project in the Programming Education Tools Group, part of the Computing Education Research Group at the School of Computing, University of Kent in Canterbury, UK. The Greenfoot Team currently includes Michael Kölling, Ian Utting, Davin McCall, Neil Brown, Philip Stevens and Michael Berry. A related project developed by our group is BlueJ.
Greenfoot was created for Java, to work with OOP in visual way, leveraging direct-manipulation and Java's excellent reflection.
Question:
Would it be possible to re-create the Greenfoot environment and experience, but for JavaScript?
After all, modern JavaScript has classes, some form of reflection, and it runs natively in the browser...
And it would be great if the entire editor/environment would work without a backend, i.e. purely in the client.
A simple attempt
Here (link) you can see a simple, initial attempt at re-implementing Greenfoot in JavaScript, for JavaScript: Greenfoot_JS.
What is implemented:
- World class and Actor class
- World class has:
- getWidth, getHeight, getCellSize, setBackground, getBackground
- repaint, addObject, getObjectsAt, removeObject
- setActOrder, setPaintOrder
- Actor class has:
- act,getImage
- setLocation, getX, getY, setRotation, getRotation, move
- getWorld, getOneObjectAtOffset
- A few basic static methods of the Greenfoot class:
- start, and stop
- setWorld, setSpeed, getRandomNumber
- a rudimentary version of the getKey method
- isPointInsideRect, very useful when checking collisions
- Drag-drop of actors in the canvas (when GreenFoot is paused)
- Rotation methods, facing attribute for actors
- setting image for classes: every subclass of Actor has a getImage() method that returns an HTML imgElement
- Tree-like visualization of classes and subclasses
- Right-click on class names: allows to edit or create subclasses
- Right-click on main canvas: shows all methods of the current object, including all superclasses' methods.
All methods can be invoked, and the user is prompted to enter the appropriate parameters;
The results of the method invocation are shown with rudimentary visualization
- Right-click on main canvas: if no actor is selected, the World's methods are shown.
- Classes and subclasses of Actor and World are represented as a tree-like datastructure.
- JSON is used to save and load the whole scenario: all subclasses of World and Actor will be downloaded in a JSON file.
The same JSON file can be loaded, to continue working on the scenario
Please refer to the official Greenfoot documentation, to see signatures and behavior of methods.
Try it :)
[Greenfoot_JS]