On 28/04/15 16:38, diliup gabadamudalige wrote:
---------- Forwarded message ----------
From: diliup gabadamudalige <dili...@gmail.com>
Date: Tue, Apr 28, 2015 at 6:22 PM
Subject: circular movement in pygame
To: pygame-us...@seul.org

It's good that you tried the python-game list for a
pygame question. But if pygame-users can't give a
definitive answer then its even less likely that the
tutor list will. Although you might need to allow
a full 24 hours to get answers, email is not an
instant delivery mechanism.

Looking at the code on this page lines 47 & 48

http://programarcadegames.com/python_examples/show_file.php?file=sprite_circle_movement.py

I didn't look at the code in that tutorial, but...

is there a way to do
self.rect.x +*= some value*
self.rect.y += some value

Yes, that's just normal Python syntax. It adds/multiplies
the current value of self.rect with "some value"...

rather than

self.rect.x = self.radius * math.sin(self.angle) + self.center_x
self.rect.y = self.radius * math.cos(self.angle) + self.center_y

But its unlikely to have the same effect as this since the
above two lines are calculating a new value based on radius,
angle, and centre rather than one based on the current
values of self.rect

I tired it in the code attached and strangely it works ok but only OUTSIDE
THE class. When I implement the exact code in a class it does something
weird.  I can't find where I have gone wrong.

I can't see your code but are you sure you are using self in
all the appropriate places in your class based code?


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to