This is coming along so nicely, could you send me some resources for where you found out how to do this random terrain generation and stuff?
I'll try to explain it for a bit. I could send you the complete code, but that probably won't help you very much.
To generate the terrain, I created a formula which has as output a slightly randomized sine wave. The core of the terrain generation code is:
for (int i = 0; i < 16; i++) {
for (int j = 0; j < hMax; j++) {
for (int k = 0; k < 16; k++) {
if (Math.random() * 5 + (8 * Math.sin(0.125 * (i + totalY))) > j - 12 && Math.random() * 3 + 8 * (Math.sin(0.125 * (k + totalX))) > j - 12) {
blockData[i][j][k] = 1;
} else {
blockData[i][j][k] = 0;
}
}
}
}
These 3 for-loops run trough all possible coordinates, and check whether the Y coordinate for the given x coordinate is less than sin(x). If that is true, a block of stone is generated.
After that, the following loop check whether a block is the top block, and if so, it replaces the top block with grass, and the two blocks below that with dirt.
You might want to talk to royawesome he is writing a custom rendering engine for SpoutCraft to replace notches that uses LWJGL. I'm sure he might have some interesting information. Also maybe you could help if you have the knowledge.
Personally looks good nice to see someone doing something rather then asking for people to make it for him.
You might want to talk to royawesome he is writing a custom rendering engine for SpoutCraft to replace notches that uses LWJGL. I'm sure he might have some interesting information. Also maybe you could help if you have the knowledge.
Personally looks good nice to see someone doing something rather then asking for people to make it for him.
I'll see if I can find him, thanks for the suggestion.
Also, currently, there is still some sort of pattern in the generated landscape, which doesn't look very well. I'll probably have to write some sort of 3d perlin noise instead.
I just figured out I'm slowly jailing myself in my own code, which gets more and more restrictive. I just found out how to fix this at the source, but it may take a while before everything works again.
If I can get this to work properly, a lot of weird code workarounds can be removed, which should give me a good performance boost.
Also, thanks for all the reactions so far. I'll keep updating.
When I least expected it, the new code suddenly started to work flawlessly. I'll try to explain what I've changed in the code.
The previous version used a 5-dimensional array for all the world data. Dimension 1 contained all chunks' X coordinates, dimension 2 their Z coordinates, dimension 3 contained the X coordinates of all blocks in a chunk, dimension 4 their Y coordinates, and dimension 5 their Z coordinates.
It is often required to check the block next to a certain block (let's call this block 'A')for whatever reason it is. Be it smoothing, lighting, terrain generation or anything else, some information will be required from the block next to A (which I'll call block B ). As long as B is in the same chunk as A, it's easy. Let's say B is behind A. In that case, the coordinates of B will be nearly similar. If the coordinates of A are 12;8;10, the coordinates of B will be 12,8,11. So far so good.
But outside chunks, two more levels are involved. To find the block next to block A when block A is at the side of a chunk, a lot more calculations are required.
But that has been fixed now. So that means I can now focus on adding new features and improving performance. So far, textures aren't working very well yet, so that will probably have to wait.
A short list of what I'm planning to add in the near future:
-Textures
-Collision detection & gravity (gravity cannot be added without also adding collison detection)
-A better, seed-based world generation engine using Perlin noise (I already have plans on how to tweak it for better looking terrain)
-Chunk loading, unloading and saving
-PERFORMANCE PERFORMANCE PERFORMANCE
Defiantly a interesting project I hope to see it continue.
I also have a question for you. Would it be possible to make a raytracing lighting engine for a simple block based world like this. With how simple the geometry is makes sense to me that a RayTracing lighting engine would be possible. But my experience with this is minor I'm just wondering if it would be possible.
This looks really cool. It has some potential to be a nice little game.
Also, I'm having a problem. I spent about 45 minutes making a simple(Extremely simple) text adventure. It's not much, but I suppose its a start. I coded entirely without any interface, and I'm regretting it. I was wondering If somebody would be able to explain how I would put this:
PS: My code isn't the best, just a heads up.
Into an window/interface. I suppose this deserves its own thread, but hey, why not post it here.
Defiantly a interesting project I hope to see it continue.
I also have a question for you. Would it be possible to make a raytracing lighting engine for a simple block based world like this. With how simple the geometry is makes sense to me that a RayTracing lighting engine would be possible. But my experience with this is minor I'm just wondering if it would be possible.
Native raytracing lighting would be incredibly cool, but already, I am struggling to keep the game somewhat playable in terms of FPS. It will have to wait for some major FPS improvements.
@mcnulty: That really depends on what you want to do with it. If you're planning to continue programming, and you have some experience with Java, then I can definitely recommend LWJGL; it runs much smoother compared to Java's default graphics libraries, and it's much more powerful.
However, if you're only just starting to learn Java, then adding LWJGL on it will most likely be too much. In that case, a combination of the Swing user interface and Java's default graphics libraries should work good as well. If you're planning on using the Swing ui, I strongly recommend using the NetBeans IDE, because it has an integrated window design manager, which should save you a ton of work.
I'd also like to get some feedback on the framerate from you guys. At the moment of writing, there is no FPS counter yet, so you'll have to get primitive and try to guess it, or just tell me whether you can play it smoothly, stutterly, barely or not at all. If you do, please don't forget to tell me which CPU and graphics card you have.
A zip with the game files can be downloaded here. Extract it anywhere you want, hit RUN.bat and you should be good to go.
EDIT: if you haven't set the Java PATH variable, this batch script may not work. In that case, open it with any good text editor and replace all the text with
Really stuttery for me. 10FPS, I'd estimate. Also, I spawned inside a grass block, and when I moved around, only the first chunk loaded. Kind of weird.
Yes; have a look at of my own voxel engine, which does exactly that. So far there's multisampled sunlight, true ambient occlusion, and point light sources. I'm going to add a radiosity pass later on.
I have a Phenom II 955 X4, 4 GB, nvidia 260 GTX, running Linux (Ubuntu 11.10). It's playable, but not smooth, I guesstimate it around 20 FPS. Also, I can look around, but I can't move the camera.
Really nice :smile.gif:
Is this created with LWJGL?
I hope so. I'm currently figuring out how LWJGL textures work.
I'll try to explain it for a bit. I could send you the complete code, but that probably won't help you very much.
To generate the terrain, I created a formula which has as output a slightly randomized sine wave. The core of the terrain generation code is:
These 3 for-loops run trough all possible coordinates, and check whether the Y coordinate for the given x coordinate is less than sin(x). If that is true, a block of stone is generated.
After that, the following loop check whether a block is the top block, and if so, it replaces the top block with grass, and the two blocks below that with dirt.
Personally looks good nice to see someone doing something rather then asking for people to make it for him.
I'll see if I can find him, thanks for the suggestion.
Also, currently, there is still some sort of pattern in the generated landscape, which doesn't look very well. I'll probably have to write some sort of 3d perlin noise instead.
Just jump in the IRC chat and if he is offline ask him about it say you made a rendering engine. Most of the spout devs are very open to questions.
Link to chat http://forums.spout.org/chat/
If I can get this to work properly, a lot of weird code workarounds can be removed, which should give me a good performance boost.
Also, thanks for all the reactions so far. I'll keep updating.
The previous version used a 5-dimensional array for all the world data. Dimension 1 contained all chunks' X coordinates, dimension 2 their Z coordinates, dimension 3 contained the X coordinates of all blocks in a chunk, dimension 4 their Y coordinates, and dimension 5 their Z coordinates.
It is often required to check the block next to a certain block (let's call this block 'A')for whatever reason it is. Be it smoothing, lighting, terrain generation or anything else, some information will be required from the block next to A (which I'll call block B ). As long as B is in the same chunk as A, it's easy. Let's say B is behind A. In that case, the coordinates of B will be nearly similar. If the coordinates of A are 12;8;10, the coordinates of B will be 12,8,11. So far so good.
But outside chunks, two more levels are involved. To find the block next to block A when block A is at the side of a chunk, a lot more calculations are required.
But that has been fixed now. So that means I can now focus on adding new features and improving performance. So far, textures aren't working very well yet, so that will probably have to wait.
A short list of what I'm planning to add in the near future:
-Textures
-Collision detection & gravity (gravity cannot be added without also adding collison detection)
-A better, seed-based world generation engine using Perlin noise (I already have plans on how to tweak it for better looking terrain)
-Chunk loading, unloading and saving
-PERFORMANCE PERFORMANCE PERFORMANCE
I also have a question for you. Would it be possible to make a raytracing lighting engine for a simple block based world like this. With how simple the geometry is makes sense to me that a RayTracing lighting engine would be possible. But my experience with this is minor I'm just wondering if it would be possible.
For creating a GUI you will want to look at Swing.
http://docs.oracle.com/javase/tutorial/uiswing/
I am not sure its what everyone uses and I've never really messed with it but I think it is what you are looking for.
Native raytracing lighting would be incredibly cool, but already, I am struggling to keep the game somewhat playable in terms of FPS. It will have to wait for some major FPS improvements.
@mcnulty: That really depends on what you want to do with it. If you're planning to continue programming, and you have some experience with Java, then I can definitely recommend LWJGL; it runs much smoother compared to Java's default graphics libraries, and it's much more powerful.
However, if you're only just starting to learn Java, then adding LWJGL on it will most likely be too much. In that case, a combination of the Swing user interface and Java's default graphics libraries should work good as well. If you're planning on using the Swing ui, I strongly recommend using the NetBeans IDE, because it has an integrated window design manager, which should save you a ton of work.
===================================================
I'd also like to get some feedback on the framerate from you guys. At the moment of writing, there is no FPS counter yet, so you'll have to get primitive and try to guess it, or just tell me whether you can play it smoothly, stutterly, barely or not at all. If you do, please don't forget to tell me which CPU and graphics card you have.
A zip with the game files can be downloaded here. Extract it anywhere you want, hit RUN.bat and you should be good to go.
EDIT: if you haven't set the Java PATH variable, this batch script may not work. In that case, open it with any good text editor and replace all the text with
for jre6. Or if you're using jre7, use this instead:
(if you do not know whether you're running jre6 or jre7, it will usually be jre6)
EDIT2:
The controls are: WASD to move, mouse to look around, C to ascend and Z to descend.
I will be home in about 2 hours to tell you fps from my home computer.
Athlon II X4 @2.9 GHz
5450
6 GB of RAM
Really nice :smile.gif:
Is this created with LWJGL?
I spawn upside down every time...