AttributeError: 'int' object has no attribute '_erase'

安稳与你 提交于 2020-01-06 09:06:51

问题


I am trying to make a game where you have to avoid objects falling from the sky. I am a beginner programmer (14yrs old) so I make a lot of mistakes. I solve all of them(for this program) but i dont know how to fix this one. The error is in title. Thank you. Full code:

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()

Full error code:

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'

P.S. some of the words are in Serbian so they could be hard to remember. Working in Python 3.1, pygame 1.9.1 and livewires. Line games.screen.mainloop() is throwing the error.

来源:https://stackoverflow.com/questions/54364148/attributeerror-int-object-has-no-attribute-erase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!