+ 1

Player' object has no attribute 'x' 🥵🥵🥵

from tkinter import * window = Tk() Высота = window.winfo_screenheight() Ширина = window.winfo_screenwidth() window.geometry(f"{Высота}x{Ширина}") canvas = Canvas(window, width = 1000, height = 1000) class Player: def __unit__(self): self.v = 0 self.x = 200 self.y = 200 self.photo = PhotoImage(file = r"Player.png") def up(): self.v = 10 player1 = Player() def game(): canvas.create_image(player1.x, player1.y, image=player1.photo) player1.y += player1.v window.after(10, game) game() window.mainloop()

14th Feb 2023, 3:13 PM
python
1 Odpowiedź
+ 2
__unit__() # X wrong __init__() # √ correct
14th Feb 2023, 3:18 PM
Jayakrishna 🇮🇳