Drawing a path in-game - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Drawing a path in-game (/thread-8355.html)
Drawing a path in-game - GregX999 - Nov 29, 2010 07:20 PM
Does anyone know how you create/store "paths" that the user draws on screen during game play? I'm thinking of games like Flight Control (where the player needs to draw a path for each airplane to the appropriate runway).
Is it done by storing every pixel of the path in an array? Using a lot of waypoints and straight-lines in-between? Using a few waypoints and spline interpolation? Something else? How many times a second would you need to record a point?
(This is more a "technique" question as opposed to technical - I already know how to sense touch events and what-not.)
RE: Drawing a path in-game - Skorche - Nov 29, 2010 08:04 PM
You already don't get per-pixel input. It tends to come in maybe 10 times a second or so anyway.
A pretty simple solution to the problem is to record every input value that is more than a certain threshold distance from the last recorded input value. Smoothing the points out using splines might be a plus, but you probably won't notice anyway.
RE: Drawing a path in-game - EvolPenguin - Nov 30, 2010 10:55 AM
On a semi-tangent, I really like when the lines I draw on screen (on something like an iPad or iPhone) are smoothed out, makes it feel more natural to the way my finger went, rather than a bunch of line segments.
RE: Drawing a path in-game - GregX999 - Dec 1, 2010 07:16 AM
Hmmm... seems I'll have to look into that whole "spline thing" then.
But I do agree, seeing a nice smooth path does look the best.