minirpg002.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:mini_rpg 作者: paolo-perfahl 项目源码 文件源码
def loadresources(self):
        """painting on the surface (once) and create sprites"""
        # make an interesting background 
        draw_examples(self.background) # background artwork
        try:  # ----------- load sprite images -----------
            PygView.images.append(pygame.image.load(os.path.join("data", "babytux.png"))) # index 0
            # load other resources here
        except:
            print("pygame error:", pygame.get_error())
            print("please make sure there is a subfolder 'data' and in it a file 'babytux.png'")
            pygame.quit()
            sys.exit()
        # -------  create (pygame) Sprites Groups and Sprites -------------
        self.allgroup =  pygame.sprite.LayeredUpdates() # for drawing
        self.ballgroup = pygame.sprite.Group()          # for collision detection etc.
        self.hitpointbargroup = pygame.sprite.Group()
        self.bulletgroup = pygame.sprite.Group()
        self.tuxgroup = pygame.sprite.Group()
        self.enemygroup = pygame.sprite.Group()
        # ----- assign Sprite class to sprite Groups ------- 
        Tux.groups = self.allgroup, self.tuxgroup
        Hitpointbar.groups = self.hitpointbargroup
        Ball.groups = self.allgroup, self.ballgroup
        Evildoge.groups = self.enemygroup, self.allgroup
        Bullet.groups = self.allgroup, self.bulletgroup
        self.ball1 = Ball(x=100, y=100) # creating a Ball Sprite
        self.ball2 = Ball(x=200, y=100) # create another Ball Sprite
        self.tux1 = Tux(x=400, y=200, dx=0, dy=0, layer=5, imagenr = 0) # over balls layer
        #self.evildoge = Evildoge(x=150, y=350)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号