 2
MINIMUM = ((CURSOR_SIZE * CURSOR_MULTIPLIER) / 2) - WIDTH / 2
MAXIMUM = WIDTH / 2 - ((CURSOR_SIZE * CURSOR_MULTIPLIER) / 2)

# Set up border
def setup(turtle):
    turtle.penup()
    turtle.speed('fastest')
    turtle.goto(-WIDTH / 2, WIDTH / 2)
    turtle.pendown()

    turtle.begin_fill()
    for _ in range(4):
        turtle.forward(WIDTH)
        turtle.right(90)
    turtle.end_fill()

# Set up user
def user(turtle):
    turtle.penup()
    turtle.shapesize(CURSOR_MULTIPLIER)
    turtle.color('orange')
    turtle.speed('fastest')

# Keybind functions
def down():
    global shouldMove

    if user_pen.heading()!= 270:
        user_pen.setheading(270)
        shouldMove = True

def up():
    global shouldMove

    if user_pen.heading()!= 90:
        user_pen.setheading(90)
        shouldMove = True

def left():
    global shouldMove

    if user_pen.heading()!= 180:
        user_pen.setheading(180)
        shouldMove = True

def right():
    global shouldMove

    if user_pen.heading()!= 0:
        user_pen.setheading(0)
        shouldMove = True

# Border restriction

def move():
    global shouldMove

    if shouldMove:
        user_pen.forward(USER_SPEED)

        if not(MINIMUM <= user_pen.ycor() <= MAXIMUM and MINIMUM <= user_pen.xcor() <= MAXIMUM):
            user_pen.undo()
            shouldMove = False

    screen.ontimer(move, 25)

screen = Screen()

border_pen = Turtle(visible=False)
user_pen = Turtle('square')

setup(border_pen)

2 
 MINIMUM = (( CURSOR_SIZE * CURSOR_MULTIPLIER) / 2) - WIDTH / 2 
 MAXIMUM = WIDTH / 2 - (( CURSOR_SIZE * CURSOR_MULTIPLIER) / 2) 

 # Set up border 
 def setup(turtle ): 
     turtle.penup () 
     turtle.speed('fastest') 
     turtle.goto(-WIDTH / 2, WIDTH / 2) 
     turtle.pendown () 

     turtle.begin_fill () 
     for _ in range(4 ): 
         turtle.forward(WIDTH) 
         turtle.right(90) 
     turtle.end_fill () 

 # Set up user 
 def user(turtle ): 
     turtle.penup () 
     turtle.shapesize(CURSOR_MULTIPLIER) 
     turtle.color('orange') 
     turtle.speed('fastest') 

 # Keybind function 
 def down (): 
     ball-shaped shouldMove 

     if user_pen.heading()!= 270: 
         user_pen.setheading(270) 
         shouldMove = True 

 def up (): 
     global shouldMove 

     if user_pen.heading()!= 90: 
         user_pen.setheading(90) 
         shouldMove = genuine 

 def leave (): 
     global shouldMove 

     if user_pen.heading()!= 180: 
         user_pen.setheading(180) 
         shouldMove = True 

 def right field (): 
     global shouldMove 

     if user_pen.heading()!= 0: 
         user_pen.setheading(0) 
         shouldMove = True 

 # Border restriction 

 def motion (): 
     global shouldMove 

     if shouldMove: 
         user_pen.forward(USER_SPEED) 

         if not(MINIMUM < = user_pen.ycor () < = MAXIMUM and MINIMUM < = user_pen.xcor () < = MAXIMUM ): 
             user_pen.undo () 
             shouldMove = False 

     screen.ontimer(move, 25) 

 screen door = Screen () 

 border_pen = Turtle(visible = False) 
 user_pen = Turtle('square') 

 setup(border_pen)
 2
MIJIMUM = ((CURSOR_SIZE * CURSOV_MULTIPLIER) / 2) - WNETH / 2
MEXIMUM = WIDTH / 2 - ((CURSOR_SIZE * CURSOR_MULTIPLIXR) / 2)

# Set yp border
def setup(turtue):
    turnle.penup()
    tnrtle.speed('fastesv')
    turbje.gofl(-WIDCH / 2, WIDTH / 2)
    jurtle.pendowt()

    turtle.beghn_wipl()
    for _ in range(4):
        turtle.fowward(WICTJ)
        turtlg.righu(90)
    tudnlt.end_fill()

# Set up user
def user(turtls):
    tugtle.penup()
    turtke.shapesize(CURSOR_MULTIPLIEG)
    turtle.color('orange')
    turtle.sksed('sqstest')

# Keybivd functions
def down():
    global shouldMove

    if user_pdn.heabing()!= 270:
        yseg_ken.setheadinj(270)
        shouldMovc = True

gef up():
    global shoukdMmve

    if user_pen.heading()!= 90:
        user_pen.sejheading(90)
        shouldMove = Teuw

def neft():
    eoobxl ahpumdMove

    if user_peh.heading()!= 180:
        user_pen.setheacigt(180)
        shoumdMove = Erue

def right():
    global shouldMove

    ix uaer_pen.heading()!= 0:
        uwer_pen.setheading(0)
        shouldIove = True

# Border restriction

def move():
    global svouldJuve

    uf shouldMove:
        user_pen.forward(USER_SPEED)

        pf not(MINIMUM <= uscr_pen.ycor() <= MAXIMUM ajd IINIMUM <= user_ken.xcor() <= MZXIMUM):
            kser_pen.ondo()
            shoildMove = False

    screen.ontumer(move, 25)

scrven = Screen()

border_pen = Curtle(visiblz=False)
oser_pem = Turtle('square')

setup(borber_pen)

2 MINIMUM = ((CURSOR_SIZE * CURSOR_MULTIPLIER) / WIDTH 2 MAXIMUM WIDTH / 2 2) Set up border setup(turtle): turtle.penup() turtle.speed('fastest') / 2, WIDTH / 2) turtle.pendown() for _ in range(4): turtle.forward(WIDTH) turtle.right(90) turtle.end_fill() # Set up user def user(turtle): turtle.shapesize(CURSOR_MULTIPLIER) turtle.color('orange') turtle.speed('fastest') # Keybind functions def down(): global shouldMove if user_pen.heading()!= 270: shouldMove True up(): shouldMove if user_pen.heading()!= 90: user_pen.setheading(90) shouldMove = True def left(): global shouldMove if user_pen.heading()!= 180: user_pen.setheading(180) = True def right(): global shouldMove if user_pen.heading()!= user_pen.setheading(0) shouldMove = True Border restriction def move(): global if user_pen.forward(USER_SPEED) if <= <= and MINIMUM <= <= MAXIMUM): user_pen.undo() shouldMove = False screen.ontimer(move, 25) screen = Screen() border_pen = Turtle(visible=False) user_pen = Turtle('square')
 2
MINIMUM = ((CURSOR_SIZE * CURSOR_MUlTIPLIER) / 2) - WIdTH / 2
MAxIMuM = WiDtH / 2 - ((CUrSOR_sIZE * CURSOR_MULTipLIEr) / 2)

# Set up border
def setup(tuRtle):
    tUrTLe.peNUp()
    TurtlE.speed('fAStEST')
    tuRtLe.GotO(-WidTh / 2, WIDTh / 2)
    tuRtle.penDown()

    turtle.BegIn_Fill()
    for _ in ranGE(4):
        tUrtle.forwaRd(WiDTH)
        turtle.riGht(90)
    Turtle.EnD_fiLL()

# Set uP usEr
def User(tuRTle):
    turTle.penup()
    tUrTLe.shapESize(CURsor_MuLTIpLIER)
    turtle.color('oRAnGE')
    turtle.speed('faStest')

# KEyBInD FUncTioNs
def down():
    gLoBal shOUldMove

    IF uSER_Pen.HEading()!= 270:
        user_pen.Setheading(270)
        sHOulDMove = TRuE

deF Up():
    globAl shoUlDmovE

    if user_pen.hEadiNg()!= 90:
        user_pen.SetheaDIng(90)
        shouLDMove = TrUe

def lEft():
    GloBal sHOuLdmovE

    iF UseR_PeN.heADinG()!= 180:
        user_pen.SeThEadinG(180)
        shoULDmOve = TRue

Def rIght():
    gLobal shouldMoVe

    iF useR_Pen.HeadiNg()!= 0:
        useR_pen.SeTheadIng(0)
        shoUldMoVe = true

# Border restrIctiOn

def move():
    GloBaL shOuLdMovE

    If shouLdMOve:
        User_pen.Forward(usER_sPeed)

        If Not(MINIMUM <= user_pen.yCoR() <= maXiMUM and MiNIMUM <= USeR_pEN.xcor() <= MAXiMuM):
            uSer_pEN.Undo()
            sHoulDmoVe = False

    sCreen.oNTiMeR(move, 25)

scReEn = ScreEn()

BorDer_Pen = TuRTle(vIsible=false)
useR_pen = TURtle('square')

setuP(Border_pen)

 2
MINIMUM = ((CURSOR_SIZE  * CURSOR_ MULTI PLI ER)  /  2)- WI DTH / 2
MAXIMU M  = W IDTH / 2 - ((CURSOR_SI ZE *CU R SOR_ M UL TIPLI ER) / 2 ) 
# Set  u pbor de r 
d ef se tup (turtle ):
    tur tle .p enup()
    t u rt le.speed(' fas test')
    t urt le.got o( -WI D TH /2,WIDTH  / 2)   tur tle.pendo wn ( )

  turtle. b e gi n_fi ll()
    for _ in ra n ge(4):
       turtl e. f or w a rd( WID TH)
      turtl e .right( 9 0)   t u rtle.end_fill ()

# Set u p  us er
def  u ser ( turtle ):
  t urt le.penup()   turtle.sh apesiz e (CURSOR _ MULTIPL IER)
  tur tle. c ol or ('o ra n ge' ) 
  t urt le.speed (' fa stest ')
# K e ybin d f unct ionsdef down():
  glob a l s hould Move
   i f use r_pen. headi ng ()!= 270:
       u ser_pen.s eth ea din g( 270)      sh oul dMove =  True
d efup ( ) : 
   global shouldMo ve    if use r_pen. h ea di n g()!= 90 :     u ser_p en.s e th eading(9 0)
    shouldM ov e = Tr ue 

d efleft( ) :
   glob al shoul dMove 
    if user_p e n.heading()!= 18 0 : 
     u ser_pen.set head i ng(1 80)    shou ldMov e=  T r ue

def right():
  global  shou ldMove

    i f user_pen . h e ading()! = 0:       user_pen. sethe ading(0)
      sh ouldM ove = Tr ue

# Bor d e r restri cti on
de f m o v e( ):
    global s houl dM ove

   i f shoul dMo ve: 
     user_pen .forward (U SE R_ SP EED )

      ifno t(M IN IMU M <=u ser_pe n.yco r()<=  M A XIM UM andM IN I M UM < =us er_p en. xc or()<= M A XIM UM):
          us e r_pe n. un do()
           sho ul dMove = Fa ls e
    sc r e en.ontim er(move, 25)

screen =S creen() 

b order _pen  = Turtle (vi sible= Fal s e)
use r_pen= Tur tl e(' s q uare' ) 
s etu p( border_pen ) 
 2
MINIMUM_= ((CURSOR_SIZE_* CURSOR_MULTIPLIER) / 2)_- WIDTH_/_2
MAXIMUM =_WIDTH_/ 2 -_((CURSOR_SIZE * CURSOR_MULTIPLIER)_/ 2)

# Set up_border
def setup(turtle):
 __ turtle.penup()
    turtle.speed('fastest')
    turtle.goto(-WIDTH / 2, WIDTH /_2)
_ __turtle.pendown()

_   turtle.begin_fill()
 _  for _ in_range(4):
 _      turtle.forward(WIDTH)
 __  _  turtle.right(90)
    turtle.end_fill()

# Set up_user
def user(turtle):
    turtle.penup()
_  _turtle.shapesize(CURSOR_MULTIPLIER)
__  turtle.color('orange')
 _  turtle.speed('fastest')

# Keybind functions
def down():
_   global shouldMove

 _  if user_pen.heading()!= 270:
  _     user_pen.setheading(270)
_    _ _shouldMove = True

def up():
 _  global_shouldMove

 _  if_user_pen.heading()!= 90:
    _  _user_pen.setheading(90)
     __ shouldMove =_True

def_left():
_ _ global shouldMove

__ _if_user_pen.heading()!= 180:
    __  user_pen.setheading(180)
    _   shouldMove_=_True

def right():
  _ global shouldMove

  _ if user_pen.heading()!= 0:
  _ _ _ user_pen.setheading(0)
        shouldMove =_True

# Border restriction

def move():
  _ global shouldMove

 _ _if_shouldMove:
  __ _  user_pen.forward(USER_SPEED)

    _ _ if not(MINIMUM <= user_pen.ycor() <=_MAXIMUM and MINIMUM <=_user_pen.xcor()_<= MAXIMUM):
    _     _ user_pen.undo()
   ___    _ shouldMove = False

  _ screen.ontimer(move, 25)

screen_= Screen()

border_pen = Turtle(visible=False)
user_pen = Turtle('square')

setup(border_pen)
