Turtle Graphics

Have you created any projects using the Tkinter Turtle?

Page 1 of 1

6 Replies - 15239 Views - Last Post: 06 September 2008 - 12:43 PM Rate Topic: -----

#1 dave_6_10  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 19-March 08

Turtle Graphics

Post icon  Posted 28 August 2008 - 03:48 PM

  goto(0,0)
  down()
  goto(25,0)
  goto(25,25)
  goto(0,25)
  goto(0,0)
  up()



Check this turtle out its a pretty basic that has some complex coolness.
Is This A Good Question/Topic? 0
  • +

Replies To: Turtle Graphics

#2 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: Turtle Graphics

Posted 28 August 2008 - 06:15 PM

You, um, made a square. :P

On of the most impresive learning tools I've seen in a long time is the Turtle Art program that comes with the OLPC machine. It uses interlocking code elements to show the student the basics of procedural programming.

I taught Terrapin Logo to kids grades second through fifth, many many years ago. The second graders started with squares. ;)
Was This Post Helpful? 1
  • +
  • -

#3 dave_6_10  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 19-March 08

Re: Turtle Graphics

Posted 31 August 2008 - 02:49 PM

well, its hard to post something overly complex considering I only have an hour per each library computer session, I will try to post something a little more "advanced" tomorrow ")
Was This Post Helpful? 0
  • +
  • -

#4 dave_6_10  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 19-March 08

Re: Turtle Graphics

Posted 02 September 2008 - 03:24 PM

def drawcube():
	# A cube to give the illusion of 3 dimensions.
	cubex=-15
	cubey=-15
	plus8=+160
	minus4=-80
	minus5=-100
	color("yellow")
	goto(cubex,cubey)
	down()
	goto(cubex,cubey+plus8)
	goto(cubex+plus8,cubey+plus8)
	goto(cubex+plus8,cubey)
	goto(cubex+plus8+minus4,cubey+minus5)
	goto(cubex+minus4,cubey+minus5)
	goto(cubex+minus4,cubey+plus8+minus5)
	goto(cubex+plus8+minus4,cubey+plus8+minus5)
	goto(cubex+plus8,cubey+plus8)
	goto(cubex,cubey+plus8)
	goto(cubex+minus4,cubey+plus8+minus5)
	goto(cubex+minus4,cubey+minus5)
	goto(cubex,cubey)
	goto(cubex,cubey+plus8)
	goto(cubex,cubey)
	goto(cubex+plus8,cubey)
	goto(cubex+plus8+minus4,cubey+minus5)
	goto(cubex+plus8+minus4,cubey+plus8+minus5)
	up()
	color("black")
	goto(cubex,cubey)
	down()
	goto(cubex,cubey+plus8)
	goto(cubex+plus8,cubey+plus8)
	goto(cubex+plus8,cubey)
	goto(cubex+plus8+minus4,cubey+minus5)
	goto(cubex+minus4,cubey+minus5)
	goto(cubex+minus4,cubey+plus8+minus5)
	goto(cubex+plus8+minus4,cubey+plus8+minus5)
	goto(cubex+plus8,cubey+plus8)
	goto(cubex,cubey+plus8)
	goto(cubex+minus4,cubey+plus8+minus5)
	goto(cubex+minus4,cubey+minus5)
	goto(cubex,cubey)
	goto(cubex,cubey+plus8)
	goto(cubex,cubey)
	goto(cubex+plus8,cubey)
	goto(cubex+plus8+minus4,cubey+minus5)
	goto(cubex+plus8+minus4,cubey+plus8+minus5)
	color("green")
	up()
	goto(cubex,cubey)
	down()
	goto(cubex,cubey+plus8)
	goto(cubex+plus8,cubey+plus8)
	goto(cubex+plus8,cubey)
	goto(cubex+plus8+minus4,cubey+minus5)
	goto(cubex+minus4,cubey+minus5)
	goto(cubex+minus4,cubey+plus8+minus5)
	goto(cubex+plus8+minus4,cubey+plus8+minus5)
	goto(cubex+plus8,cubey+plus8)
	goto(cubex,cubey+plus8)
	goto(cubex+minus4,cubey+plus8+minus5)
	goto(cubex+minus4,cubey+minus5)
	goto(cubex,cubey)
	goto(cubex,cubey+plus8)
	goto(cubex,cubey)
	goto(cubex+plus8,cubey)
	goto(cubex+plus8+minus4,cubey+minus5)
	goto(cubex+plus8+minus4,cubey+plus8+minus5)
	up()
	
	sleep(1)



okay instead of a square lets try a cube. :)

This one will be fun for your second graders also :)

def engine():
	reset()
	up()
	#the letter "E"
	goto(40,70)
	down()
	goto(0,70)
	goto(0,10)
	goto(40,10)
	up()
	goto(40,40)
	down()
	goto(0,40)
	up()
	#the letter "E" moved to show a motion of entire shape of (-20,-20)
	color("green")
	goto(40-20,70-20)
	down()
	goto(0-20,70-20)
	goto(0-20,10-20)
	goto(40-20,10-20)
	up()
	goto(40-20,40-20)
	down()
	goto(0-20,40-20)
	up()
	#the letter "E" moved to show a motion of entire shape of (-20,-20)
	color("red")
	goto(40-40,70-40)
	down()
	goto(0-40,70-40)
	goto(0-40,10-40)
	goto(40-40,10-40)
	up()
	goto(40-40,40-40)
	down()
	goto(0-40,40-40)
	up()
	#the letter "E" moved to show a motion of entire shape of (-20,-20)
	color("maroon")
	goto(40-60,70-60)
	down()
	goto(0-60,70-60)
	goto(0-60,10-60)
	goto(40-60,10-60)
	up()
	goto(40-60,40-60)
	down()
	goto(0-60,40-60)
	up()
	#the letter "E" moved to show a motion of entire shape of (-20,-20)
	color("pink")
	goto(40-80,70-80)
	down()
	goto(0-80,70-80)
	goto(0-80,10-80)
	goto(40-80,10-80)
	up()
	goto(40-80,40-80)
	down()
	goto(0-80,40-80)
	
	sleep(2),
	

if __name__ == '__main__':

	engine()
	sleep(3)
	done()



#Bicyclewheel
	#As the rain falls I am thankful for the cooling aire.
	#The heat has been steadfast and tonight it breaks!
	speed("fastest")
	x=0
	y=0
	up()
	goto(x,y-50)
	down()
	fill(1)
	color("black")
	circle(50)
	fill(0)
	up()
	goto(x,y-40)
	down()
	color("white")
	fill(1)
	circle(40)
	fill(0)
	color("black")
	up()
	goto(x,y)
	down()
	goto(x+40,y)
	goto(x,y)
	goto(x-40,y)
	goto(x,y)
	goto(x,y+40)
	goto(x,y-40)
	goto(x,y)
	setheading(45)
	forward(40)
	backward(80)
	goto(x,y)
	setheading(135)
	forward(40)
	backward(80)
	
	up()
	sleep(1)
	reset()
	write("created by dave_6_10")


And this one is especially useful for the exploratory purpose of learning to use turtle graphix
Was This Post Helpful? 0
  • +
  • -

#5 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: Turtle Graphics

Posted 02 September 2008 - 05:35 PM

Nice. For turtles, I like the classics:
from turtle import *

speed("fastest")
color("blue")
down()
for i in range(36):
	for j in range(10):
		forward(50)
		right(36)
	right(10)
up()



Also, I'm not fond of goto. It breaks the metaphor of a turtle taking some steps, dipping it's tail in paint, picking it up and putting it down. What does a turtle know of x and y? It only need know move and turn. Here's a cube without goto, by way of example:
def DrawCube(size, zsize, boxColor, sideColor):
	def square(size):
		down()
		for step in range(4):
			forward(size)
			right(90)
		up()

	def side(size, zsize):
		down()
		right(45)
		forward(zsize)
		left(45)
		forward(size)
		left(135)
		forward(zsize)
		left(45)
		forward(size)
		right(180)
		up()
		
	color(boxColor)
	square(size)
	color(sideColor)
	side(size, zsize)
	right(90)
	forward(size)
	left(90)
	side(size, zsize)
	left(90)
	forward(size)
	right(90)
	color(boxColor)
	square(size)
	up()
	right(45)
	forward(zsize)
	left(45)
	down()
	square(size)
	up()

DrawCube(150, 100, "black", "blue")


Was This Post Helpful? 0
  • +
  • -

#6 dave_6_10  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 19-March 08

Re: Turtle Graphics

Posted 05 September 2008 - 10:51 AM

Hey since your so Wizardours and full of knowledge in the python language maybe you could help me with fitting this whole character sheet into one window :P

DnD Charactersheet:
 
__author_="Dave_6_10"
__title_="Dungeons and Dragons character sheet"
__version_="1.0"


def page1():
	print("""
____________________________   _______________________________	Dungeons
CHARACTER NAME				 PLAYER						   ==>-&-----
____________________________   ___________ ___________ _________  Dragons
CLASS AND LEVEL				RACE		AUGMENT	 DEITY
_______  _______  ______  _______ _______ _________ _________ _________
size	 age	  gender  height  weight  eyes	  hair	  skin

Ability Name|Ability	Ability   Temporary   Temporary
			| score   | modifier   score	  modifier
  Strength  |_________|_________|___________|__________|
  Dexterity |_________|_________|___________|__________|
Constitution|_________|_________|___________|__________|
Intelligence|_________|_________|___________|__________|
   Wisdom   |_________|_________|___________|__________|
  Charisma  |_________|_________|___________|__________|
 Hit Points |_________|_________|___________|__________|
 
 """)
	stop=int(input("enter 1 to go to next page"))
	page=stop
	if page == 1: exec('page2()')

def page2():
	print("""
						--------------   ------------------------------
_______________________|  FEATS	   | |		 SPELLS			  |
Campaign			   |--------------| |---Domain/Specialty School---|
|----------------------|______________| |_____________________________|
|______________________|______________| |_____________________________|
Exp Points			 |			  | |o:___________________________|
					   |______________| |							 |
		GEAR		   |			  | |_____________________________|
""")
	stop=int(input("enter 1 to go to next page"))
	page=stop
	if page == 1: exec('page2()')

if __name__ == '__main__':
		  page1()

Was This Post Helpful? 0
  • +
  • -

#7 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5846
  • View blog
  • Posts: 12,705
  • Joined: 16-October 07

Re: Turtle Graphics

Posted 06 September 2008 - 12:43 PM

Define window. The code you've shown merely dumps text to a screen. If it's a terminal window, define more rows. You're limited by your environment, not the language.

Design it in a word processor, dump it to a PDF. Make an image and display the image. If you want to interact with the user, then it becomes more interesting.

Personally, I'd use HTML. It's ubiquitous, understood by most users, easy to enter data into and print from.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1