[java] A simple java question

This topic is 5456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, i have a simple question that has probably been answered somewhere on the web before, or has source code somewhere, but i cant find it. Basically i want to:- A) create a simple program using java that will open a new window that shows tiles. eg 8x8. Specifically a top down view ( i intend to create a top down map generator from it ). A very simple GUI will be used to choose map size eg 2x2 4x4 8x8 etc, and when "submit" is clicked, the new window and tiles will be generated. Does anyone have links to sites or articles, or can use their knowledge in this thread? :-) Any help would be much appreciated. After i can accomplish this, my next stages will be to :- 1. Give tiles values (terrain types) 2a. Give tiles simple colors eg green for "grass tile" 2b. Somehow incorporate Perlin Noise for the different graphics of the different tiles 3. Use AI or constraints to realistically randomize placement of tiles 4. Have the ability to turn on/off tilegrid. Please note, i only really require the answer to "A" at the moment. 1 - 4 is there to give an idea of what i will use the tiles for (ie is your help plausable). Of course if you are able to help me at all on these i wont say no :-) Thanks for reading this post and hope you can help!

Share on other sites
just override paint(Graphics) in a jpanel with something like this
public void paint(Graphics g){g.setColor(Color.WHITE);g.fillRect(0,0,getSize().width,getSize().height);g.setColor(Color.BLACK);for (int i=0;i<squarecount-1;i++){g.drawLine(i*getSize().width/squarecount,0,i*getSize().width/squarecount,getSize().height);g.drawLine(0,i*getSize().height/squarecount,getSize().width,i*getSize().height/squarecount);}}

It's really quite simple and you should have found many examples of it if you ever googled about the info.

Share on other sites
thankyou for your reply and your time. Ill give the code a go now. I have been searching the web using google, but i think my inputs arent detailed enough eg. java tiles brings up tiling for webpages.

thanks again.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 22
• 17
• 46