Advertisement
Jaseman125

Points of a circle python code

Aug 21st, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. # POINTS OF A CIRCLE
  2.  
  3. # By Jaseman - 21st August 2012
  4.  
  5. import os, pygame; from pygame.locals import *
  6. from math import sin, cos, pi
  7. pygame.init(); clock = pygame.time.Clock()
  8. os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
  9. pygame.display.set_caption("Points Of A Circle")
  10. screen=pygame.display.set_mode((600,600),0,32)
  11.  
  12. background=pygame.Surface((600,600))
  13. background.fill((0,0,192))
  14.  
  15. dot=pygame.Surface((8,8))
  16. pygame.draw.circle(dot,(255,255,255),(4,4),4,0)
  17. dot.set_colorkey([0,0,0])
  18.  
  19. screen.blit(background,(0,0))
  20. screen.blit(dot,(300-4,300-4)) # Paste a dot in the centre of the screen
  21. # 300=half screen width 4=half dot width
  22.  
  23. radius = 200
  24. points = 90
  25.  
  26. angleStep = pi *2 / points
  27. for a in range(0,points):
  28. x = sin(a * angleStep)*radius
  29. y = cos(a * angleStep)*radius
  30. screen.blit(dot,(x+300-4,y+300-4)) # Paste dots in a circle
  31.  
  32.  
  33. pygame.display.update()
  34. pygame.time.wait(30000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement