How would you make an object move along a drawn path ?
Posted: Fri Jun 08, 2012 9:49 pm
Hi Lövers,
Well, I was thinking about making a short game, (just a random idea I got)...
In some part of the gameplay, an object might have to move following a drawn path.
My two concerns are :
1. Let the player draw his desired path, using a mouse, pressing down a button, for instance.
2. Make the object move precisely along that path.
How would you do this ? I am actually looking for elegant and efficient way to do it.
I may have some ideas, and I am pretty sure they will work :
* Display an empty buffer, get (each update cycle) pixels where the mouse has been hovering, and mark them as so on the buffer,
while list their (xi,yi) coordinates in a table which will be used by the object to move...
* Or just store the first pixel (x1,y1) coordinates (when the player started pressing down the mouse button),
while *still* marking the others pixels where the player will be hovering with the cursor.
Give (x1,y1) to the object.
Then it will move by steps, trying to detect each step looking in neighbourings pixels the next waypoint (previously marked) and step there.
Though, both of these methods appears quite expensive, to me.
Do anyone have interesting ideas ?
Well, I was thinking about making a short game, (just a random idea I got)...
In some part of the gameplay, an object might have to move following a drawn path.
My two concerns are :
1. Let the player draw his desired path, using a mouse, pressing down a button, for instance.
2. Make the object move precisely along that path.
How would you do this ? I am actually looking for elegant and efficient way to do it.
I may have some ideas, and I am pretty sure they will work :
* Display an empty buffer, get (each update cycle) pixels where the mouse has been hovering, and mark them as so on the buffer,
while list their (xi,yi) coordinates in a table which will be used by the object to move...
* Or just store the first pixel (x1,y1) coordinates (when the player started pressing down the mouse button),
while *still* marking the others pixels where the player will be hovering with the cursor.
Give (x1,y1) to the object.
Then it will move by steps, trying to detect each step looking in neighbourings pixels the next waypoint (previously marked) and step there.
Though, both of these methods appears quite expensive, to me.
Do anyone have interesting ideas ?