Jump to content
  • Advertisement
Sign in to follow this  
uni2uni2

[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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!