繪制一個圓2,運用colorkey alpha
阿新 • • 發佈:2018-05-13
IT nbsp ini style spl erb port HA col
1 import pygame
2
3 pygame.init()
4 screen = pygame.display.set_mode((640, 480))
5 # -----設置背景-----
6 background = pygame.Surface(screen.get_size())
7 background.fill((255, 240, 245)) # fill LavenderBlush
8 # ----- 繪制一個圓 -----
9 ballsurface = pygame.Surface((640, 480))
10 ballsurface.set_colorkey((0, 0, 0)) # 將黑色設為色鍵
11 pygame.draw.circle(ballsurface, (224, 255, 255), (640//2, 480//2), 480//2)
12 # ----- 布局 ------
13 background = background.convert()
14 screen.blit(background, (0, 0))
15
16 ballsurface = ballsurface.convert_alpha()
17 screen.blit(ballsurface, (0, 0))
18 # ----- 顯示 -----
19 pygame.display.flip()
繪制一個圓2,運用colorkey alpha