for what ever it's worth I'd like to share the code below with you. I got the code to do what I wanted. Object falls onto a rotating platform and stays there without falling off.
video is here -> https://www.youtube.com/watch?v=I6c5cKhLuo4 import sys, os, pygame from pygame.locals import * from standard_object_creator import * from math import sin, cos, pi, radians SCREENW = 800 SCREENH = 700 pygame.init() FPSCLOCK = pygame.time.Clock() FONT1= "data\Cookie-Regular.ttf" if sys.platform == 'win32' or sys.platform == 'win64': #os.environ['SDL_VIDEO_CENTERED'] = '2'# center of screen os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (10,30)#top left corner SCREEN = pygame.display.set_mode((SCREENW, SCREENH)) pygame.display.set_caption('rotating object') BLUE = (0, 50, 255) BLACK = (0, 0, 0) RED = (255, 0, 0) PURPLE = (145, 0, 100) yellow = (220,220, 0) FPS = 160 # frames per second platforms = pygame.sprite.Group() boxes = pygame.sprite.Group() ## this is the center of rotation. objects will be placed on the radius according to the step cx = SCREENW / 2 # x pos in relation to screen width cy = SCREENH / 2 # y pos in relation to screen height ## self, posx, posy, imagelist, speedx = 0, speedy = 0, value = 0 plat = pygame.image.load("platform.png").convert_alpha() box = pygame.image.load("box.png").convert_alpha() box = object_factory ([box], cx, cy - 300, 0, 2) boxes.add(box) RADIUS = 100 # distance from the center angle = radians(0) # angular distance between objects omega = 1 for x in xrange(1): xpos = (cos(angle * x) * RADIUS) + cx ypos = (sin(angle * x) * RADIUS) + cy obj = object_factory([plat], xpos, ypos) obj.cx = cx obj.cy = cy obj.difx = 0 obj.dify = 0 obj.angle = radians(60 * x) # position each object around (cx,cy) obj.radius = RADIUS # distance from the center obj.omega = radians(omega) obj.offsetx = cos(obj.angle) * obj.radius obj.offsety = -sin(obj.angle) * obj.radius platforms.add(obj) mouseposlist = [] okkoma = [platforms, boxes] x = 0 l = [] while True: SCREEN.fill(BLACK) x += 1 ##-------------------------------------------------------------- pygame.event.pump() keys = pygame.key.get_pressed() for event in pygame.event.get(): if event.type == MOUSEBUTTONDOWN: if event.button == 1: pos = pygame.mouse.get_pos() val = [pos[0], pos[1], 0, 0] print val mouseposlist.append(val) elif event.button == 3 and mouseposlist != []: mouseposlist.pop(-1) if event.type == KEYDOWN and event.key == K_ESCAPE: print mouseposlist pygame.quit() sys.exit() for hp in boxes: hp.move() hp.collide(platforms) ## MOVE THE SPRITE IN A CIRCLE center of rotation = cx,cy. Each object is placed by varying the step) pygame.draw.circle(SCREEN, BLUE, (cx, cy), RADIUS, 2) for obj in platforms: obj.angle += obj.omega # larger value increases speed ( angle gets larger) #obj.radius += .1 # this will make the object move in an expanding spiral obj.offsetx = cos(obj.angle) * obj.radius obj.offsety = -sin(obj.angle) * obj.radius obj.difx = obj.offsetx - obj.rect.x obj.dify = obj.offsety - obj.rect.y obj.speedx = round(obj.cx + obj.difx, 2) obj.speedy = round(obj.cy + obj.dify, 2) l.append([obj.speedx, obj.speedy]) obj.move() for ekak in okkoma: ekak.update() ekak.draw(SCREEN) ## -------------------------------------------------------------------- pygame.draw.line(SCREEN, BLUE, (0, SCREENH / 2), (SCREENW, SCREENH / 2), 2) pygame.draw.line(SCREEN, BLUE, (SCREENW / 2, 0), (SCREENW / 2, SCREENH), 2) pygame.display.update() FPSCLOCK.tick(FPS) pygame.time.wait(10) print l On Thu, Apr 30, 2015 at 12:27 PM, diliup gabadamudalige <dili...@gmail.com> wrote: > Thanks all for the very informative responses especially to Alan for being > descriptive. > > I am now going to make my movement linear and move away from my current > circular one. > > I hope a little bit of fun and "Thank you" emails fall into the order of > the day.. > > :) > > On Thu, Apr 30, 2015 at 9:13 AM, Dave Angel <da...@davea.name> wrote: > >> On 04/29/2015 02:37 PM, diliup gabadamudalige wrote: >> >>> I do not understand how Alan does not get the code that is in this >>> thread. >>> >> >> There are at least 3 ways of posting to "this thread": >> A) email >> B) newsgroup >> C) googlegroups >> >> and at least 5 ways of looking at "this thread" >> A) email >> B) email digest >> C) newsgroup >> D) googlegroups >> E) various archives >> >> To get messages from one region to another involves going through a >> gateway, and most of them damage some of the messages going through. To >> minimize the likelihood that what looks good on your screen will be missing >> or different on mine or on Alan's, follow a few rules: >> >> 1) avoid html >> 2) avoid attachments >> >> There are others, but those seem to be the biggies. >> >> Many other guidelines will help readability and consistency, like not >> top-posting, using proper quoting and attribution, giving enough >> information but not too much, specifying the whole environment in the FIRST >> message of a thread, etc. >> >> -- >> DaveA >> >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor >> > > > > -- > Diliup Gabadamudalige > > http://www.diliupg.com > http://soft.diliupg.com/ > > > ********************************************************************************************** > This e-mail is confidential. It may also be legally privileged. If you are > not the intended recipient or have received it in error, please delete it > and all copies from your system and notify the sender immediately by return > e-mail. Any unauthorized reading, reproducing, printing or further > dissemination of this e-mail or its contents is strictly prohibited and may > be unlawful. Internet communications cannot be guaranteed to be timely, > secure, error or virus-free. The sender does not accept liability for any > errors or omissions. > > ********************************************************************************************** > > -- Diliup Gabadamudalige http://www.diliupg.com http://soft.diliupg.com/ ********************************************************************************************** This e-mail is confidential. It may also be legally privileged. If you are not the intended recipient or have received it in error, please delete it and all copies from your system and notify the sender immediately by return e-mail. Any unauthorized reading, reproducing, printing or further dissemination of this e-mail or its contents is strictly prohibited and may be unlawful. Internet communications cannot be guaranteed to be timely, secure, error or virus-free. The sender does not accept liability for any errors or omissions. ********************************************************************************************** _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor