[LIBGDX] How to draw terrain for truck/car game?

Hey guys I’m trying to come up with something like this:

or

http://s27.postimg.org/yqar38dxv/paint.jpg

Preferably the very last one as I want it as smooth as possible, now I’ve done some research and apparently the way to go about doing this is with batch.draw(Texture, Float[] vertices … ), problem is I’ve no idea how to use it or if this really is the best method.

Could anyone give me a hand and just show me a small example ( snippet of code) of how it could be done, I just want it to randomise and make it seem like mountains on the ground. Thank you :slight_smile:

What are you using for the? Java2D? LibGDX? LWJGL? JOGL? JMonkeyEngine? Slick? Something else?

What about this is giving you trouble? What have you tried so far?

How would you do this with a pencil on a piece of paper, without a computer? Pretend you have a really dumb friend who has no idea how to draw this kind of terrain (again, on a piece of paper with a pencil, without a computer). Write out instructions that he could follow to draw the kind of terrain you’re looking for on a piece of graph paper. Remember how dumb your friend is, so make sure all the instructions are as easy to follow as possible! If an instruction can be broken down into smaller steps, then break it down into smaller steps.

When you have those instructions written out, you’ll have an algorithm that you can start thinking about implementing in code.

Sorry forgot to mention I am using LibGDX for this, only issue I have is not knowing how to randomise it and also how to create it, can’t seem to get batch.draw with vertices to work :confused:

Step 1 is to get something really basic working, then work your way up. Can you draw a single point? Can you draw a triangle? Can you draw an entirely flat terrain?

If you’re having trouble with that, post an MCVE with hard-coded (not randomized) values and we can take a look.

If you can get the basics working, then start thinking about that dumb friend of yours. Write out (in English, not code) exactly what you’re trying to do.

When you have the basics working perfectly, and the instructions written out clearly, then you can think about combining them.

Will just drop this here, as someone asked for something similar a bit ago:

Linky