Thomas
Thomas

Reputation: 4297

Create curved lines in XNA

For practice I'd like to create a game like "Achtung, die Kurve" (http://www.achtungdiekurve.net), basically a hybrid of Tron and Snake, in XNA. For this I wonder how to draw the curves, considering the line / curve continues to grow and I need some kind of collision detection. Do you have any suggestions and/or links to code samples on how to tackle this challenge? Thx

Upvotes: 2

Views: 3033

Answers (1)

Jeremy Thompson
Jeremy Thompson

Reputation: 65534

The XNA Curve Creator shows you how to use the Curve class: http://creators.xna.com/en-US/utilities/curveeditor

More information about the Curve class: http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.curve.aspx

And here is a demonstration on how to get the Camera for follow a curve, so I'm sure it could be adjusted for your needs: http://msdn.microsoft.com/en-us/library/bb203908(XNAGameStudio.10).aspx

It also depends on whether or not you want to use a particle based approach or a strip based approach when trailing an object. There are several samples for both approaches, this older one for a the strip method or this sample for the particle-based method.

Use GraphicsDevice.DrawUserPrimitives(). Generate a list of vertices from either the previous positions of your sprites, or use the Curve class linked above if sprite movement is too jagged.

Ref: http://forums.create.msdn.com/forums/p/60257/370769.aspx
Ref: How do I draw lines using XNA?

Upvotes: 4

Related Questions