fork download
  1. import pygame
  2. import sys
  3.  
  4. '''
  5. http://p...content-available-to-author-only...e.org/docs/ref/draw.html#pygame.draw.circle
  6. http://p...content-available-to-author-only...e.org/docs/ref/draw.html#pygame.draw.line
  7. '''
  8. screensize = [800, 600]
  9. pygame.init()
  10.  
  11. '''
  12. initialize a window or screen for display
  13. pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface
  14. '''
  15. screen = pygame.display.set_mode(screensize)
  16.  
  17. pygame.display.set_caption('Graphs')
  18. screen.fill(pygame.color.THECOLORS['white'])
  19. pygame.display.update()
  20.  
  21. '''
  22. draw a straight line segment
  23. pygame.draw.line(Surface, color, start_pos, end_pos, width=1): return Rect
  24. '''
  25. pygame.draw.line(screen, pygame.color.THECOLORS['red'], (100, 100), (400, 400), 5)
  26. pygame.display.update()
  27.  
  28. '''
  29. draw a circle around a point
  30. pygame.draw.circle(Surface, color, pos, radius, width=0): return Rect
  31. '''
  32. pygame.draw.circle(screen, pygame.color.THECOLORS['purple'], (100, 100), 64)
  33. pygame.display.update()
  34.  
  35. pygame.draw.circle(screen, pygame.color.THECOLORS['blue'], (400, 400), 64)
  36. pygame.display.update()
  37.  
  38. # TODO (DONE) look up how to work with text.
  39.  
  40. # Create a font
  41. font = pygame.font.Font(None, 64)
  42.  
  43. # Render the text
  44. text = font.render('23', True, pygame.color.THECOLORS['black'])
  45.  
  46. # Create a rectangle
  47. textRect = text.get_rect()
  48.  
  49. # Center the rectangle
  50. textRect.centerx = 400
  51. textRect.centery = 400
  52.  
  53. # Blit the text
  54. screen.blit(text, textRect)
  55.  
  56. pygame.display.update()
  57.  
  58. while True:
  59. for event in pygame.event.get():
  60. if event.type == pygame.QUIT:
  61. sys.exit()
Runtime error #stdin #stdout #stderr 0.01s 27712KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'pygame'