parent
191528c036
commit
a9f5726365
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Black">
|
||||
<option name="sdkName" value="Python 3.12 (Python 3.12venv)" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (Python 3.12venv)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/扫雷.iml" filepath="$PROJECT_DIR$/.idea/扫雷.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="jdk" jdkName="Python 3.12 (Python 3.12venv)" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,22 @@
|
||||
import pygame
|
||||
|
||||
|
||||
class Button:
|
||||
"""生成图形的类"""
|
||||
|
||||
def __init__(self, screen, message):
|
||||
self.screen = screen
|
||||
self.message = message
|
||||
self.screen_rect = self.screen.get_rect()
|
||||
self.font = pygame.font.SysFont(None, 48)
|
||||
self.font_color = (0, 70, 0)
|
||||
self.image = self.font.render(self.message, True, self.font_color, None)
|
||||
self.image_rect = self.image.get_rect()
|
||||
self.image_rect.center = self.screen_rect.center
|
||||
|
||||
def place(self, x, y):
|
||||
self.image_rect.x = x
|
||||
self.image_rect.y = y
|
||||
|
||||
def display(self):
|
||||
self.screen.blit(self.image, self.image_rect)
|
@ -0,0 +1,35 @@
|
||||
import sys
|
||||
from time import sleep
|
||||
|
||||
import pygame
|
||||
|
||||
from button import Button
|
||||
|
||||
|
||||
class Cover:
|
||||
"""管理游戏覆盖物的类"""
|
||||
|
||||
def __init__(self, setting, screen): # 游戏参数设置和游戏主界面
|
||||
self.setting = setting
|
||||
self.screen = screen
|
||||
self.winButton = Button(self.screen, 'Congratution')
|
||||
|
||||
self.covers = [] # 存储未被点击过的方块的覆盖物的位置
|
||||
for i in range(20):
|
||||
for j in range(20):
|
||||
self.covers.append([i, j]) # 刚开始时整个界面都是被覆盖的
|
||||
|
||||
def delete(self, x, y): # 传入单机鼠标的位置,判断是否合法,如果是,删除当前方块
|
||||
x = x // 25
|
||||
y = y // 25
|
||||
if [x, y] in self.covers:
|
||||
self.covers.remove([x, y])
|
||||
|
||||
def show(self): # 将所有未被点击过的方块展现出来
|
||||
for cur in self.covers:
|
||||
pygame.draw.rect(self.screen, self.setting.screen_color, ((cur[0] * 25, cur[1] * 25), (24, 24)))
|
||||
if len(self.covers) <= 40:
|
||||
self.winButton.display()
|
||||
pygame.display.update()
|
||||
sleep(3)
|
||||
sys.exit()
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
import sys #结束游戏
|
||||
from time import sleep #暂停游戏
|
||||
|
||||
import pygame
|
||||
|
||||
class Over:
|
||||
"""控制游戏结束的类"""
|
||||
def __init__(self, screen): #游戏主界面
|
||||
self.is_over = False
|
||||
self.screen = screen
|
||||
self.screen_rect = self.screen.get_rect()
|
||||
|
||||
self.msg = 'GAME OVER'
|
||||
#渲染文字'GAME OVER'到游戏主界面上
|
||||
self.font = pygame.font.SysFont(None, 48)
|
||||
self.image = self.font.render(self.msg, True, (100, 0, 0), (0, 0, 60))
|
||||
self.rect = self.image.get_rect()
|
||||
self.rect.center = self.screen_rect.center #将文字放在界面中心
|
||||
|
||||
def show(self): #遇见炸弹,游戏结束,结束前将玩家遇到的炸弹标记未红色方块并在结束前绘制出来
|
||||
self.screen.blit(self.image, self.rect)
|
||||
pygame.display.update()
|
||||
|
Loading…
Reference in new issue