Python Forum
Dugeon maze game with turtle module. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Game Development (https://python-forum.io/forum-11.html)
+--- Thread: Dugeon maze game with turtle module. (/thread-33923.html)



Dugeon maze game with turtle module. - Newbie1114 - Jun-10-2021

Hi ,I am making a dungeon maze game with turtle module and there is an error and i don't know that what does that error mean and how to fix it.Please help me if you know.

I'm very very thank you if you spend sometime answering my question.
And if you what to know sth please call me
Here is my code:
import turtle
import math
import time

screen=turtle.Screen()
screen.bgcolor("blue")
screen.title("basic maze")
screen.setup(600,600)

class block(turtle.Turtle):
	def __init__(self):
		turtle.Turtle.__init__(self)
		self.shape("square")
		self.color("white")
		self.penup()
		self.speed(0)

class Mily(turtle.Turtle):
	def __init__(self):
		turtle.Turtle.__init__(self)
		self.shape("square")
		self.color("green")
		self.penup()
		self.speed(0)
		self.point=0

	def up(self):
		pre_1=me.xcor()
		pre_2= me.ycor()+24

		if (pre_1,pre_2)not in BLOCKS:
			self.goto(pre_1,pre_2)
	def down(self):
		pre_1=me.xcor()
		pre_2=me.ycor()-24

		if (pre_1,pre_2)not in BLOCKS:
			self.goto(pre_1,pre_2)
	def left(self):
		pre_1=me.xcor()-24
		pre_2=me.ycor()

		if (pre_1,pre_2)not in BLOCKS:
			self.goto(pre_1,pre_2)
	def right(self):
		pre_1=me.xcor()+24
		pre_2=me.ycor()

		if (pre_1,pre_2)not in BLOCKS:
			self.goto(pre_1,pre_2)

	def touch(self,different):
		A=self.xcor()-different.xcor()
		B=self.ycor()-different.ycor()
		range=math.sqrt((A**2)+(B**2))

		if range < 5:
			return True
		else:
			return False

class Point(turtle.Turtle):
	def __init__(self,x,y):
		turtle.Turtle.__init__(self)
		self.shape("square")
		self.color("yellow")
		self.penup()
		self.speed(0)
		self.point=100
		self.goto(x,y)


	def dis(self):
		self.goto(1000,1000)
		self.hideturtle()

class Point_1(turtle.Turtle):
	def __init__(self,x,y):
		turtle.Turtle.__init__(self)
		self.shape("square")
		self.color("yellow")
		self.penup()
		self.speed(0)
		self.point=100
		self.goto(x,y)


	def dis(self):
		self.goto(2000,200000)
		self.hideturtle()



Levels=[""]
level_1=[
"XXXXXXXXXXXXXXXXXXXX",
"X M   X    X  X    X",
"X     X    X  X    X",
"X  X  X    X  XXX  X",
"X  X  X    X  X    X",
"X  XXXXXX  X  X    X",
"X    X  X     X  XXX",
"X    X  X     X    X",
"X       X     XXX  X",
"X       X     X    X",
"X     XXXXX   X  XXX",
"X             X    X",
"X             X    X",
"XXXXXX        X    X",
"X    X    X        X",
"X  XXX    X     XXXX",
"X  X      XXX   X  X",
"X         X        X",
"X         X P   X  X",
"XXXXXXXXXXXXXXXXXXXX"

]

points=[]


Levels.append(level_1)

def build(level):
	for y in range(len(level)):
		for x in range(len(level[y])):
			Thing=level[y][x]

			screen_x=-288+(x*24)
			screen_y=288-(y*24)

			if Thing=="X":
				pen.goto(screen_x,screen_y)
				pen.stamp()

				BLOCKS.append((screen_x,screen_y))

			if Thing=="M":
				me.goto(screen_x,screen_y)

			if Thing=="P":
				points.append(Point(screen_x,screen_y))




me=Mily()
pen=block()

turtle.listen()
turtle.onkey(me.up,"Up")
turtle.onkey(me.down,"Down")
turtle.onkey(me.left,"Left")
turtle.onkey(me.right,"Right")


BLOCKS=[]

build(Levels[1])

screen.tracer(0)
limit=10
start=time.time()

while True:

	pass_time=time.time()-start
	if pass_time > limit:
		Point.dis()
		points.append(Point_1(-169,-96))
	

	for Point in points:
		if me.touch(Point):
			
			me.point+=Point.point
			print("YOUR POINT:{}".format(me.point))

			Point.dis()

			points.remove(Point)

			points.append(Point_1(-169,-96))


	for Point_1 in points:
		if me.touch(Point_1):
			me.point+=Point_1.point
			print("YOUR POINT:{}".format(me.point))

			Point_1.dis()
			
			points.remove(Point_1)

	screen.update()
And here is the error;
Error:
points.append(Point_1(-169,-96)) TypeError: 'Point' object is not callable [Finished in 7.3s with exit code 1]



RE: Dugeon maze game with turtle module. - Gribouillis - Jun-10-2021

At line 189/190, dont use Point_1 as a variable name, it shadows the name of the class Point_1. Choose another variable name in the for loop. Same thing at line 176 with Point. Don't reuse class names for something else.


RE: Dugeon maze game with turtle module. - Newbie1114 - Jun-11-2021

So i just have to change the name of the variable.And the variables have to different from the class name.
If that the way to fix it so it don't work.
I have tried to change many name but every time it still have the same error.Maybe I,m wrong
But very thank you for your time Gribouillis.


RE: Dugeon maze game with turtle module. - stephen645 - Jun-15-2021

points.append(Point_1(-169,-96))
TypeError: 'Point' object is not callable
[Finished in 7.3s with exit code 1]
did you correct it?
slope game