Python Forum
Dugeon maze game with turtle module.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dugeon maze game with turtle module.
#1
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]
Reply
#2
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.
Reply
#3
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.
Reply
#4
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python Maze Game by Christian Thompson ninedeadeyes 2 3,631 Apr-05-2019, 01:03 PM
Last Post: ninedeadeyes
  Creating Snake game in Turtle Shadower 1 6,585 Feb-11-2019, 07:00 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020