- GRAVITY = 0.1 # Adjust this value to change the strength of the gravity
- ball_y_speed = 0 # Initial vertical speed of the ball
- # Game loop
- while True:
- # Update the position of the ball based on its current speed
- ball_y_position += ball_y_speed
- # Apply gravity to the ball's speed
- ball_y_speed += GRAVITY
- # Check if the ball has hit the bottom of the screen
- if ball_y_position > SCREEN_HEIGHT:
- ball_y_position = SCREEN_HEIGHT # Set the ball's position to the bottom of the screen
- ball_y_speed = 0 # Reset the ball's vertical speed to zero
- # Update the position of the ball on the screen
- draw_ball(ball_x_position, ball_y_position)
[text] jasfdkasjf
Viewer
Editor
You can edit this paste and save as new:
File Description
- jasfdkasjf
- Paste Code
- 23 Mar-2023
- 715 Bytes
You can Share it: