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

Commit

Permalink
Beta 1.0
Browse files Browse the repository at this point in the history
这里是 Beta 1.0 版本
整个游戏的基本框架已经构建好啦
但是许多的代码,仍然不够有序
在 Beta 2.0 中,我们将进行大量重构,将代码许多部分进行修改,遵行 OOP 原则,期待吧🥳
  • Loading branch information
Llonvne committed May 3, 2022
1 parent f7de594 commit 52ca611
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 23 deletions.
10 changes: 4 additions & 6 deletions src/SpeedboatDice.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pygame.event

from src.data.GameData import GameData
from src.debug import eventPrint
from src.events.handler.GameControllerEventHandler import GameControllerEventHandler
from src.events.handler.RollEventHandler import RollEventHandler
from src.events.handler.ScreenEventHandler import ScreenController
Expand All @@ -18,8 +19,6 @@ def __init__(self, screen: pygame.Surface):
# 向队列中推入游戏开始事件
StartGameEvent()

self.fcclock = pygame.time.Clock()

def run(self):
"""
启动游戏
Expand All @@ -46,9 +45,8 @@ def run(self):
"""
通过 event_debug 定义是否显示事件
"""
if event_debug and event.type >= pygame.USEREVENT:
print(event)

if event_debug:
eventPrint.eventPrint(event)
"""
如果事件类型为退出,则立刻执行退出
"""
Expand Down Expand Up @@ -81,5 +79,5 @@ def run(self):
elif event.type == ChooseKEnd:
AllowUserInput()
# 由 processUserInput 处理鼠标的事件
elif event.type == pygame.MOUSEMOTION:
elif event.type == pygame.MOUSEBUTTONUP:
processUserInput(event, data.round)
9 changes: 9 additions & 0 deletions src/debug/eventPrint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pygame

from src.events import events


def eventPrint(event: pygame.event.Event):
# 只显示用户事件
if event.type > pygame.USEREVENT:
print(event)
35 changes: 18 additions & 17 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@
from SpeedboatDice import SpeedboatDice
from src.VideoMusicControl import video, music

# 初始化 pygame 设置
if __name__ == '__main__':
# 初始化 pygame 设置

# 设置窗口大小,分辨率
window_size: tuple = (1280, 720)
caption = "快艇骰子"
# 设置窗口大小,分辨率
window_size: tuple = (1280, 720)
caption = "快艇骰子"

# 设置 LOGO
logo = pygame.image.load(os.path.join('Media', 'Pic', 'LOGO.jpeg'))
pygame.display.set_icon(logo)
# 设置 LOGO
logo = pygame.image.load(os.path.join('Media', 'Pic', 'LOGO.jpeg'))
pygame.display.set_icon(logo)

# 初始化 pygame 模块
pygame.init()
pygame.display.set_caption(caption)
screen = pygame.display.set_mode(window_size)
# 初始化 pygame 模块
pygame.init()
pygame.display.set_caption(caption)
screen = pygame.display.set_mode(window_size)

# 播放视频
video.play()
# 播放视频
video.play()

# 播放BGM
music.play()
# 播放BGM
music.play()

# 启动游戏
SpeedboatDice(screen).run()
# 启动游戏
SpeedboatDice(screen).run()
3 changes: 3 additions & 0 deletions src/tools/userInput.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ def processUserInput(event: Event, round: Round):
:param round:
:return:
"""
if 1075 < event.__dict__.get('pos')[0] < 1075 + 105 and 615 < event.__dict__.get('pos')[1] < 615 + 81:
print("123")
roll()

0 comments on commit 52ca611

Please sign in to comment.