Advertisement
Guest User

Complex2

a guest
Aug 25th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.64 KB | None | 0 0
  1. import pygame
  2.  
  3. def nc(b):
  4.     a = [WIN_WIDTH//2, WIN_HEIGHT//2]
  5.     return([a[0]+b[0]*50,a[1]-b[1]*50])
  6.  
  7.  
  8.  
  9. FPS = 60
  10. WIN_WIDTH = 1000
  11. WIN_HEIGHT = 800
  12.  
  13. WHITE = (255, 255, 255)
  14. BLACK = (0, 0, 0)
  15. GRAY = (125, 125, 125)
  16. LIGHT_BLUE = (64, 128, 255)
  17. GREEN = (0, 200, 64)
  18. YELLOW = (225, 225, 0)
  19. PINK = (230, 50, 230)
  20.  
  21. pygame.init()
  22.  
  23. clock = pygame.time.Clock()
  24.  
  25. sc = pygame.display.set_mode((WIN_WIDTH, WIN_HEIGHT))
  26.  
  27. center = [WIN_WIDTH//2, WIN_HEIGHT//2]
  28.  
  29. dom = [[1,1],[3,1],[3,3],[2,4],[1,3]]
  30.  
  31. #pov = [1/2**0.5, 1/2**0.5]
  32.  
  33. #centr_pov = [2,2]
  34.  
  35. #for y in dom:
  36. #    x = [y[0]-centr[0], y[1]-centr[1]]
  37. #    print(x[0]*pov[0] - x[1]*pov[1] + centr_pov[0], x[0]*pov[1] + x[1]*pov[0]+centr_pov[1])
  38.  
  39.  
  40. #Замена координат дома
  41. for i in range(len(dom)):
  42.     dom[i] = nc(dom[i])
  43.  
  44. points = []
  45. for i in range(0, WIN_WIDTH+1,50):
  46.     points.append([i,WIN_HEIGHT//2])
  47. for i in range(0,WIN_HEIGHT+1,50):
  48.     points.append([WIN_WIDTH//2,i])
  49.  
  50.  
  51. while 1:
  52.     sc.fill(WHITE)
  53.  
  54.     for i in pygame.event.get():
  55.         if i.type == pygame.QUIT: exit()
  56.     #Вот здесь всё рисуем
  57.  
  58.     #ось х
  59.     pygame.draw.aaline(sc, BLACK, nc([-WIN_WIDTH//2, 0]), nc([WIN_WIDTH//2, 0]))
  60.     #ось у
  61.     pygame.draw.aaline(sc, BLACK, nc([0, -WIN_HEIGHT//2]), nc([0, WIN_HEIGHT//2]))
  62.     #точки на осях
  63.     for point in points:
  64.         pygame.draw.circle(sc, BLACK, point, 3)
  65.     #центр (0,0)
  66.     pygame.draw.circle(sc, BLACK, nc([0, 0]), 5)
  67.  
  68.     #Дом!
  69.     pygame.draw.polygon(sc, YELLOW, dom)
  70.  
  71.     #до сюда  
  72.     pygame.display.update()
  73.  
  74.  
  75.     pygame.time.delay(1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement