随笔分类 - pygame
摘要:import sys,mathimport pygame#使用pygame之前必须初始化pygame.init()#设置主屏窗口screen = pygame.display.set_mode((800,600))#设置窗口标题pygame.display.set_caption('')# sour
阅读全文
摘要:import sys,mathimport pygame#使用pygame之前必须初始化pygame.init()#设置主屏窗口screen = pygame.display.set_mode((800,600))#设置窗口标题pygame.display.set_caption('')# sour
阅读全文
摘要:x0, y0 = 250, 250x1, y1 = 200, 200x2, y2 = 350, 200x3, y3 = 150, 300x4, y4 = 300, 300 d = True if y1 > 300: d = Falseelif y1 < 200: d = Trueif d == Fa
阅读全文
摘要:无约束:x1, y1, x2, y2, x3, y3, x4, y4 = 135, 135, 64, 135, 64, 64, 135, 64 x0,y0 = 100,100 y1 -= 10y2 -= 10y3 += 10y4 += 10 y1 += 10y2 += 10y3 -= 10y4 -=
阅读全文
摘要:点旋转:def count(angle,length): # y = y2-y1 y = math.sin(math.pi * (angle / 180)) * length y2 = int(y + y1) # x = x2-x1 x = math.cos(math.pi * (angle / 1
阅读全文
摘要:def count(angle): # y = y2-y1 y = math.sin(math.pi * (angle / 180)) * 50 y2 = int(y + y1) # x = x2-x1 x = math.cos(math.pi * (angle / 180)) * 50 x2 =
阅读全文
摘要:import math import pygame from pygame.locals import * # 导入pygame定义的常量 width,height = 480,360 pygame.init() screen = pygame.display.set_mode((width,hei
阅读全文
摘要:if y == 300 and x != 100: x -= 100 print(' x -= 100')elif x == 100 and y != 100: y -= 100 print(' y -= 100')elif y == 100 and x != 300: x += 100 print
阅读全文
摘要:import sysimport pygame#使用pygame之前必须初始化pygame.init()#设置主屏窗口screen = pygame.display.set_mode((400,400))#设置窗口标题pygame.display.set_caption('')# source =
阅读全文
摘要:# 事件类型# QUIT 用户按下窗口的关闭按钮 none# ATIVEEVENT Pygame被激活或者隐藏 gain,state# KEYDOWN 键盘按下 unicode、key、mod# KEYUP 键盘放开 key、mod# MOUSEMOTION 鼠标移动 pos, rel, butto
阅读全文
摘要:# pygame.draw.rect() 绘制矩形# pygame.draw.polygon() 绘制多边形# pygame.draw.circle() 根据圆心和半径绘制圆形# pygame.draw.ellipse() 绘制一个椭圆形# pygame.draw.arc() 绘制弧线(挥着椭圆的一
阅读全文
摘要:# pygame.font.init() 初始化字体模块# pygame.font.quit() 取消初始化字体模块# pygame.font.get_init() 检查字体模块是否被初始化,返回一个布尔值。# pygame.font.get_default_font() 获得默认字体的文件名。返回
阅读全文
摘要:#音效# pygame.mixer.Sound('test.mp3') #音效:wvb格式 背景音乐:ogg格式#Sound# play() 播放音效# stop() 停止播放# fadeout() 淡出# set_volume() 设置音量# get_volume() 获取音量# get_num_
阅读全文
摘要:# pygame.Rect(left,top,width,height)# pygame.Rect.copy() 复制矩形# pygame.Rect.move() 移动矩形区域,接受一个列表参数# pygame.Rect.move_ip() 移动矩形(无返回)# pygame.Rect.inflat
阅读全文
摘要:# Surface=pygame.Surface(size=(width,height),flags,depth)# 参数函数如下:# size:表示 Surface 对象的矩形区域大小;# flags:功能标志位,有两个可选参数值 pygame.HWSURFACE 和 pygame.SPCALPH
阅读全文
摘要:# 游戏暂停# pygame.time.get_ticks() 以毫秒为单位获取时间# pygame.time.wait() 使程序暂停一段时间# pygame.time.set_timer() 创建一个定时器,即每隔一段时间,去执行一些动作# pygame.time.Clock() 创建一个时钟对
阅读全文
摘要:# self.image 加载要显示的精灵图片,控制图片大小和填充色# self.rect 精灵图片显示在哪个位置# Sprite.update() 刷新精灵图,使其相应效果生效# Sprite.add() 添加精灵图到精灵组中(groups)# Sprite.remove() 从精灵组中删除选中的
阅读全文
摘要:import pygame# screen = pygame.display.set_mode(size=(),flags=0) #size:窗口大小,元组参数 flags:窗口样式# flags参数样式:# pygame.FULLSCREEN 创建一个全屏窗口。# pygame.HWSURFACE
阅读全文