当我在 linux 上进行测试时,一切都很好,但是在我的 windows 机器上,我不能沿对角线向下和向左移动(但可以向其他三个对角线移动)。
if event.type == QUIT or event.type == KEYDOWN and event.key == K_ESCAPE:
self.running = False
if event.type == KEYDOWN:
if event.key == K_SPACE:
self.player.shooting = True
if event.key == K_UP:
self.player.moving.add("forward")
if event.key == K_DOWN:
self.player.moving.add("back")
if event.key == K_RIGHT:
self.player.moving.add("right")
if event.key == K_LEFT:
self.player.moving.add("left")
if event.type == KEYUP:
if event.key == K_SPACE:
self.player.shooting = False
if event.key == K_UP:
self.player.moving.remove("forward")
if event.key == K_DOWN:
self.player.moving.remove("back")
if event.key == K_RIGHT:
self.player.moving.remove("right")
if event.key == K_LEFT:
self.player.moving.remove("left")
这是进行移动的更新方法:
def update (self, time_passed):
tp = time_passed # From clock.tick(60)
if self.moving:
if "forward" in self.moving and (self.rect.top > 0):
self.rect.move_ip(0, -self.speed*tp)
if "back" in self.moving and (self.rect.bottom < self.screen_ref[1]):
self.rect.move_ip(0, self.speed*tp)
if "left" in self.moving and (self.rect.left > 0):
self.rect.move_ip(-self.speed*tp, 0)
if "right" in self.moving and (self.rect.right < self.screen_ref[0]):
self.rect.move_ip(self.speed*tp, 0)
我刚才检查以再次检查我没有破坏任何已确认的内容。对角向下和向左不起作用。我要么开始往下走,然后改为向左移动,要么开始向左移动,然后改为向下移动。任何人有任何想法为什么?