我想要一些关于pygame 2D平台的帮助。下面是绘制精灵的代码,它看起来像什么,以及侧向滚动的代码,但是可以在它的整体中找到它here.
我从各种留言板上看过一些其他帖子,但我对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
目前没有回答
相关问题 更多 >
编程相关推荐