• Как убрать зеленую точку в середине екрана?

    DanielPY
    @DanielPY Автор вопроса
    забыл
    import pygame

    pygame.init()

    width = 500
    height = 500

    display = pygame.display.set_mode((500,500))

    pygame.display.update()
    pygame.display.set_caption('Змейка')

    game_end = False

    colors = {'Snake Head': (0, 255, 0),
    'Snake Tail': (0, 200, 0),
    'Apple': (255, 0, 0)
    }

    snake_pos = {
    'x': width/2-5,
    'y': height/2-5,
    'x_changes': 0,
    'y_changes': 0
    }

    snake_size = (10, 10)

    snake_speed = 0.25

    while not game_end:
    for event in pygame.event.get():
    if event.type == pygame.QUIT:
    game_end = True

    elif event.type == pygame.KEYDOWN:
    if event.key == pygame.K_LEFT:
    snake_pos['x_changes'] = - snake_speed
    snake_pos['y_changes'] = 0
    pass
    if event.key == pygame.K_RIGHT:
    snake_pos['x_changes'] = snake_speed
    snake_pos['y_changes'] = 0
    pass
    if event.key == pygame.K_UP:
    snake_pos['x_changes'] = 0
    snake_pos['y_changes'] = - snake_speed
    pass
    if event.key == pygame.K_DOWN:
    snake_pos['x_changes'] = 0
    snake_pos['y_changes'] = snake_speed
    pass

    display.fill((0,0,0))

    snake_pos['x'] += snake_pos['x_changes']
    snake_pos['y'] += snake_pos['y_changes']

    if(snake_pos['x'] < - snake_size[0]):
    snake_pos['x'] = width

    elif(snake_pos['x'] > width):
    snake_pos['x'] = 0

    elif(snake_pos['y'] < - snake_size[1]):
    snake_pos['y'] = height

    elif (snake_pos['y'] > height):
    snake_pos['y'] = 0

    pygame.draw.rect(display, colors['Snake Head'], [
    snake_pos['x'],
    snake_pos['y'],
    snake_size[0],
    snake_size[1]])

    pygame.display.update()

    pygame.draw.rect( display, (0, 255, 0), [500/2-5, 500/2-5, 10, 10])

    pygame.display.update()

    pygame.quit()
    quit()