Ejemplo n.º 1
0
def art():
    window = turtle.screen()
    window.bgcolor("Green")

    raju = turtle.Turtle()
    raju.color("red")
    for i in range(1, 5):
        draw(raju)
        raju.right(10)
    window.exitonclick()
Ejemplo n.º 2
0
Archivo: ps17.py Proyecto: Gritide/Py
def main():
    dod = turtle.screen()
    ede = turtle.Turtle()
    for i in range(5):
        angle = int(input(":Enter a number:"))
        tur.left(angle)
        tur.forward(100)
        dod.exitinclick(1)
        if_name_ == '_mgin'
        main(0)
Ejemplo n.º 3
0
def art():
    window = turtle.screen()
    window.bgcolor("Green")

    raju = turtle.Turtle()
    raju.color("red")
    for i in range(1,5):
        draw(raju)
        raju.right(10)
    window.exitonclick()
def jumping_turtle(velocity, theta, time):
    import turtle

    alex = turtle.Turtle()
    sc = turtle.screen()

    alex.speed(10)
    for time in range(20):
        grace.goto(x_coordinate(velocity, random.randint(0, 360), i),
                   y_coordinate(velocity, theta, i, -10))
Ejemplo n.º 5
0
def draw_triangle():
    window=turtle.screen()
    window=bgcolor("yellow")
    a=turtle.Turtle()
    a.right(60)
    a.forward(60)
    a.right(60)
    a.forward(60)
    a.right(60)
    a.forward(60)
    window.exitonclick()
Ejemplo n.º 6
0
def draw_art():
    window = turtle.screen()
    window.bgcolor("black")
    #Turtle Brad
    brad = turtle.Turtle()
    brad.shape("turtle")
    brad.color("yellow")
    brad.speed(4)
    brad.pensize(2)
    for i in range(1,37):
        draw_square(brad)
        brad.right(10)
    #Turtle Angie

    window.exitonclick()
Ejemplo n.º 7
0
def draw_square():
    window = turtle.screen()
    window.bgcolor("red")

    P = turtle.Turtle()
    P.color("yellow")
    P.shape("turtle")
    P.speed(2)
    P.forward(100)
    P.right(90)
    P.forward(100)
    P.right(90)
    P.forward(100)
    P.right(90)
    P.forward(100)
    P.right(90)
Ejemplo n.º 8
0
def draw_art():
	windows = turtle.screen()
	window.bgcolor("red")
	# create the turtle brad - draw squares
	brad = turtle.turtle()
	brad.shape("turtle")
	brad.color("yellow")
	brad.speed.(2)
	for i in range(1,37):
		draw_square(brad)
		brad.right(10)
	# create the turtle angie - drawa circles
	angie.turtle.Turtle()
	angie.shape("arrove")
	angie.color("blue")
	angie.circle(100)

	window.exitonclick()
Ejemplo n.º 9
0
def showmontepi(numdarts):
    scn = turtle.screen()
    t = turtle.turtle()

    scn.setworldcoordinates(-2, -2, 2, 2)

    t.penup()
    t.goto(-1, 0)
    t.pendown()
    t.goto(1, 0)

    t.penup()
    t.goto(0, 1)
    t.pendown()
    t.goto(0, -1)

    inCircle = 0
    t.penup()

    for i in range(numDarts):
        x = random.random()
        y = random.random()

        distance = math.sqrt(x**2 + y**2)

        t.goto(x, y)

        if distance <= 1:
            inCircle = inCircle + 1
            t.color("blue")
        else:
            t.color("red")

        t.dot()

        pi = inCircle / numDarts * 4
        scn.exitonclick()
        return pi

    showMontePi(1000)

    t.pendown()
Ejemplo n.º 10
0
import turtle as t


def write_xy(x, y):
    t.goto(x, y)
    t.stamp()
    t.write("x:%d, y:%d" % (x, y))


def screen_clear(x, y):
    t.goto(x, y)
    t.clear()


t.setup(600, 600)
s = t.screen()
t.penup()
s.onscreenclick(write_xy, 1)
s.onscreenclick(screen_clear, 3)
s.listen()
Ejemplo n.º 11
0
# -*- coding: utf-8 -*-
"""
Created on Tue Aug  4 10:55:15 2020

@author: AE401
"""

import turtle

t = turtle.Turtle()
t.color('red')
canvas = turtle.screen()
canvas.title('w')
canvas.bgcolor('black')
t.forward(300)
t.right(90)
t.forward(250)
t.right(90)
t.forward(600)
t.right(90)
t.forward(520)
t.right(90)
t.forward(520)
t.right(90)
Ejemplo n.º 12
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 25 21:10:22 2019

@author: alphatec1
"""
#burada araç gittiği yolun haritasını çıkaracak, tüm yolu tamamladıktan sonra yön bulma algoritmasıyla; park etme yerine gidecek.
import os
from turtle import Turtle, screen
from collections import deque, namedtuple
wn = screen()

t = Turtle()
t1 = Turtle()

nSayi = 0
xJetson = 0
yJetson = 0
angle = 0
#şartlar eklenecek.
t.penup()
t.setx(xJetson)
t.sety(yJetson)
t.pendown()

t1.penup()
t1.setx(xJetson)
t1.sety(10 + yJetson)
t1.pendown()
  
  tloc += 50

# TODO: move turtles across and down screen, stopping for collisions

steps = 0
   while steps < 50:
    steps = steps + 1

    for n_turtle in horiz_turtle:
        for v_turtle in vert_turtles:
            
            h_turtle.forward(10)
            v_turtle.forward(10)

            x1 = h_turtle.xcor()
            x2 = v_turtle.xcor()

            y1 = h_turtle.ycor()
            y2 = v_turtle.ycor()

            if abs(x1 - x2) < 20 and abs(y1 - y2) > 20:
                h_turtle.fillcolor("gray")
                v_turtle.fillcolor("gray")

                horiz_turtles.remove(h_turtle)
                vert_turtles.remove(v_turtle)


wn=trtl.screen()
wn.mainloop()
Ejemplo n.º 14
0
import turtle
import random
import time
delay=0.1
score=0
hightestscore=0

#snakebodies
bodies=[]
#getting a screen l canvas
s=turtle.screen ()
s.title("snake Game")
s.bgcolor("gray")
s.setup (width=600,hight=600)
#creat snake head
head=turtle.Turtle()
head.speed(0)
head.shape("square")
head.color("white")
head.fillcolor("blue")
head.penup()
head.goto(0,0)
head.direction="stop"

#snake food
food=turtle.Turtle()
food.speed(0)
food.shape("square")
food.color("yellow")
food.fillcolor("green")
food.penup()
Ejemplo n.º 15
0
def draw_square():
    window = turtle.screen()
    window.bgcolor("red")
    brad = turtle.Turtle()
    brad.forward(100)
    window.exitonclick()
Ejemplo n.º 16
0
import turtle
window = turtle.screen()
window.bgcolor("lighblack")
painter= turtle.turtle()
painter.fillcolor('yellow')
painter.pencolor('blue')
painter.pensize(3)
def drawsq(t,s):
    for i n range(4):
        t.forward(s)
        t.left(90)
for i in range ( 1,180 ):
    painter.left(18)
    drawsq(painter,200)
Ejemplo n.º 17
0
#Aula 6  Exemplos
#Usando Turtle
import turtle
jn = turtle.screen(
)  #definindo uma variavel da função Screen. Vai abrir uma tartaruga em uma tela branca. Ela tem "metodos" (andar, voltar, direita)
joana = turtle.Turtle(
)  # damos o nome a nossa tartaruga (que na vdd é uma seta)
joana.forward(50)  #move a tartaruga pra frente 50
joana.left(90)  #move gira 90 graus
joana.forward(50)  #frente de novo
#------
jn.bgcolor(
    "lightgreen")  #esse metodo muda a cor da janela ( a string é um argumento)
jn.title("Oláaaaa")  #muda o nome da janela

teca = turtle.Turtle(
)  #criamos uma nova tartaruga chamada Teca ( uma nova "instancia"/ objeto do tipo Turtle)
#VOLTAR DEPOIS
Ejemplo n.º 18
0
def draw_square():
    window = turtle.screen()
    window.bgcolor('blue')
import turtle  #allows us to use turtle library
wn = turtle.screen()  #creates a graphics window
alex = turtle.Turle()  #creates a turtle named alex
alex.forward(150)  #tell alex to move forwardby 150 units
alex.left(90)  #turn by 90 degrees
alex.forward(75)  #complete second side of a rectangle
Ejemplo n.º 20
0
import turtle as t 
from random import randint

def random_color():
    r = randint(0, 255)
    g = randint(0,  255)
    b = randint(0, 255)
    rgb = (r, g, b)
    return rgb

tim = t.Turtle()
tim.pensize(5)
t.colormode(255)
t.speed(9)

def draw_spirograph(size_of_gap):
    for _ in range (int(360/size_of_gap)):
        tim.color(random_color())
        tim.circle(100)
        tim.setheading(tim.heading() + size_of_gap )
        print(tim.heading())

draw_spirograph(10)

screen = t.screen()
screen.exitonclick()
Ejemplo n.º 21
0
 def main():
     t = turtle.Turtle()
     t.speed(0)
     draw_two_circles(t)
     turtle.screen().mainloop()
Ejemplo n.º 22
0
import turtle
#set up screen

win = turtle.screen()
win.title("Watariamba nyoka game")
win.bgcolor("blue")
win.setup(width=600, height=600)
win.tracer(0)
Ejemplo n.º 23
0
import turtle as t
playerAscore=0
playerAscore=0

window=t.screen()
window.title("Pong Game")
window.bgcolor("red")
window.setup(width=800,height=600)
window.tracer(0)

#creating left paddle
leftpaddle=t.Turtle()
leftpaddle.speed(0)
leftpaddle.shape("square")
leftpaddle.color("white")
leftpaddle.shapesize(stretch_wid=5,stretch_len=1)
leftpaddle.penup()
leftpaddle.goto(-350,0)

#creating right paddle
rightpaddle=t.Turtle()
rightpaddle.speed(0)
rightpaddle.shape("square")
rightpaddle.color("white")
rightpaddle.shapesize(stretch_wid=5,stretch_len=1)
rightpaddle.penup()
rightpaddle.goto(350,0)


#creating ball
ball=t.Turtle()
Ejemplo n.º 24
0
import turtle

#just a little prcatise
turtle.screen()
for i in range(0, 5):
    turtle.forward(100)
    turtle.right(72)

turtle.exitonclick()
Ejemplo n.º 25
0
import turtle
#import time
a = turtle.Turtle()

screen = turtle.screen(200, 200)
screen.title('turtle')
screen.bgcolor('lightblue')

a.pensize(5)
a.color('green')
a.shape('turtle')
a.forward(100)

a.done
import turtle
loadWindow=turtle.screen()
turtle.speed(2)

for i in range:
    turtle.circle(5*i)
    turtle.circle(-5*i)
    turtle.left(i)
turtle.exitonclick()
Ejemplo n.º 27
0
import turtle  # allows to use turtle libray
wn = turtle.screen()  # creat a graphical window
cutki = turtle.Turtle()  # creat a turtal name cutki
cutki.forward(150)
cutki.left(90)
cutki.forward(75)