摘要: 下面介绍Info类,界面的显示大部分都是由它来完成,init函数中create_info_labels函数创建通用的信息,create_state_labels函数对于不同的状态,会初始化不同的信息。 class Info(): def __init__(self, game_info, state 阅读全文
posted @ 2019-09-17 17:48 水至清明 阅读(417) 评论(0) 推荐(0) 编辑
摘要: Control 是状态机类,main函数是游戏的主循环,setup_states函数设置游戏启动时运行的状态。 class Control(): def __init__(self): self.screen = pg.display.get_surface() self.done = False 阅读全文
posted @ 2019-09-17 17:48 水至清明 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 有两个文件constants.py 和 state_demo.pyconstants.py 保存了所有的字符串定义和常量 constants.pyGAME_TIME_OUT 表示游戏的超时时间,这边为了demo演示,设成了5秒,实际是300秒。 SCREEN_HEIGHT = 600SCREEN_W 阅读全文
posted @ 2019-09-17 17:48 水至清明 阅读(577) 评论(0) 推荐(0) 编辑
摘要: private int curATK;private int curAtkKey;public int CurATK { get { return curATK ^ curAtkKey; }(http://www.my516.com) set { curAtkKey = Random.Range(0 阅读全文
posted @ 2019-09-17 17:48 水至清明 阅读(655) 评论(0) 推荐(0) 编辑
摘要: 先定义一个State 基类, 按照上面说的状态需要的三个操作分别定义函数(startup, update, cleanup)。在 init 函数中定义了上面说的三个变量(next,persist,done),还有start_time 和 current_time 用于记录时间。 class Stat 阅读全文
posted @ 2019-09-17 17:46 水至清明 阅读(374) 评论(1) 推荐(0) 编辑