From 9f15c70cb2bbdfbd642a32ce2d7de29dae3fa52f Mon Sep 17 00:00:00 2001 From: 206530308 <2978914674@qq.com> Date: Tue, 15 Jun 2021 15:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 3.py diff --git a/3.py b/3.py new file mode 100644 index 0000000..5361e3b --- /dev/null +++ b/3.py @@ -0,0 +1,30 @@ +import pygame #导入pygame模块 +from pygame.locals import * #导入pygame.locals模块 +import time #导入time模块 + +#子弹类 +class Bullet(object): + #构造方法,用于初始化子弹对象的属性 + def __init__(self, screen_temp, x, y): + self.x = x+40 #子弹起始x坐标 + self.y = y-20 #子弹起始y坐标 + self.screen = screen_temp #窗口 + self.image = pygame.image.load("C:/work/youxi/zidan.png") #创建一个子弹图片 + #显示子弹图片的方法 + def display(self): + self.screen.blit(self.image, (self.x, self.y)) #显示子弹图片 + #子弹移动方法 + def move(self): + self.y-=10 #子弹y坐标自减10 + #判断子弹是否越界的方法 + def judge(self): + if self.y<0: #如果子弹的y坐标小于0 + return True #返回true正确 + else: + return False #返回false错误 + + + + + +