python - Sprite keeps shaking up and down -


i have implemented gravity game, , keeps pulling down onto player. yet, when player standing on platform, keeps shaking , down. how can fix this?

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 

all/any appreciated!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -