PyGame學習

 

目錄

入門

畫一個奧運五環

入門

畫一個奧運五環

import pygame
import sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600, 500))
# None 使用默認字體  60 是字體大小
myfont = pygame.font.Font(None, 60)
white = 255, 255, 255
blue = 255, 0, 0
textImage = myfont.render("Hello World!", True, white)

while True:
    for event in pygame.event.get():
        if event.type in (QUIT, KEYDOWN):
            sys.exit()
    screen.fill(blue)
    screen.blit(textImage, (100, 100))

    # 繪製圓
    color_blue = 41, 167, 225
    color_black = 35,24,22
    color_green = 35,172,56
    color_yellow = 255,241,0
    color_white = 255,255,255
    position_1 = 100, 255
    position_2 = 210, 255
    position_3 = 320, 255
    position_4 = 155, 305
    position_5 = 265, 305
    radius = 50
    width = 5
    pygame.draw.circle(screen, color_blue, position_1, radius, width)
    pygame.draw.circle(screen, color_black, position_2, radius, width)
    pygame.draw.circle(screen, color_green, position_3, radius, width)
    pygame.draw.circle(screen, color_yellow, position_4, radius, width)
    pygame.draw.circle(screen, color_white, position_5, radius, width)
    pygame.display.update()

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章