|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
跟着小甲鱼老师敲的代码,出现了超出最大递归深度的异常- import pygame
- import sys
- from pygame.locals import *
- import random
- #pygame.sprite.Sprite动画精灵类
- class Ball(pygame.sprite.Sprite):
- def ___init__(self, image, pos, speed):
- pygame.sprite.Sprite.__init__(self)
- self.image = pygame.image.load(image).convert_alpha()
- self.rect = self.image.get_rect()
- self.rect.left, self.rect.top = pos
- self.speed = speed
- ## self.width, self.height = bg_size[0], bg_size[1]
- def main():
- pygame.init()
- ball_image = '173303o7gm7x5b57f972gz.png'
- bg_image = '173302oeettatvv00vv3bu.png'
-
- running = True
- bg_size = width, height = 1024, 681
- screen = pygame.display.set_mode(bg_size)
- pygame.display.set_caption('play the ball')
- background = pygame.image.load(bg_image).convert_alpha()
- balls = []
- for i in range(5):
- pos = random.randint(0, width - 100), random.randint(0, height - 100)
- speed = [random.randint(-10, 10), random.randint(-10, 10)]
- print(2)
- ball = Ball(ball_image, pos, speed)
- print(1)
- balls.append(ball)
- clock = pygame.time.Clock()
- while running:
- for event in pygame.event.get():
- if event.type == QUIT:
- sys.exit()
- screen.blit(background, (0, 0))
- for each in balls:
- screen.blit(each.image, each.rect)
- pygame.display.flip()
- clock.tick(30)
- if __name__ == "__main__":
- main()
复制代码
以上是我的代码,求大神康康孩子吧 |
|