我已经在我的游戏中实现了重力,它一直在我的玩家身上。然而,当我的球员站在一个平台上时,他一直在上下摇晃。我该如何解决这个问题?
PLAYER_ACC = 0.65
PLAYER_FRICTION = -0.12
PLAYER_GRAVITY = 0.
class Player(pg.sprite.Sprite):
def __init__(self, game, x, y):
self.pos = vec(WIDTH / 2, HEIGHT / 2)
self.vel = vec(0, 0)
self.acc = vec(0, 0
def collision_with_walls(self):
collision = pg.sprite.spritecollide(self, self.game.walls, False)
if collision:
self.pos.y = collision[0].rect.top
self.vel.y = 0
def update(self):
self.acc.x += self.vel.x * PLAYER_FRICTION
self.vel += self.acc
self.pos += self.vel + 0.5 * self.acc
self.collision_with_walls()
self.rect.midbottom = self.pos
所有/任何帮助表示赞赏!