[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: Keeping a sprite on screen with rect.clamp



Thanks guys. Lerp huh :) And bezier will be useful.

Mark

On Tue, Aug 17, 2010 at 11:38 AM, Ciro Duran <ciro.duran@xxxxxxxxx> wrote:
> I use the Vec2d class defined in the Pygame cookbook, plus a simplification
> of the calculate_bezier() function also there. Here's the code:
> def calculate_lerp(p, steps = 30):
>     t = 1.0 / steps
>     points = [p[0].interpolate_to(p[1], t*i) for i in range(0, steps+1)]
>     return points
> On Mon, Aug 16, 2010 at 10:13 PM, Mark Reed <markreed99@xxxxxxxxx> wrote:
>>
>> I want to calculate a straight path of points between two points and
>> each frame do:
>>
>> sprite.x, sprite.y = sprite.path[step]
>> step++
>>
>> And have the sprite move along that line.  I've lost all basic math
>> skills, and don't want to spend an hour debugging such a simple thing.
>>
>> Mark
>>
>> On Tue, Aug 17, 2010 at 9:41 AM, Luke Paireepinart
>> <rabidpoobear@xxxxxxxxx> wrote:
>> > Can you be more specific about what you mean? Are you trying to
>> > interpolated points between two endpoints or what?
>> >
>> > Sent from my iPhone
>> >
>> > On Aug 16, 2010, at 8:13 PM, Mark Reed <markreed99@xxxxxxxxx> wrote:
>> >
>> >> Anyone have a function for calculating all the points on a line to be
>> >> used for sprite movement?
>> >>
>> >> Mark
>> >
>
>