I know I've got to record x_coords and y_coords in a list on each movement of a key. Than from this list I have
to compare them to max(x,y,-x,-y). Am I appending in the right place? and are my if statements just nonsense as they keep resulting in the same error?
setup(screen_size,screen_size)
screen_size = 800
cursor_increment = 20
max_x_coord = (screen_size - cursor_increment)
max_y_coord = (screen_size - cursor_increment)
x_coords = []
y_coords = []
def movement_tracker():
pos_x = xcor()
pos_y = ycor()
if pos_x() and pos_y() >- max_x_coord:
goto((xcor()-cursor_increment),(ycor()-cursor_increment))
if pos_x() and pos_y() <= -max_x_coord:
goto((xcor()+cursor_increment),(ycor()+cursor_increment))
#This works
def movement_functions():
def directions(key, angle, distance=20):
def onkey_movement_call():
setheading(angle)
fd(distance)
stamp_pos_x = xcor()
stamp_pos_y = ycor()
x_coords.append(y_coords)
y_coords.append(x_coords)
onkey(onkey_movement_call,key)
directions("Up", 90)
directions("Down", 270)
directions("Right", 360)
directions("Left", 180)
#It results in this error.
Traceback (most recent call last):
File "C:\Users\User\Desktop\solution_update.py", line 104, in <module>
movement_tracker()
File "C:\Users\User\Desktop\solution_update.py", line 29, in movement_tracker
if pos_x() and pos_y() <= -max_x_coord:
TypeError: 'int' object is not callable

New Topic/Question
Reply



MultiQuote






|