Мне нужна помощь в добавлении прокрутки в 2D-платформер Pygame - PullRequest
0 голосов
/ 17 октября 2019

Мне нужна помощь с Pygame 2D-платформером. Ниже приведен код для рисования спрайта, как он выглядит и код для боковой прокрутки, но его можно найти здесь целиком .

Я посмотрел нанекоторые другие сообщения из различных досок объявлений, но я очень плохо знаком с программированием на Python и понятия не имею, что это такое (например, основной цикл).

Он уже имеет прокрутку из стороны в сторону, если это имеет значение.

Заранее спасибо за помощь.

class Player(pygame.sprite.Sprite):
"""
This class represents the bar at the bottom that the player controls.
"""

# -- Methods
def __init__(self):
    """ Constructor function """

    # Call the parent's constructor
    super().__init__()

    # Create an image of the block, and fill it with a color.
    # This could also be an image loaded from the disk.
    width = 40
    height = 60
    self.image = pygame.Surface([width, height])
    self.rect = self.image.get_rect()

    # Set a referance to the image rect.
    self.rect = self.image.get_rect()

    HERE IS THE CODE FOR SCROLLING SIDE-TO-SIDE

    # Keep track of the shift amount
    self.world_shift += shift_x

    # Go through all the sprite lists and shift
    for platform in self.platform_list:
        platform.rect.x += shift_x

    for enemy in self.enemy_list:
        enemy.rect.x += shift_x
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...