Feb-17-2020, 04:29 PM
Hello everybody.
I am making a little game and somehow I can't figure out how to move my player sprite upwards or downwards without needing to rotate the player image.
So here is my code:
Piethon
I am making a little game and somehow I can't figure out how to move my player sprite upwards or downwards without needing to rotate the player image.
So here is my code:
vec = pg.math.Vector2 class Player(pg.sprite.Sprite): def get_keys(self): self.rot_speed = 0 self.vel = vec(0, 0) keys = pg.key.get_pressed() if keys[pg.K_LEFT] or keys[pg.K_a]: self.vel = vec(-PLAYER_SPEED / 2, 0).rotate(-self.rot) if keys[pg.K_RIGHT] or keys[pg.K_d]: self.vel = vec(PLAYER_SPEED, 0).rotate(-self.rot) if keys[pg.K_UP] or keys[pg.K_w]: pass if keys[pg.K_DOWN] or keys[pg.K_s]: passCan anybody tell me how to do this? Thanks, would be nice.
Piethon