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

2013/11/7

can you draw a background w/ stars in space

ksksks ksksks

2013/11/7

#
can't remember if there's a drawStar code like drawOval.
Gevater_Tod4711 Gevater_Tod4711

2013/11/7

#
You can find all the methods in the Greenfoot API. Here you can find the class GreenfootImage. (And yes there is a method drawOval but for stars you better use fillOval I think)
danpost danpost

2013/11/7

#
If you actually want star shapes you can use fillPolygon and supply the array of x and y coordinates for each important point in the image. For a basic triangle, one could use this:
1
2
3
4
5
GreenfootImage image = new GreenfootImage(15, 19);
int[] xs = new int[] { 0, 9, 18};
int[] ys = new int[] { 14, 0, 14);
image.setColor(java.awt.Color.blue);
image.fillPolygon(xs, ys, xs.length);
ksksks ksksks

2013/11/7

#
thanks Can I use yours(copy it) if i add you to the coAuthor list?
ksksks ksksks

2013/11/7

#
@Gevater_Tod4711 thanks, I couldn't find it.
danpost danpost

2013/11/7

#
You can use it, but I do not believe that you want triangles as stars. And for snippets like this, co-authoring is not necessary. This is just a basic example of how to draw a filled polygon (this one just happens to only have three points and, therefore, creates a triangle).
ksksks ksksks

2013/11/7

#
using a for loop danpost. sorry, complecates things more.
ksksks ksksks

2013/11/7

#
ok. Thanks, not able to do that yet. Any way to make little sparkles(turn & shoot aliens?)
You need to login to post a reply.