It looks great! But it looks different every time. (I mean the gray points)
But it's easy to generate the same colors, like you've got on the website within three steps (only if you want ;) ):
first declare a variable like:
GreenfootImage gi_original;
Then start a new Thread, that will load the image in the constructor. (because it sometimes need a bit to load it from the web. And till it is needed, there is enough time):
new Thread()
{
public void run()
{
try
{
gi_original=new GreenfootImage("http://www.greenfoot.org/photo_attachments/0000/9746/Greenfoot.jpg?1393532467");
}
catch(Exception e)
{
gi_original=null;
}
}
}.start();
and the last step:
In the RandomRectangle()-method, you write under 'colory=...;' and before the 'while (getBackground().getColorAt(colorx-cellsize, colory).equals(randomcolor)...)' the following three lines:
if(gi_original!=null)
randomcolor=gi_original.getColorAt(randposx[randvar]*18+9,randposy[randvar]*18+9);
else
Now the gray and black rectangles will always have exactly the same colors, like on your current Greenfoot-website-image ;)
thehe nice idea thanks busch, first it was only important for me to get different gray colors at each rectangle so the neighbar rectangle does not have the same color! but maybe ill fix this at my next screnario.
Thanks to Bush2207, i solved it without internet image, i compared it with my local original bmp logo picture, so its working everywhere everytime!
Looks much better then with random one!
No problem.
I just thought, it might be better to use the website-image, because an image needs more space and now you always have to copy the image, too. But if that's no problem for you, then this is also a good solution. (All solutions have pros and cons ;)
2014/3/2
2014/3/2
2014/3/6
2014/3/6
2014/3/6
2014/3/6
2014/3/6
2014/3/6
2014/3/7
2014/3/7
2014/3/7
2014/3/9
2014/3/9
2014/3/24
2014/3/24