我不想在弯道不顺时撞车

2024-04-23 19:25:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我的游戏就像汽车从上方驶来,玩家必须通过向左或向右移动来躲避它

  • (x,y)是玩家的位置
  • (enemy_startx,enemy_starty)是敌人的立场

其他变量显而易见

#These are also the crash conditions for the game.
    if y < enemy_starty+enemy_height:
        if x > enemy_startx  and x < enemy_startx + enemy_width or x+(car_width+5) > enemy_startx and x + (car_width+5) < enemy_startx+enemy_width:
             crash()

Tags: andthe游戏if玩家crashwidthcar