I think these are the most relevant parts:
def jump(self):
self.rect.y += 2
# if we can jump, set our speed up
if ((len(hits) > 0) or (self.rect.bottom >= WinHeight)):
self.change_y = -10
def calcgrav(self):
#does gravity stuff
if (self.change_y == 0):
self.change_y = 1
else:
self.change_y += 0.35
#check if on ground
if ((self.rect.y >= WinHeight- self.rect.height) and (self.change_y >= 0)):
self.change_y = 0
self.rect.y = WinHeight - self.rect.height
This is within a class named Player, and it's a pygame sprite. change_y is the change in y of the sprite. Calc_grav() is called within my Player class update function. Hits is a list of collisions with my platforms and sprites. WinHeight is the height of my pygame window.