#wap to ball position control with the help of up,down,left,right key import SimpleGUICS2Pygame.simpleguics2pygame as simplegui import random width=300 height=300 position=[int(width/2),int(height/2)] rad=15 velocity=[0,0] def keydown(key): global velocity acc=1 if key==simplegui.KEY_MAP["down"]: velocity[1]+=acc elif key==simplegui.KEY_MAP["left"]: velocity[0]-=acc elif key==simplegui.KEY_MAP["right"]: velocity[0]+=acc elif key==simplegui.KEY_MAP["up"]: velocity[1]-=acc def draw(canvas): position[1]+=velocity[1] position[0]+=velocity[0] canvas.draw_circle(position,rad,3,"red","red") frame=simplegui.create_frame("key",400,400) frame.set_draw_handler(draw) frame.set_keydown_handler(keydown) frame.start()