Astrofirm

Thanks the lights are not in the current release but will be in a few days, just need to smooth out a day/night cycle

Alright, so I just ran it, and I noticed the window size was huge! I have a 1920x1080 monitor, and it took up the whole screen. I’m going to venture a guess and say that you’re detecting the window resolution, and setting the window to that size, and I’d scale it down a little!

The other thing is the mouse cursor is locked to the grid (I believe), and it feels strange because it jumps around from block to block instead of smoothly from pixel to pixel. Other than that, I would ask how you generate your terrain because it’s very simple but nice :smiley:

thanks for the criticism :wink:

I agree that the window size is very large, in the next update i will reduce the size and hopefully have a way to resize the window in game without a change i aspect ratio.

The mouse is locked to the screen for testing purposes really but will be change in the future so it does not actually hinder mose movment.

I generate my terrain using general simplex noise. I first spawn a huge rectagle of blocks and set eaches coordinates to be their getter. When i am generating terrain, the code gets the height from the simplex noise and the current x values of the loop and turns that block into whatever it needs like this:

  
for(int x=0;x<mapsize; x++){
           for (int y=0;y<layers;y++){
                float height =SimexNoise.noise(x/turbulence, heightlim);
                  getBlock(x, y+height).air=false;
      {
}

Pretty much like that

Oh, very cool! So can I ask what value your variable turbulence is set to? And is heightlim literally your height limit? My terrain isn’t as cool as yours, it just removes a block here or there :confused:

my height limit is 60 and my turbulence is a random number between 1 and 257. There is some other stuff with id placement but It’s basically just checking the biome then assigning the ids according to the layer the blocks are on.

So I’m a little confused. Does the y variable create the height differences in your map, like the hills? You said you had a block of tiles and then ran over them with simplex noise, but does that create the hill effect?

Remember that first I spawn a big rectangle of blocks, the y is there to loop through all of the blocks the check if the simplex noise wants it to be a solid block.
[EDIT]
I may start a tutorial thread on this

Oh, I see, I think. Do you use the value from the noise generator and assign the layers of tiles? A tutorial would be great, I’ve tried a bunch of different values, and I can’t get that hill affect. I usually get a one tile difference on the top layer of tiles, and thats it.

Okay so here is my code:


for (int x = 0; x < mapSize; x++) {
			for (int y = 0; y < layers; y++) {
				double o = SimplexNoise.noise(x / (float) (lol + 1) + it,
						heightlim) * 16;
				int height = (int) (round(o, 1));
				if (y < heightlim) {
					if (check(x, y + height)) {//check if block exists
						block[x][y + height].id = id;//set block id
						block[x][y + height].air = false;//set block collidable
					}
				}
			}
		
		}
	}

make sure the blocks have a air value of true when this is run

can I ask what the values lol and it are? Thanks for helping me so much :slight_smile:

no Problem, this game will probably be open source eventually anyway :wink:

lol would equal the turbulence so a number between 1 and 157 (I couldn’t come up with a good variable name at the time ::slight_smile: ) I generate this number with the random class already in java

Nope, its not working still :confused: Here’s my code:

public void create() {
		int l = rand.nextInt(157) + 1;
		for (int x = 0; x < width; x++) {
			for (int y = 0; y < height; y++) {
				double o = SimplexNoise.noise(x / l + 1, 512) * 32;
				int height = (int) (SimplexNoise.fastfloor(o));
				System.out.println(height);
				if (y + height < 512 && height > 0) {
					tiles[x][(int) (y + height)] = new Tile("Grass");
				}
			}
		}
	}

Curiously, it seems that all the tiles are flipped when I generate the noise. Here’s a picture of what I mean:

Edit: So I stopped adding one to the variable and now the terrain is a lot more spiky, I guess you could say. But the y values are still screwed up! Everything is flipped!

are you using libgdx? beacuse regular java flips the y coordinate for some reason.


public void create() {
      int l = rand.nextInt(157) + 1;
      for (int x = 0; x < width; x++) {
         for (int y = height; y >= height; y--) {//changed
            double o = SimplexNoise.noise(x / l + 1, 60) * 32;//changed
            int height = (int) (SimplexNoise.fastfloor(o));
            System.out.println(height);
            if (y + height <60&& height > 0) {//changed
               tiles[x][(int) (y + height)] = new Tile("Grass");
            }
         }
      }
   }

try this I don’t really know how it will work though :confused:

No, I’m using LibGDX. Hmm, after a few tries of messing around with the variables, it still doesn’t work :stuck_out_tongue: Do you know where you learned how to use SimplexNoise? Because obviously I’m doing something very wrong here!

I came here for my simplex noise. I just copied the statement at the top, and the 2d SimplexNoise class

Ah yeah, I already have that class. I was wondering where you actually got those values to add to the noise function, because our games are a little different so the code won’t produce the same results!

oh, trial and error is really what I did :-\ . I kept on changing variables until a sufficient range was found

I just discovered that I don’t let my turbulence drop below 45, this doesn’t solve your problem but could heed better looking terrain

Well, my problem is still that the terrain generates upside down :confused: I think I managed to create some decent looking terrain (ok not really), but its useless upside down :P!

Okay try this:


public void create() {
      int l = rand.nextInt(157) + 1;
      for (int x = 0; x < width; x++) {
         for (int y = height; y >= height; y--) {//changed
            double o = SimplexNoise.noise(x / l + 1, 60) * 32;//changed
            int height = (int) (SimplexNoise.fastfloor(o));
            System.out.println(height);
            if (y -height <60) {//changed
               tiles[x][(int) (y - height)] = new Tile("Grass");
            }
         }
      }
   }