tags:

views:

19

answers:

1

Here's an image of what I'm trying to achieve: http://bit.ly/cabifI Basically I want the blue circle to move along the curve path back and forth when I press the right and left arrow keys.

I know I have to blit the image but is there a way to automatically determine the x,y coordinates of the path and blit the image into there while pressing the keys?

Or is there some king of algorithm/techniques that needs to be used?

A: 

I assume you know the paths coordinates.

Given a single point along the path, place the ball on the same x but let y = y - ballRadius - (lineWidth / 2).

A very simple approximation; you will probably have some intersections, especially on steep slopes, but it might do the trick.

mizipzor
That's the problem. I don't know the coordinates of each point from the path. Is there a way to automate this?
Marconi
I see, well the obvious route now is to update your answer with how the path is generated. How do you draw a line which points you do not know? Are you using a library?
mizipzor
pygame is the only dependency but here's what I did: I edit the image and draw trace the path i want with a red line then in pygame I scanned the pixels from left to right then top to bottom. everytime I hit a red pixel, I record its coordinates.
Marconi
Then you should know the points of the line (the points you recorded), try using those points in the formula I posted.
mizipzor