Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would you go about generating terrain for a circle. To be specific i am using a 5x5 .PNG as the thing or object that will fill the circle. At the moment i am having problems making the terrain where it will fill the circle, but rounded. My specififc problem with the generation is that it fills it, however it is not rounded because it goes all the way to the max y at all points. The x axis however is not a problem at the moment. My code right now for the generation of the terrain is so.

for(float x = mapEdge.getMinX() ; x < mapEdge.getMaxX() ;   x += 5 ){
            for(float y = mapEdge.getCenterY() ; y > mapEdge.getMinY(); ){
                y -=5;
                g.drawImage(grass,x, y);


The above code results in this, (Actual Screenshot)

But what i want to happen however is this,(Drawn in paint)

P.S.If i have left anything out or need to change something to make it more readable, follow guidelines or ETC. please tell me and i will make appropriate changes.

Also,(Don't know if this follows the guidelines /:)can someone plz post or direct me to a post describing how to use an ID for Random Tile generation system, and how to use perlin noise?

share|improve this question

closed as not a real question by Byte56, bummzack, Le Comte du Merde-fou, Josh Petrie, Sean Middleditch Apr 7 '13 at 20:00

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Unfortunately, this question is a bit too broad and doesn't fit well with the Q/A format of the site. This site isn't for discussion based questions like this one. Start smaller, get something that can generate blocks, then something that can make large areas of block with chunking. Then move on to making them in a circular shape. See the FAQ for some links on getting started and to learn what types of questions to ask here. Good luck! – Byte56 Apr 5 '13 at 1:33
up vote 1 down vote accepted

You can use Graphics.setClip() to set arbitrary clipping shape. After that all image drawing calls will be clipped inside this shape.

Shape oldClip = g.getClip();
g.setClip(new Ellipse2D.Float(x, y, diameter, diameter));
// Draw the images here
share|improve this answer
I am having problems finding the solution to the following error-The method setClip(Rectangle) in the type Graphics is not applicable for the arguments (Ellipse2D.Float) – user2231327 Apr 5 '13 at 22:05
Are you using Java ME or some other limited version of Java? This method has been in standard Java since version 1.1. – msell Apr 6 '13 at 5:52
Eclipse Juno,latest version of java, and java EE. P.S. I am very new to programming so if none of those were the answer you were looking for please tell me, also i am using slick2D with lwjgl. – user2231327 Apr 6 '13 at 18:39
Slick2d has it's own Graphics class, which doesn't support arbitrary clipping shapes. From the documentation it seems that Graphics.texture(Shape, Image) could do what you are looking for. – msell Apr 6 '13 at 19:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.