How to generate uneven road?

Hi,

I am a newbie in game development and just started learning the basics.
I plan to start making a game where I need the character to move on a rough,uneven, topsy turvy,curvy road.
How can this be done?

With regards
Manish

you might have to draw a picture to illustrate what you mean. there must be a million variations on what that description could be.

Without knowing anything at all about the context of your game there is absolutely no way any of us can help you in any way, the only help we could offer you is to send you here:
http://google.com

… that is, unless you give us more context.

Newbie in game dev? Or Java? Basics in Java or basics in game dev?

How can it be done? 10000000 different ways, 2D? 3D? platform? Birds eye? too many variables…not enough context.

Sorry for being not clear.

I know how to insert sprites etc in game scene and make them move.
But I dont know how to insert the varying scenery in game.
In my planned game I want to have a track which is varying in evenness, curves etc
so that sprite has difficulty while moving on it. I want to learn how to generate such a track in my game.
Hope I am able to put myself clear here.

With regards
Manish

…I am newbie in game development.
And game I plan to make is 3d game with a camera view following the character.

With regards
Manish

You might want to start off with a 2D game. Starting off with a 3D game isn’t all that easy… :slight_smile:

Stopping you right there, forget about 3D. You will just trip over yourself, I suggest a Space Invader or Brick Break game.

Thought I would just get right to the point, starting off with 2D is imo, 95% of the time the best approach. Everyone wants to make the next Minecraft, unfortunately not today.

I understand that a newbie should start with 2D. And I have done that by developing a very simple platform jumping game
in Android by following tutorials.
But the theme in my planned game is more suitable to 3D rather than 2D, hence I am more inclined towards it.
And in 3D too I have worked a bit, developing the basic Air Hockey game based on a famous tutorial.
But I have no idea about random scene/track generation and what strategy,algorithm etc is
followed for it?

With regards
Manish

No. Not another one of those :smiley:

Galaga clone!

I think word ‘newbie’ used in original post has totally deviated the thread from its original intent…sorry for that
as I do have some basic understanding of game development like sprite movement, collision detection etc.

What I want to learn is how to randomly generate track/scenery in a game.

With regards
Manish

i suggest you look into ‘procedural generation’ it is such a wide topic though, that there is a lot to sort through to come up with the sort of algorithms that will produce what you desire.

We got alot of “newbies” on here that are impossible to understand. You are very well spoken, but you have to try to understand that with the given information it would be impossible to give you an answer. Ask the right question.

Instead of, “how do I generate a road”
Ask something more specific and with more detail, that has a conclusive answer.
Maybe, “I am using LibGDX for developing a 3D game centered around following a road, and was wondering what the best way to generate and texture a 3D model on runtime.”
And even then, that question is difficult to answer because its so unique to your project. Its the core of your game, how could we possibly have a solution ready for that.

Another issue is that someone with enough experience in programming to take on a simple 3D game wouldnt be asking this question…

If your set on 3D game development, start off with a project you understand how to make the core game mechanic of.

(I agree with others that OP may be too ambitious, but I will let him be the judge of that)

So now for a real answer:

How to make an uneven road?

  1. Make a road.
  2. Make it uneven.

A road can usually be represented as a series of line segments, which are later expanded in width.

You may have a road the looks like this:
__________
/
|
_____/

So to make it uneven, you can roughen it up with random offsets (constrained of course, as to not break the continuity of the road):
_
/ ______
_|
__/
___/

This technique is formalized and expounded upon here for terrain generation, but it would suit the purpose of road generation as well. (Roads are more or less terrain, no?)

It should be easy if you do this in 2d (top view) and use the data to generate your 3d represantation of it.

I’m on my phone so I won’t go into much detail, but I think it migh be worth for you to look into noise func5ions and their use in games/procedural generation.

A rough example, of how you could implement this is:

  1. Create some points/nodes that will define the rough path of your road. Make sure that you don’ just place random points but use the last creted point to find the next one (place point, rotate n degrees, move m units, place next point, rotate n degrees… etc). Repeat until your level is complete (or you could even generate new points on the fly).
  2. Go through each connection between 2 points and use a noise function to add details/variations etc to the paths between your main points/nodes.

You will still have to figure out some things to get this working, but I hope this help you to find some ideas on how to do it.

Edit: burnt pizza was faster. I think we both point to a similar solution.

You get points for simplicity :slight_smile:

I do however agree with burnt’s reasoning. It isn’t much harder than this. The difference between 2D and 3D is that 3D requires some more thinking in another dimension (which, after all, isn’t that hard if you know your math). However I do strongly suggest to learn game development by starting of with 2D games. I once was this ambitious, didn’t work out.