"Etch a Sketch" Help

Discussion in 'Programming General' started by asdasd123, Mar 29, 2012.

"Etch a Sketch" Help
  1. Unread #1 - Mar 29, 2012 at 5:12 AM
  2. asdasd123
    Joined:
    Feb 2, 2012
    Posts:
    417
    Referrals:
    0
    Sythe Gold:
    0

    asdasd123 Forum Addict

    "Etch a Sketch" Help

    If you don't know what it is
    http://i.telegraph.co.uk/multimedia/archive/01677/dog_1677568i.jpg

    Code:
    #Setup document (800x600)
    #Create the drawing surface -
    from turtle import *
    
    
    def move_up():
        setheading(90)
        forward(5)
        
    def move_down():
        setheading(270)
        forward(5)
        
    def move_left():
        setheading(180)
        forward(5)
        
    def move_right():
        setheading(0)
        forward(5)
    
    def clear_screen():
        clear()
        bgcolor("grey")
        st()
    
    
    title("eTCH!")
    speed(0)
    bgcolor("grey")
    setup(width=800, height=600)
    penup()
    pensize(3)
    pendown()
    onkey(move_up, 'Up')
    onkey(move_down, 'Down')
    onkey(move_left, 'Left')
    onkey(move_right, 'Right')
    onkey(clear_screen, 'c')
    listen()
    exitonclick()
    What I want to know is how do I make it stop at the borders of the screen?
     
  3. Unread #2 - Mar 29, 2012 at 7:40 AM
  4. novice
    Joined:
    Jun 21, 2008
    Posts:
    111
    Referrals:
    0
    Sythe Gold:
    0

    novice Active Member

    "Etch a Sketch" Help

    Code:
    def move_up():
    	if(ycor()>0):
    		setheading(90)
    		forward(5)
        
    def move_down():
    	if(ycor()<600):
    		setheading(270)
    		forward(5)
        
    def move_left():
    	if(xcor()>0):
    		setheading(180)
    		forward(5)
        
    def move_right():
    	if(xcor()<800):
    		setheading(0)
    		forward(5)
    
     
< Runescape Botters | C# Runescape Highscore Lookup >

Users viewing this thread
1 guest


 
 
Adblock breaks this site