where do you start when making a game like this?

sliders_alpha

New Member
Hi,

today while playing minecraft I though, let's code it.
But having no experience in game programming, I don't know where to start, their is so much to do.

I do understand the terasology code, but there is SO MUCH of it.

tell me, when you start from nothing, what do you do first?

terrain generator?

thanks.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Welcome!

Begla or Immortius would be ideal for answering this, but I'd say first of all you want to be able to have a camera viewing a flat world, like I'm sure there are examples of via the LWJGL or jMonkeyEngine site :)

Then likely movement, hard coded objects in the world, etc. Terrain gen I imagine is a little further down the road, other than tiny sample stuff, since you then get into how you divide the world (chunks) also.

But that's more or less me just guessing, since I haven't done it from scratch either. The furthest I got solo was tinkering with a jME world creating physics cubes and shooting things at them (a.k.a. tweaking supplied examples)

As for Terasology - you start small, in a tiny little corner you like the idea of, then simply find a typo to fix, a comment to improve, an easy bug in the issue tracker to fix, etc, and grow from there!
 

sliders_alpha

New Member
thanks,

Indeed, I could start by doing a flat surface with just a camera wich "walk" on it.
then work from there.

I found this : http://arcsynthesis.org/gltut/ in LWJGL wiki, going to do all the tutos before.

however as I understood : you need to make 3D models of what you want in a 3D drawing software like blender, then export it for your code :eek:
I just need cubes, am I really forced to go through 3D modelisation?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Oh nonono, the Blender models etc make up a second layer of more fancy objects in the world (like stairs). The base blocks are just simple voxels :)
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
The way I have started in the past is by defining a simple data structure for describing a chunk of the world - some flavour of 3D array such you can get information on the existance and nature of a block at a given (x,y,z) coordinate. I generated one to start with that contains some fixed values (not using a terrain generation algorithm), or simple random noise.

Then I wrote code to generate a mesh to represent that chunk - keeping it as simple to being with to start, blocks only, fully lit and a single texture or no texture.

Finally I added basic camera + rendering, so I could see what the mesh looks like.

From there it is a matter of iterating and picking features to add, maybe:
- Moving the camera
- Texturing blocks
- Lighting
- Multiple chunks
- Modifying the world
- Player movement
- Terrain generation algorithm
- Block shapes
- Configurable block types
- World persistence
- Infinite world
- Gameplay
- Optimisations

and so on forever, or until you are sick of it at any rate.
 

sliders_alpha

New Member
Cervator said:
Oh nonono, the Blender models etc make up a second layer of more fancy objects in the world (like stairs). The base blocks are just simple voxels :)
great, no need to learn 3D modelling in order to get started =D.

thanks immortius, this is a really great order.
also does coding some part in GROOVY really give you some kind of advantage (in term of execution speed)?

And I am wondering, will I really get a dragtiscally increase in frame rate if I were to do it in C++?
I read many "why minecraft is coded in java" thread.

according to many people, with today's computing power, this shouldn't be a problemn minecraft just need to be better optimized.

what do you think?
 

sliders_alpha

New Member
It doesn't look that much faster :/ but it could because of how this guy did his programming.

still on the openGL courses, can't wait to start =D
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
thanks immortius, this is a really great order.
also does coding some part in GROOVY really give you some kind of advantage (in term of execution speed)?
No, groovy is slower than java. Advantage is only more powerful syntax and dynamically writing code at runtime.

It doesn't look that much faster :/ but it could because of how this guy did his programming.
Well, all of the rendering is done by OpenGL regardless, and that is a major component for how well things will perform.

Strictly speaking it is always possible to write C++ code that will be faster than Java (or .Net) code, but it is possible to write code that performs much worse as well. Then there are other considerations like how easy it is to develop and maintain the code, to debug the code, and the question of whether the performance you will gain offsets those costs. Large portions of code will generally not be performance critical as well, so the extra performance is wasted on them. Of course, you can always integrate a scripting language to use for that code.

Edit: for a different type of game, but another list of steps for making a game that may be a useful read.
 

sliders_alpha

New Member
So, I'm advancing.

I've made cubes classes wich each embed 6 boolean to tell if a face is visible or not, those boolean are being set when a cube is inserted inside a sector (16x16x256 cubes)

Then I made a flat terrain generator wich generated a flat 30x30 terrain.
So it needs 900 Sectors

But

After 91 sector allocation I get an exception "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space"

Does it mean that 900 sector is too much for my RAM?
and thus I must store each sector on hard drive, and load one of them in the RAM, do my stuff, print it, store it back on drive, load the next and so on for the 900 sectors?

or did I just too poorly design my data system and the RAM should be able to hold 900 sector?
 

ironchefpython

Member
Contributor
Architecture
sliders_alpha said:
I've made cubes classes wich each embed 6 boolean to tell if a face is visible or not, those boolean are being set when a cube is inserted inside a sector (16x16x256 cubes)

Then I made a flat terrain generator wich generated a flat 30x30 terrain.
So it needs 900 Sectors
6 bits x 16 x 16 x 256 x 30 x 30 = 42 megabytes to store that baseline amount of information.

However... Java sucks. You're probably using 14 bytes per block (1 per boolean, 8 for object overhead).

14 bytes x 16 x 16 x 256 x 30 x 30 = 787.5 megabytes before you ever start counting the hashmaps or arraylists that you're keeping your blocks in.

sliders_alpha said:
Does it mean that 900 sector is too much for my RAM?
Yup.

sliders_alpha said:
and thus I must store each sector on hard drive, and load one of them in the RAM, do my stuff, print it, store it back on drive, load the next and so on for the 900 sectors?
Yes... or you can use a more memory efficient data structure (sparse arrays, rle encoding, tries, etc.) and find or write your own Java library to work with that data structure.

Or you can stop using Java, and go to C like every other decent game designer. :p
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
ironchefpython, you make baby gelcubes cry :cry:

Java is clearly the best thing since sliced bread! Any other scenario is inconceivable! :D

sliders_alpha - take a look at our Chunk class, which is what you call a "sector": https://github.com/MovingBlocks/Terasol ... Chunk.java - I'm sure there are some related rendering classes you might also find interesting

KaiKratz was able to pull some snazzy compression logic recently that shrunk memory usage (and on-disk storage) substantially. All kinds of good tricks all over the codebase :)
 

sliders_alpha

New Member
Lol, my first purpose here is to get some neat java skills.
I could work on an other project but this one is fun, and getting faced to such problems is what get you better.

nice cervator =D, I'll check your code (gonna try do make my own algorythm before tho =p)
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
sliders_alpha said:
After 91 sector allocation I get an exception "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space"
Ok, first piece of advice is to work out how much memory you are allowing java to use. By default it is allocated a small subset of your maximum ram - this can be overridden with the -Xmx commandline option.

or did I just too poorly design my data system and the RAM should be able to hold 900 sector?
World data structure is one of those things which do require some care. Best way to minimise memory usage without dipping into exotic techniques is either using primitive arrays (e.g. byte[]) or the collections from the Trove library. Keep all the values from a single in one of those collections (or a set of collections for different data). This avoids memory being wasted in object allocation. booleans are quite memory wasteful in either form as it takes at least a byte for each, BitSet is much more memory efficient at the cost of some usage performance.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Don't we use calculations to figure out what to render rather than store booleans anyway? We just have the byte ID for the block type and some secondary stuff, we don't have six of anything per block if I recall :)
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
Yes. Not storing information you can derive is also a good idea. If you are sticking to just cubes to start with, all you need to know is whether there is or isn't a cube at a specific location. You can determine side visibility by checking adjacent locations (Terasology has a bit of extra logic to handle non-cube shapes, but that is the essence of it).
 

sliders_alpha

New Member
Don't we use calculations to figure out what to render rather than store booleans anyway? We just have the byte ID for the block type and some secondary stuff, we don't have six of anything per block if I recall :)
Yes. Not storing information you can derive is also a good idea. If you are sticking to just cubes to start with, all you need to know is whether there is or isn't a cube at a specific location. You can determine side visibility by checking adjacent locations (Terasology has a bit of extra logic to handle non-cube shapes, but that is the essence of it).
calculating this information in real time must be time consuming, that why I though about calculating a cube and his neighboors visibility during it's insertion/removal of the chunck.
however this add a lot of data to store.

But since you guys seems to be able to calculate this in real time just fine, I'll do the same
 

sliders_alpha

New Member
ah, I didi it xD
cubes visibility are calculated on the fly (only inside chunks, meaning each chunk faces are drawed even when insivible)

So now I'm doing my rendering algorythm, but there is one thing I'm not sure of.
Do OpenGL draw what is outside of the window?

exemple, you can see in this picture 4 chunks with the same height.



a part of those 4 chhunk is off screen, but I did ask OpenGL to draw them.
was it smart enought to notice that it was off screen and thus disgard what I sent him in this part?

also I guess there is not automated way to tell him, if a cube is behing a cube, the camera cannot see it, so don't draw it.
I'll have do do some math before ans select what I want to draw.
 
Top