基于Pygame Zero的指南针游戏开发与优化
1. 指南针游戏0.1版本介绍
在开发游戏时,我们需要考虑用户的期望。例如,对于游戏计时器的显示,使用 floor 函数去除小数部分,以整数秒显示计时器,能让玩家在计时器显示为零时,直观地认为游戏结束。从10.9秒开始计时,到小于1秒结束,大约为10秒,玩家能看到从10到0的计时显示。
以下是指南针游戏0.1版本的完整代码:
import random
import math
WIDTH = 800
HEIGHT = 600
BACKGROUND_IMG = "compassgame_background_01"
game_state = ""
target_direction = ""
#Player character
player = Actor('compassgame_person_down_1', (WIDTH/2,HEIGHT/2))
# Which image is being displayed
player_step_count = 1
# Direction that player is facing
direction = 'down'
# Number of seconds to play when the timer starts
timer_start = 10.9
# number of seconds to decrement the timer each time we score a point
timer_decrement = 0.2
# This is the actual timer set t
超级会员免费看
订阅专栏 解锁全文
26

被折叠的 条评论
为什么被折叠?



