I'm creating 2D game and when i am trying to add more than one wall they doesn't appear on canvas.
import tkinter
root = tkinter.Tk()
canvas = tkinter.Canvas(root)
canvas.pack()
class wall:
point1 = []
point2 = []
def __init__(self, canvas, x1, y1, x2, y2):
self.canvas = canvas
self.point1.append(x1)
self.point1.append(y1)
self.point2.append(x2)
self.point2.append(y2)
def draw(self):
self.canvas.create_line(self.point1[0], self.point1[1], self.point2[0], self.point2[1], width = 2)
walls = []
walls.append(wall(canvas, 90, 90, 100, 200))
walls.append(wall(canvas, 90, 90, 300, 100))
def update():
for wall in walls:
wall.draw()
root.after(int(1000/60), update)
root.after(int(1000/60), update)
root.mainloop()
If I add them manually they are drawing both.
canvas.create_line(90, 90, 100, 200, width = 2)
canvas.create_line(90, 90, 300, 100, width = 2)
self.x1,self.y1,self.x2,self.y2?