0

我正在尝试制作一个游戏,你必须避免物体从天上掉下来。我是一名初学者(14 岁),所以我犯了很多错误。我解决了所有问题(对于这个程序),但我不知道如何解决这个问题。错误在标题中。谢谢你。完整代码:

from livewires import games, color
import random

games.init(screen_width = 1280, screen_height = 720, fps = 150)

class Covjek(games.Sprite):
    def update(self):
        if self.overlapping_sprites:
            self.destroy()
            games.screen.quit()
        self.x = games.mouse.x
        if self.left < 0:
            self.left = 0
        if self.right > games.screen.width:
            self.right = games.screen.width

class Budala(games.Sprite):
    odds_change = 200
    def __init__(self, y = 50, speed = 2, odds_change = 200):
        super(Budala, self).__init__(image = games.load_image("nigga.jpg"),
                                 x = games.screen.width/2,
                                 y = y,
                                 dx = speed)
        self.odds_change = odds_change
        self.time = 200
        self.score = 0
        games.screen.add(self.score)
        self.text = games.Text(size = 50, x = games.screen.width - 20,
                               y = games.screen.height - 20, value = self.score,
                               color = color.red)    

    def update(self):
        if self.right > games.screen.width:
            self.dx = -self.dx
        if self.left < 0:
            self.dx = -self.dx
        odd = random.randrange(Budala.odds_change + 1)
        if odd == Budala.odds_change:
            self.dx = -self.dx
        self.time -= 1
        if self.time == 0:
            games.screen.add(Meteor(image = games.load_image("smeg.jpg"),
                                     x = self.x,
                                     y = self.y,
                                     dy = 2))
            self.time = 200



class Meteor (games.Sprite):

def __init__(self, chef, x = 640, y = 670,image = games.load_image("kamijonhehe.jpg")):
    super(Meteor, self).__init__(x = x,
                                  image = image,
                                  y = y,
                                  chef = budala)
    self.chef = chef
def update(self):
    if self.bottom > games.screen.height:
        self.destroy()
        self.chef.score += 1

games.screen.background = games.load_image("boaj.jpg")
budala = Budala()
games.screen.add(budala)                                      
games.screen.add(Covjek(image = games.load_image("kamijonhehe.jpg"),
                        x = games.screen.width/2,
                        bottom = 720))
games.screen.event_grab = True
games.mouse.is_visible = False
games.music.load("smukwed.mp3")
games.music.play()
games.music.play()
games.screen.mainloop()

完整的错误代码:

Traceback (most recent call last):
  File "C:\Users\nikol\Desktop\Python\prugrami limun\izbegavalje.py", line 
75, in <module>
    games.screen.mainloop()
  File "C:\Python31\lib\site-packages\livewires\games.py", line 303, in 
mainloop
    object._erase()
AttributeError: 'int' object has no attribute '_erase'

PS有些单词是塞尔维亚语,所以很难记住。使用 Python 3.1、pygame 1.9.1 和 livewires。Line games.screen.mainloop() 抛出错误。

4

0 回答 0