casa con finestre
casa con finestre
Ho provato a far disegnare alla tartaruga una casa con porta e finestre. Il codice mi sembra molto, lungo...spero di trovare il modo di far fare la stessa cosa alla tartaruga con un codice più breve!
TO QUADRATO
REPEAT 4 [
forward 10
left 90
]
END
TO QUADRATO2
REPEAT 4 [
forward 10
left 90
forward 20
]
END
Home
clearscreen
repeat 4 [
forward 100
right 90
]
forward 100
right 60
forward 58
right 60
forward 58
right 60
penup
forward 20
right 90
forward 10
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
left 90
forward 20
left 90
forward 50
right 90
forward 5
pendown
QUADRATO
right 90
penup
forward 10
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
left 90
forward 20
left 90
forward 50
right 90
forward 5
pendown
QUADRATO
penup
right 90
forward 30
pendown
QUADRATO2
penup
forward 20
pendown
QUADRATO
TO QUADRATO
REPEAT 4 [
forward 10
left 90
]
END
TO QUADRATO2
REPEAT 4 [
forward 10
left 90
forward 20
]
END
Home
clearscreen
repeat 4 [
forward 100
right 90
]
forward 100
right 60
forward 58
right 60
forward 58
right 60
penup
forward 20
right 90
forward 10
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
left 90
forward 20
left 90
forward 50
right 90
forward 5
pendown
QUADRATO
right 90
penup
forward 10
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
forward 20
pendown
QUADRATO
penup
left 90
forward 20
left 90
forward 50
right 90
forward 5
pendown
QUADRATO
penup
right 90
forward 30
pendown
QUADRATO2
penup
forward 20
pendown
QUADRATO
Last edited by paolarosabelli on Thu Dec 29, 2016 12:18 pm; edited 1 time in total
paolarosabelli- Posts : 12
Join date : 2016-12-27
Re: casa con finestre
Dopo aver visto la quinta lezione e capito come si può costruire un codice per far disegnare alla tartaruga qualsiasi poligono regolare, ho accorciato il codice per disegnare la casa con le finestre in questo modo:
CLEARSCREEN
HOME
TO TRIANGOLO LL
REPEAT 3 [
FORWARD LL
RIGHT 120
]
END
TO QUADRATO LL
REPEAT 4 [ FORWARD LL
RIGHT 90
]
END
QUADRATO 100
FORWARD 100
RIGHT 30
TRIANGOLO 100
PENUP
HOME
FORWARD 80
RIGHT 90
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
HOME
FORWARD 60
RIGHT 90
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
HOME
PENUP
RIGHT 90
FORWARD 40
LEFT 90
PENDOWN
QUADRATO 30
CLEARSCREEN
HOME
TO TRIANGOLO LL
REPEAT 3 [
FORWARD LL
RIGHT 120
]
END
TO QUADRATO LL
REPEAT 4 [ FORWARD LL
RIGHT 90
]
END
QUADRATO 100
FORWARD 100
RIGHT 30
TRIANGOLO 100
PENUP
HOME
FORWARD 80
RIGHT 90
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
HOME
FORWARD 60
RIGHT 90
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
PENUP
FORWARD 15
PENDOWN
QUADRATO 10
HOME
PENUP
RIGHT 90
FORWARD 40
LEFT 90
PENDOWN
QUADRATO 30
paolarosabelli- Posts : 12
Join date : 2016-12-27
Re: casa con finestre
Ho trovato la soluzione per accorciare il codice dopo la visione della lezione dell'11 novembre, dove è stata posta la questione del cambio di posizione della tartaruga per riprodurre una nuova figura. E' possibile dare nuove istruzioni alla tartaruga creando una variabile. In questo caso, la creazione della variabile TO GAP (ma si potrebbe chiamare in qualunque modo) mi ha dato la possibilità di accorciare il codice per disegnare le finestre in ripetizione. Ho inserito anche l'istruzione HEADING (si trova nel manuale di Librelogo, come indicato dal Prof. Formiconi) che permette di cambiare l'orientamento della tartaruga.
Ecco il nuovo codice:
CLEARSCREEN
HOME
TO TRIANGOLO LL
REPEAT 3 [
FORWARD LL
RIGHT 120
]
END
TO QUADRATO LL
REPEAT 4 [ FORWARD LL
RIGHT 90
]
END
TO GAP SS DD
PENUP
HEADING DD
FORWARD SS
PENDOWN
END
QUADRATO 100
FORWARD 100
RIGHT 30
TRIANGOLO 100
GAP 1 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 60 9h
LEFT 90
PENUP
FORWARD 40
GAP 1 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 60 9h
left 90
PENUP
FORWARD 40
LEFT 90
FORWARD 35
PENDOWN
QUADRATO 20
Ecco il nuovo codice:
CLEARSCREEN
HOME
TO TRIANGOLO LL
REPEAT 3 [
FORWARD LL
RIGHT 120
]
END
TO QUADRATO LL
REPEAT 4 [ FORWARD LL
RIGHT 90
]
END
TO GAP SS DD
PENUP
HEADING DD
FORWARD SS
PENDOWN
END
QUADRATO 100
FORWARD 100
RIGHT 30
TRIANGOLO 100
GAP 1 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 60 9h
LEFT 90
PENUP
FORWARD 40
GAP 1 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 30 3h
QUADRATO 20
GAP 60 9h
left 90
PENUP
FORWARD 40
LEFT 90
FORWARD 35
PENDOWN
QUADRATO 20
paolarosabelli- Posts : 12
Join date : 2016-12-27
Permissions in this forum:
You cannot reply to topics in this forum
|
|