This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

danpost
danpost presents ...

2014/1/8

Hexagonal SuperWorld

Support world class that can be extended to make hexagonal worlds.

Control methods include:
* getInactiveFillColor() returns the inactive fill color (color of region outside the hexagonal area)
* setInactiveFillColor(Color) to change the background color of the world before the hexagons are drawn (for outside the hexagonal area)
* getHexBackgroundColor() returns the background color last set to all hexagons
* setHexBackgroundColor(Color) to change the background color of all the hexagons (for hexagonal area)
* getHexFrameColor() returns the frame color last set to all hexagons
* setHexFrameColor(Color) to change the color of the frames of all the hexagons
*setHexInactive(int, int) to change background and frame colors of the hexagon at the given hex coordinates to the inactive fill color
* setHexColors(Color, Color, int, int) to change the background and frame colors of the hexagon at the given hex coordinates

Helper methods include:
* isHexLocation(int, int) to test if the given hex coordinates are for a hexagon
* getWorldX(int, int) to get the world x-coordinate value of the center of the hexagon at the given hex coordinates
* getWorldY(int, int) to get the world y-coordinate value of the center of the hexagon at the given hex coordinates
* getHexWidth() to get the number of columns of hexagons in the world (like 'getWidth' for a grid world)
* getHexHeight() to get the number of rows of hexagons in the world (like 'getHeight' for a grid world)
* getHexSize() to get the size of the hexagons in the world (like 'getCellSize' for a grid world)
* addHexActor(Actor, int, int) to add an actor at the center of the hexagon at the given hex coordinates

Usage in this scenario: generation of the Fibonacci series using a triangle of hexagons.

The value of each hexagon is the sum of the one above and the one above and to the left. If no hexagon exists in either location, the value added to the sum is zero. If the result of the sum is zero, then the value defaults to one.

Click 'Run' to show the sums.
Click 'Pause' to highlight the long diagonal from top-left. The values in that diagonal are the values of the Fibonacci series (as are all diagonals going down and to the right starting from any top hexagon).

4966 views / 15 in the last 7 days

3 votes | 0 in the last 7 days

Tags: demo with-source fibonacci danpost support superworld series hexagonal

This scenario is a member of: Support Classes by danpost


open in greenfoot
Your browser does not support the canvas tag.
A new version of this scenario was uploaded on Thu Jan 09 05:27:03 UTC 2014
A new version of this scenario was uploaded on Fri Jan 10 08:04:53 UTC 2014 Corrected code and added documentation.
A new version of this scenario was uploaded on Fri Jan 10 16:18:04 UTC 2014
A new version of this scenario was uploaded on Sat Jan 11 04:24:54 UTC 2014
A new version of this scenario was uploaded on Sat Jan 11 05:09:58 UTC 2014
A new version of this scenario was uploaded on Sat Jan 11 05:58:10 UTC 2014
A new version of this scenario was uploaded on Sat Jan 11 06:06:11 UTC 2014
A new version of this scenario was uploaded on Sat Jan 11 06:33:26 UTC 2014
danpostdanpost

2014/1/11

Requests for any methods not provided that may be helpful are welcome. I cannot, however, guarantee that they will be implemented. Thanks.
A new version of this scenario was uploaded on 2020-10-29 09:25:11 UTC

See all comments

Want to leave a comment? You must first log in.

Who likes this?

FlyingRabidUnicornPig Game/maniac MatheMagician