Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
完成!
Browse files Browse the repository at this point in the history
  • Loading branch information
Llonvne committed May 30, 2022
1 parent 4760ca0 commit ac015a7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ Hello!🥳,这是我们的Python课程设计的作业,素材来自世界51游
游戏玩法: 详见 Wiki https://zh.wikipedia.org/wiki/快艇骰子
绝大部分规则遵守 世界51游戏大全-任天堂,与 Wiki 上的稍有出入

待完成事项:

* 游戏鼠标控制部分逻辑
* 游戏各种动画,音效添加
* 代码封装行

库依赖:

* pygame
Expand Down
20 changes: 11 additions & 9 deletions src/SpeedboatDice.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ def run(self):
running = False
break

if event.__dict__.get("类型") == "游戏流程控制时间" and event.__dict__.get('描述') == '游戏结束':
if event.__dict__.get("类型") == "游戏流程控制时间" and event.__dict__.get('描述') == '游戏结束' or goodGame:
if self.players[1].board.totalScore() > self.players[0].board.totalScore():
winnerID = 1
if winnerID == 0:
self.game.display((Pic(config.win_pic_path),(190,50)))
else:
self.game.display((Pic(config.win_pic_path), (270, 50)))
pygame.display.update()
# displayWinner(self.game,winnerID)
goodGame = True

if goodGame:
Expand All @@ -63,7 +64,7 @@ def run(self):
for i in range(10):
self.players[inTermPlayerNo].rollNotCostChances()
self.game.wait(110)
self.game.screenUpdate(self.players)
self.game.screenUpdate(self.players,self.termCount)

# 处理 选择事件
if event.__dict__.get("类型") == "骰子事件" and event.__dict__.get('描述') == "选择":
Expand All @@ -76,7 +77,7 @@ def run(self):
if event.__dict__.get('类型') == '分数选择':
chooseScore(self.players[inTermPlayerNo], event)
if event.__dict__.get('类型') == '游戏流程控制事件' and event.__dict__.get('描述') == '玩家选择分数完毕':
if inTermPlayerNo == 1 and self.termCount == 12:
if inTermPlayerNo == 1 and self.termCount == 2:
self.game.postEvent("游戏流程控制时间", "游戏结束")
self.players[inTermPlayerNo].isYourTerm = False
self.players[1 - inTermPlayerNo].isYourTerm = True
Expand All @@ -85,9 +86,10 @@ def run(self):
if inTermPlayerNo == 0:
self.termCount += 1
# 调用 Game 处理屏幕更新
if goodGame:
if winnerID == 0:
self.game.display((Pic(config.win_pic_path), (190, 50)))
else:
self.game.display((Pic(config.win_pic_path), (270, 50)))
self.game.screenUpdate(self.players)
# if goodGame:
# if winnerID == 0:
# self.game.display((Pic(config.win_pic_path), (190, 50)))
# else:
# self.game.display((Pic(config.win_pic_path), (270, 50)))
if not goodGame:
self.game.screenUpdate(self.players,self.termCount)
9 changes: 5 additions & 4 deletions src/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def displayerScore(self, *players: Player):
displaytext(self.screen, (noToRead.get("reward"), i), (35 if players[i].board.numCount() >= 63 else 0),
True)

def screenUpdate(self, players: list[Player]):
def screenUpdate(self, players: list[Player],term:int):
"""
屏幕更新函数
:param players: 玩家列表 用于显示玩家内部的骰子等
Expand All @@ -160,10 +160,9 @@ def screenUpdate(self, players: list[Player]):
# 显示背景
self.display((self.backGround, (0, 0)))

# 显示玩家头像
displayer(self)



# 显示 Roll
self.display((self.roll, (725, 600)))

Expand All @@ -176,7 +175,9 @@ def screenUpdate(self, players: list[Player]):
else:
self.displayDices(players[1].diceBoard.toDisplayable())

disTermCount(self, 10)
# 显示回合数
disTermCount(self, term)

# 更新屏幕
self._clock.tick(config.fps)
pygame.display.update()
Expand Down
19 changes: 13 additions & 6 deletions src/game/media/display/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import pygame.font




def displayText(display, value, isBlack, point):
"""
Expand Down Expand Up @@ -107,15 +105,24 @@ def displaytotal(screen: pygame.surface, point, vlaue, color):
Font_surface = Font.render(str(vlaue), True, color, None)
screen.blit(Font_surface, (star_x + lenth_x * point[1], star_y))

def disTermCount(game,term:int):

if term>=10:
def disTermCount(game, term: int):
if term >= 10:
star_x = 35
star_y = 57
else:
star_x = 52
star_y = 57
color=(120,118,106)
color = (120, 118, 106)
Font = pygame.font.Font(pygame.font.get_default_font(), 32)
Font_surface = Font.render(str(term), True, color, None)
game.screen.blit(Font_surface, (star_x, star_y))
game.screen.blit(Font_surface, (star_x, star_y))


def displayWinner(game, winnerID:int):
star_x = 52
star_y = 57
color = (120, 118, 106)
Font = pygame.font.Font(pygame.font.get_default_font(), 32)
Font_surface = Font.render(str(winnerID), True, color, None)
game.screen.blit(Font_surface, (star_x, star_y))

0 comments on commit ac015a7

Please sign in to comment.