Jump to content
• Advertisement

# Create infinite curve

This topic is 2162 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

So I basically start with a straight line from 0,0 to 0,10 (x,y space),and i need to add another line of that length,connected to the old one,but which slowly makes a curve,then another one....

The point is,I want the lines connected.

The bigger problem is doing this for infinite time.How would you go about it?

#### Share this post

##### Share on other sites
Advertisement
We are going to need either a much better description of the situation (ideally including why you are trying to do this) or a picture of what you want this to look like: My mind-reading skills are not what they used to be. ;)

#### Share this post

##### Share on other sites

I just need to code random generated curves forever. For example,you start with 100 floats,representing points. With those 100 floats you have to create a random curve.When you move forward,you delete the first float,and create a new one,but that new one IS based on the 99th one.Basically each new float is somehow linked to the float behind it.

or look at it from this point,you always have 100 points.You first create a curve.Whenever the player moves forward,you create a new point where the player WAS last time,and that new point is creating a new curve.

So,if player is is on point 1,but moves to point 2,point 1 will equal to a new point.You do that untill all points have been recreated to form a new curve.

Edited by noatom

#### Share this post

##### Share on other sites
Sorry, but you are still not making a lot of sense. I don't understand what you are trying to do, or the connection between the 100 floats and the random curve, or what you mean by a float being based on another, or the nature of the link between the new float and the float behind it.

You probably have a more natural problem in mind, and you convinced yourself that it could be reduced to something like what you are describing. If you explain the circumstances in which the need to solve this problem arose, we will be in a much better position to help you.

#### Share this post

##### Share on other sites

ok,the real problem is: " implement a road ,that has curves,and that goes one forever". When it says goes on forever,it means that when the player goes forward,the road will become longer.

its in 2d space btw

Edited by noatom

#### Share this post

##### Share on other sites
If I understand you correctly, you are wanting to create something similar to snake right? Meaning you have a path and you have a head of the path where it grows but as it grows at the head, the tail gets shorter so you always have the same number of points, right?

#### Share this post

##### Share on other sites
I am assuming only a quite small part of the curve is visible at any time. If the player can only move forward you can then simply store the visible portion of the curve and generate new parts as needed. The old parts can be easily discarded. If the player can also move backwards you probably need something more complicated (but it depends on your needs).

#### Share this post

##### Share on other sites
I suggest starting with an actual implementation of driving along an arbitrary finite road. This way, apart from dealing with more difficult parts first, you are forced to develop a sufficiently general representation for arbitrary road sections (for example, a bunch of polygons or large tiles) and you only need to implement updates of the road representation and random generation of reasonable road sections to allow the player to drive forever. I suggest looking for inspiration in an old MS-DOS game, Stunts (aka 4D Sports Driving), which has 3D graphics but friendly tiles in the level editor: track pieces include for example 2x2 tiles large 90° curves, single tile tight 90° curves, 2x1 vertical or corkscrew loops, hills and ramps rising 1 level in 1 tile length, etc. Every tile consists of a few polygons, instanced in a simple 3D scene with an arbitrary camera, extremely aggressive culling of distant geometry, and a skybox. Your game could lay down this kind of road pieces in "unexplored" parts of the map, without replacing previously encountered road sections. Another reference: OutRun, where the fixed view allows the road to be a sequence of coarsely juxtaposed very short sections (you can go down to about 1 pixel) with a smoothly varying vertical and horizontal displacement from the previous section. Add random road width changes, objects (e.g. roadside boulders) and a little traffic, and you have specified everything.

#### Share this post

##### Share on other sites

I may be misunderstanding, but you want a curve that you can add control points to?  That should be straightforward enough.  As long as you keep adding points to a spline, it will keep getting longer.  A catmull rom spline, my go-to spline, only looks at 4 control points at a time, so you can remove points that are already off-screen, and add more on as they approach on-screen.  (I also like catmull rom because all the control points are on the curve)

#### Share this post

##### Share on other sites

• Advertisement
• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• Advertisement

• ### Popular Now

• 16
• 9
• 15
• 9
• 11
• Advertisement
×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!