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()

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值