Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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) https://www.dropbox.com/s/jkurs6m397djfne/WhatHappens.png

But what i want to happen however is this,(Drawn in paint) https://www.dropbox.com/s/1wc0e2p8w4plza5/WhatIWant.png

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
1  
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
add comment

closed as not a real question by Byte56, bummzack, Jimmy Shelter, 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.

1 Answer

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
g.setClip(oldClip);
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
add comment

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