Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Generating 2D map out of Simplex Noise on: 2013-04-27 11:47:49
Tried my best to find any information about "packing/unpacking" color data or doing anything useful with Noise outputs.

I've managed to understand and write an app that draws points on JPanel using drawLine() method, but I still can't get a reasonable conversion from noise numbers to any kind of a color code.
I don't want to manually map colors to noise numbers, as I find it weird.. right?

And what is the idea behind 2-dim array?

EDIT:
I've tried to map color table like that:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
private static void putMap() {
      colors = new HashMap();
      colors.put(-5.0,Color.blue);
      colors.put(-4.0,Color.cyan);
      colors.put(-3.0,Color.red);
      colors.put(-2.0,Color.gray);
      colors.put(-1.0,Color.green);
      colors.put(0.0,Color.black);
      colors.put(1.0,Color.magenta);
      colors.put(2.0,Color.pink);
      colors.put(3.0,Color.orange);
      colors.put(4.0,Color.yellow);
      colors.put(5.0,Color.lightGray);
   }


And use it that way:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
for (int i = initX; i < mapX + initX; i++) {
         for (int j = initY; j < mapY + initY; j++) {
            double res = 512;
            double tile = Math.round( (SimplexNoise.noise(i / res, j / res) * terrainTypes) / 2 );

            System.out.println(colors.get(tile));
            g2d.setColor( (Color) colors.get(tile) );
            g2d.drawLine(i, j, i, j);
         }
      }


Which produces something like:


Am I any close to my target? Smiley

Sorry for annoying questions. I'm not lazy, I'm trying my best to do it solo, but seems like I need some pro help.

Thanks
2  Games Center / Archived Projects / Re: Yet unnamed 2d roleplaying game on: 2013-04-24 22:01:52
Looks nice.

The map is pregenerated by a script or you've created it manually via editor? Smiley

I'm struggling in generating similar world map based on Perlin noise numbers Smiley
3  Game Development / Newbie & Debugging Questions / Re: Generating 2D map out of Simplex Noise on: 2013-04-22 22:40:30
Hi,

Thanks for the answer.

Now I think I should have spent more time explaining what I'm actually trying to do.

Basically, I'm not making a game using Java at all. Just using it to write a Map Generator and pre-generate a world.

The game is web based, no 3D graphics, similar to Travian I guess, just lacks the map.
I cannot generate it via PHP, as this is a very slow process and this language is not made for this calculations.

I just want, in the final result, to get a set of images that will represent the "world". Images that will be a pieces of the world like this one:


This is just one piece, I will need a lot of those. Currently, I want to generate a height/color map, to see which seed gives me the best results, then, instead of the color, I will apply my textures to the noise heights and it will give me a map.

But anyway, I will take a look at LibGDX and see if it can help me.

Thanks
4  Game Development / Newbie & Debugging Questions / Generating 2D map out of Simplex Noise on: 2013-04-22 21:28:01
Hello,

Just registered. It might be that I've found a new home for my new hobby.

I'm toying around with Java's AWT and Swing, and trying to generate a visual 2D map "for a game".
I'm using SimplexNoise class to generate the numbers, from this step, seems like I can't find much more information about what and how.
I understand that I need to convert my numbers to a Colors and apply them to the "map" I'm generating.

So I have this initialization:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
SimplexNoise.genGrad(677);
     
int initX = 0, initY = 0;
int mapWidth = 1000, mapHeight = 700;

for (int i = initX; i < mapWidth + initX; i++) {
         for (int j = initY; j < mapHeight + initY; j++) {
            double res = 512;
            double tile = SimplexNoise.noise(i / res, j / res);
         }
      }


Which gives me numbers from -1 to 1.

I then proceed to create a blank Window:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
public static void createWindow() {
      JFrame frame = new JFrame("MapGenerator");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setSize(1000, 700);
     
      // make the frame half the height and width
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
      int height = screenSize.height;
      int width = screenSize.width;

      // center the jframe on screen
     frame.setLocationRelativeTo(null);
   
      frame.setVisible(true);
   }


And now I assume I need to use Graphics2D and draw every pixel on it by the color my numbers are related to and then somehow attach this element to the JFrame.

Am I right? I'm not asking for a "copy&paste" examples (but this is awesome as well), but at least a direction of what to do. What class to use, and which approach to apply to accomplish this task.

My desired output is something like:


Thanks a lot!
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (43 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!