Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

simulate gravity in pythpn

player_y = 100
vel = 0 #  Velocity
jumping_state = False
player_y += vel

# Let's say something happends (like a key input) and jumping_state is True

def gravity(vel):
  if jumping_state:
    player_y = player_y - 20  # How high the player jumps
    vel += 0.1 # Or a different value
    jumping_state = False
    
gravity(vel)
 
PREVIOUS NEXT
Tagged: #simulate #gravity #pythpn
ADD COMMENT
Topic
Name
8+4 =