Drawing a path in-game
Hey guys,
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.)
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.)
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.
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.
Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
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.
Alex
Alex
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.

But I do agree, seeing a nice smooth path does look the best.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Get path to user's "Application Support" folder | Meh123 | 5 | 4,753 |
Nov 7, 2008 12:07 PM Last Post: Wowbagger |
|
| Path Finding | bwalters | 22 | 9,311 |
Mar 27, 2006 11:36 AM Last Post: Blacktiger |
|
| file path from NavReplyRecord? | frac707 | 2 | 2,808 |
Mar 2, 2005 05:14 AM Last Post: Hog |
|

