zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然python学习笔记:python 用pygame模块基本绘图

    绘制几何图形是游戏包的基本功能,很多游戏角色都是由基本图形组合而成的 。
    绘制矩形: pygame.draw.rect
    Pygam巳绘制矩形的语法为:

     

     

     

     

     

    用基本绘图绘制一个人脸
    用基本绘图功能绘制人脸

    import pygame
    
    pygame.init()
    screen = pygame.display.set_mode((300, 300))
    pygame.display.set_caption("基本绘图")
    
    background = pygame.Surface(screen.get_size())
    background = background.convert()
    background.fill((255,255,255))
    
    pygame.draw.circle(background, (0,0,0), (150,150), 130, 4)
    pygame.draw.circle(background, (0,0,255), (100,120), 25, 0)
    pygame.draw.circle(background, (0,0,255), (200,120), 25, 0)
    pygame.draw.ellipse(background, (255,0,255),[135, 130, 30, 80], 0)
    pygame.draw.arc(background, (255,0,0), [80, 130, 150, 120], 3.4, 6.1, 9)
    
    screen.blit(background, (0,0))
    pygame.display.update()
    
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
    pygame.quit()

  • 相关阅读:
    php设计模式 — 简单工厂模式(静态工厂方法模式)
    Vue-Router
    各种选项卡
    jq动画
    如何使用swiper写轮播
    Gulp代码压缩
    闭包
    jquery.validation校验
    grunt-js文件压缩
    CSS
  • 原文地址:https://www.cnblogs.com/tszr/p/12036391.html
Copyright © 2011-2022 走看看