keydown01.py

Created by vef03715

Created on February 01, 2021

626 Bytes


import time
from kandinsky import *
from turtle import *
from ion import *

def keydown01():
  reset()
  tf=True
  x,y=0,0
  while tf:
    draw_string(str(tf),100,90)
    draw_string(str(x),100,120)
    draw_string(str(y),100,150)
    goto(x,y)
    if keydown(KEY_LEFT):
      x-=1
      if x<-150:
        x=-150
    elif keydown(KEY_RIGHT):
      x+=1
      if x>150:
        x=150
    elif keydown(KEY_UP):
      y+=1
      if y>100:
        y=100
    elif keydown(KEY_DOWN):
      y-=1
      if y<-100:
        y=-100
    elif keydown(KEY_OK):
      tf=False
    else:
      tf=True
    time.sleep(0.005)