0

I am trying to make a Geometry Dash clone in PyGame but have not made it very far. So far I have a cube that moves to the right and a jump function that is called every time the user presses the space button. My problem is that I can't figure out how to make the shape of the jump an arc or a parabola (I believe it would be parabola since after a certain distance the cube has fallen it should reach terminal velocity like in the game). Right now when the player presses the space button they get teleported up 150 pixels and then the gravity brings them down at a linear rate.

Player class (The cube):

class Player:
    PLAYER_WIDTH, PLAYER_HEIGHT = 50, 50
    GRAVITY = 3

    def __init__(self, velo):
        self.velo = velo
        self.jump_height = self.PLAYER_HEIGHT * 3
        self.x, self.y = 10, 10
        self.cube = pygame.Rect(WIDTH/4, HEIGHT - self.PLAYER_WIDTH, self.PLAYER_WIDTH, self.PLAYER_HEIGHT)

    def move(self):
        self.cube.x += self.velo

        if self.cube.y + self.PLAYER_HEIGHT < HEIGHT:
            self.cube.y += self.GRAVITY

    def jump(self):
        if self.cube.y + self.PLAYER_HEIGHT == HEIGHT:
            self.cube.y -= self.jump_height

    def die(self):
        pass
YungOne
  • 53
  • 4

0 Answers0