Report as inappropriate.
*Now with shorter description*
Controls:
Arrow Keys to move
"1" to set the light back to the torch flickering.
"2"-"5" to control the different aspects of the light. Press "w" to increase the value, and "s" to decrease, while pressing the number.
"2" is range, "3" is spread, "4" is intensity, "5" is background intensity.
This scenario has the LightActor class, which will look at specific objects that implement the AffectedByLight & StoresImage interfaces and "light" depending on how far away each pixel in the image is from the centerl
This scenario has some more handy classes:
- There is a Background actor subclass, which will automatically place itself in the center of the screen, and than create an image for itself that is as big as the world, and then will fill it up with a specific color. I created this because I had a weird glitch when I tried to implement that into a world.
- There is a Distance class, which will find distances from Actors, coordinates, and Points (java.awt.Point).
- There is also the TruePoint class, which will find what I like to call, the "True Point" of a specific spot on an Actor's image. To explain better: The GreenfootImage class will let you go through each pixel of the image, from (0,0) to (img.getWidth(), img.getHeight()). However, for this scenario, I needed the coordinates of each spot from the WORLD's perspective (to work correctly with the Distance class). So the TruePoint class will find that "True Point" in the world according to a "Normal Point" in an Actor's image. It may come very handy for others who want to work on projects like this, where you need to find the WORLD location of a point on an image.
Plans for the future:
- Accessibility with multiple LightActors (it gets real glitchy with more than one LightActor)
- Make different shades of light
- Better performance with more objects (gets laggy when there are a lot of objects in range)-
- The ability to make ovals and other shapes with the light, instead of a circle.
If you have any suggestions or tips, or find any bugs with the system, please write a comment below. I'll try to get more work into this after I get my big AP Computer Science final project done.
Yes, you can use this code. The "Open in Greenfoot" button is there for a reason. Please credit me if you do use this code.
5455 views / 16 in the last 7 days
1 vote | 0 in the last 7 days
This scenario is a member of: Reusable actors & support classes, Reusable Code from FRUP
Want to leave a comment? You must first log in.
2013/5/27
2013/5/27
2013/5/27
2013/5/27
2013/5/27