首页 > 代码库 > python2.7之pygame
python2.7之pygame
1 pygame窗口设置
pygame在导入后,第一步需要进行初始化:
import pygame
pygame.init()
pygame可以设置标题
pygame.display.set_caption(‘gold615‘)
也可以设置界面的大小
screen=pygame.display.set_mode([640,480])#可以看到参数是一个列表
当然颜色就更别提了
screen.fill([255,255,255])#用白色填充窗口,可以根据需求随便设置颜色.
2 事件
目前看到的python代码似乎没有事件监听部分,还是需要在循环中进行处理.
退出事件
while True: for event in pygame.event.get(): if event.type==pygame.QUIT: sys.exit()
3 画圆用pygame.draw.circle()
pygame.draw.circle(screen,[255,0,0],[100,100],30,0) #第一个参数指定画在哪里,第二个指定使用的颜色,第三个指定画的位置,第四个指定半径,第五个指定线宽.
python2.7之pygame
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。