Can you make sure everything is in the loop? import pygame import sys Set up display…
- User
Can you make sure everything is in the loop? import pygame import sys
Set up display
screen = pygame.display.set_mode((900, 700))
Set the Kirby pink color (RGB format)
kirby_pink_color = (255, 105, 180) ground_color = (0, 255, 0) # Green color for the ground
Circle properties
circle_radius = 25 # Initial radius circle_y_offset = 25 # Offset from the top of the circle
Circle position and velocity
circle_x, circle_y = 425, 500 circle_x_speed, circle_y_speed = 0, 0 gravity = 1 jump_height = -15 # Set jump height
Variables for crouching and in-air state
is_crouching = False crouch_scale = 0.5 # Scale factor for crouching in_air = False
Movement flags
is_moving_left = False is_moving_right = False is_floating = False
Load the Kirby face image
kirby_face = pygame.image.load("kirby_face.png")
#Boot game pygame.init()
Game loop
while True: for event in pygame.event.get(): if event.type == pygame.QUIT:
code - Assistant
Yes, everything is already in the game loop.
- User
Weird, because ChatGPT4 said that there was an issue that was causing it to blackscreen because of the loop.
- Assistant
- User
There' now a slight issue with the crouching, he goes slightly into the ground.
- Assistant
- User
Now he goes all the way into the ground.
- Assistant
- User
now hes floating.
- Assistant
Apologies for the oversight. To prevent the Kirby character from floating, you need to modify the logic for the in-air state. Here's the revised code:
python# Game loop while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() sys.exit() elif event.type == pygame.KEYDOWN: if event.key == pygame.K_s and not is_crouching: is_crouching = True elif event.key == pygame.K_w and not in_air: circle_y_speed = jump_height in_air = True elif event.key == pygame.K_e and not is_crouching: is_floating = True elif event.key == pygame.K_r: is_floating = False elif event.key == pygame.K_a: is_moving_left = True elif event.key == pygame.K_d: is_moving_right