Exemplo n.º 1
0
    def draw_num(self, num, x_pos, y_pos, color="red"):

        # define drawing settings
        my_drawer = turtle.clone()
        my_drawer.ht()
        my_drawer.pu()
        my_drawer.speed(0)
        my_drawer.goto(x_pos, y_pos)

        # save number length
        num_len = len(str(num))

        # creates black dot to encircle number
        my_drawer.color("black")
        my_drawer.dot(50)

        # update font color and size, ensures writing is centered
        my_drawer.color(color)
        my_drawer.right(90)
        my_drawer.fd(10)
        my_drawer.right(90)
        my_drawer.fd(4 * num_len)

        # write the number passed inside of the black dot
        my_drawer.write(num, font=("arial", 12, "bold"))
Exemplo n.º 2
0
	def __init__(self, turtle, drawableObjects = []):
		self.drawableObjects = drawableObjects
		self.turtle = turtle.clone()

		# Turtle follower jest po to zeby podtrzymywac stary rysunek w momencie kiedy jest updatowany.
		# Nowy obrazek jest narysowany na stary, i stary usuwany
		self.turtleFollower = self.turtle.clone()
		self.height = self.turtle.getscreen().window_height()
		self.width = self.turtle.getscreen().window_width()
	def __init__(self,dx,dy,x,radius,y,color="grey"):
		Turtle.__init__(self)
		ast=turtle.clone()
		ast.shape("astroid.gif")
		ast.ht()
		self.penup()
		self.dx=dx
		self.dy=dy
		self.radius=radius
		self.goto(x,y)
		self.color("grey",color)
		self.shape("astroid.gif")
Exemplo n.º 4
0
import turtle
turtle.shape('turtle')
square = turtle.clone()
square.shape('square')
square.penup()
square.goto(100, 100)
square.pendown()
square.goto(100, 200)
square.goto(200, 200)
square.goto(200, 100)
square.goto(100, 100)

triangle = turtle.clone()
triangle.shape('turtle')
triangle.shape('triangle')

triangle.goto(-150, 150)
triangle.goto(300, 150)
triangle.goto(0, 0)
square.penup()
square.goto(100, -200)
    'apple.gif', 'compost.gif', 'Paper-Ball.gif', 'iphone.gif',
    'trash-bag.gif', 'plastic-bottles.gif', 'banana.gif'
]
good_trash = ['compost.gif', 'apple.gif', 'banana.gif']
bad_trash = [
    'plastic-bottles.gif', 'Paper-Ball.gif', 'trash-bag.gif', 'iphone.gif'
]
man = ["man.gif"]
trash_pos = []
trash_stamps = []

right_arrow = "Right"
left_arrow = "Left"
TIME_STEP = 500

borders = turtle.clone()
trash = turtle.clone()
man = turtle.clone()
man.showturtle()
turtle.register_shape("man.gif")
man.shape("man.gif")

MAN_SIZE = 20
trash_size = 20
man.goto(0, -399)
random_trash = 8

Screen = turtle.Screen()
Screen.register_shape("park.gif")
Screen.bgpic("park.gif")
LEFT = 2
Exemplo n.º 6
0
SIZE_Y = 500
turtle.setup(SIZE_X, SIZE_Y)  #Curious? It's the turtle window
#size.
turtle.penup()

SQUARE_SIZE = 20
START_LENGTH = 6

#Initialize lists
pos_list = []
stamp_list = []
food_pos = []
food_stamps = []

#Set up positions (x,y) of boxes that make up the snake
snake = turtle.clone()
snake.shape("circle")

#Hide the turtle object (it's an arrow - we don't need to see it)
turtle.hideturtle()

#Draw a snake at the start of the game with a for loop
#for loop should use range() and count up to the number of pieces
#in the snake (i.e. START_LENGTH)
for i in range(START_LENGTH + 1):
    x_pos = snake.pos()[0]  #Get x-position with snake.pos()[0]
    y_pos = snake.pos()[1]

    #Add SQUARE_SIZE to x_pos. Where does x_pos point to now?
    # You're RIGHT!
    x_pos += SQUARE_SIZE
Exemplo n.º 7
0
import turtle
turtle.shape('square')
turtle.shape('turtle')
finn = turtle.clone()
turtle.shape('square')
finn.goto(100, 100)
finn.goto(200, 100)
finn.goto(100, 0)
finn.goto(0, 0)
finn.goto(0, -100)
finn.goto(100, -100)
finn.goto(100, 0)
finn.goto(200, 100)
finn.right(90)
finn.goto(200, 0)
finn.goto(100, -100)
charlie = turtle.clone()
charlie.left(180)
charlie.penup()
charlie.forward(100)
charlie.shape('triangle')
charlie.pendown()
charlie.forward(100)
charlie.goto(-150, 75)
charlie.goto(-100, 0)
finn.penup()
finn.goto(100, 200)
finn.pendown()
id1 = finn.stamp()
finn.right(90)
finn.forward(100)
Exemplo n.º 8
0
SIZE_Y = 500
up_edge = 250
down_edge = -250
stamp_list = []
log_lispos = []
height = 20
length = 80
turtle.setup(SIZE_X, SIZE_Y)

turtle.hideturtle()
turtle.register_shape('pleasework.gif')

turtle.penup()

turtle.goto(300, 0)
log = turtle.clone()
log.shape('pleasework.gif')
newstamp = log.stamp()
stamp_list.append(newstamp)

log.goto(100, 0)
newstamp1 = log.stamp()
stamp_list.append(newstamp1)
log.goto(-100, 0)
stamp2 = log.stamp()
stamp_list.append(stamp2)
log.goto(-300, 0)
stamp3 = log.stamp()
stamp_list.append(stamp3)

(x, y) = log.pos()
Exemplo n.º 9
0
turtle.setup(1000, 1000)  #window size

#this inserts all pictures to the file
turtle.register_shape("gamecard.gif")
turtle.register_shape("compost.gif")
turtle.register_shape("airpollution.gif")
turtle.register_shape("plasticwaste.gif")
turtle.register_shape("globalwarming.gif")
turtle.register_shape("greenearth.gif")
turtle.register_shape("waterpollution1.gif")
turtle.register_shape("leaf.gif")
turtle.register_shape("poorturtle.gif")

turtle.shape("square")
#this sets pictures as turtles.
pic1 = turtle.clone()
pic1.shape("gamecard.gif")
pic2 = pic1.clone()
pic3 = pic1.clone()
pic4 = pic1.clone()
pic5 = pic1.clone()
pic6 = pic1.clone()
pic7 = pic1.clone()
pic8 = pic1.clone()
pic9 = pic1.clone()
pic10 = pic1.clone()
pic11 = pic1.clone()
pic12 = pic1.clone()
pic13 = pic1.clone()
pic14 = pic1.clone()
pic15 = pic1.clone()
Exemplo n.º 10
0
import turtle
import random
turtle.bgcolor("Linen")

##HEAD
print('choose your player')
print('adam, doudou, amir, kayvon, jan, alex')
chose = input()
chose.lower()

fatman = turtle.clone()
fatman.penup()
turtle.register_shape('adam.gif')
turtle.register_shape('dou_dou.gif')
turtle.register_shape('amir.gif')
turtle.register_shape('kayvon.gif')
turtle.register_shape('jan.gif')
turtle.register_shape('alex.gif')

turtle.register_shape('grapes.gif')
turtle.register_shape('orange.gif')
turtle.register_shape('watermelon.gif')
turtle.register_shape('banana.gif')
turtle.register_shape('apple.gif')
turtle.register_shape('cherries.gif')
food_types = [
    'grapes.gif', 'orange.gif', 'watermelon.gif', 'banana.gif', 'apple.gif',
    'cherries.gif'
]

if chose == 'adam':
Exemplo n.º 11
0
import turtle  # python needs this to use all the turtle functions
turtle.shape('turtle')  # changes the shape to a turtle
finn = turtle.clone()  # creates new turtle and saves it in finn
finn.shape('square')  # changes shape of 2nd turtle to square
finn.goto(0, 100)  # moves square to (x=100,y=100)
finn.goto(100, 100)
finn.goto(100, 0)
finn.goto(0, 0)
finn.penup()
finn = turtle.clone()
charlie = turtle.Turtle()
charlie.shape("triangle")

charlie.pendown()
charlie.goto(0, -100)
charlie.left(80)
charlie.goto(-100, 100)
charlie.left(90)
charlie.goto(100, 100)

turtle.shape('turtle')  # changes the shape to a turtle
finn = turtle.clone()  # creates new turtle and saves it in finn
finn.shape('square')  # changes shape of 2nd turtle to square
finn.goto(100, 100)  # move one of the two turtles
###
# you already wrote code for drawing squares and triangles in   # part 2
###
finn.goto(300, 300)
finn.stamp()
finn.goto(100, 100)
turtle.goto(400, -250)
turtle.goto(400, 250)
turtle.penup()
turtle.hideturtle()
turtle.goto(-400, -175)
turtle.showturtle()

t = 60
score = 0
SIZE_X = 800
SIZE_Y = 500
square_size = 30
food_size = 2
counter_timer = 0

plane = turtle.clone()
plane.shape('plane1.gif')
plane.goto(100, 100)

character = turtle.clone()
character.shape('final_proj_character.gif')
character_pos = (0, -450)
turtle.hideturtle()
turtle.penup()
character.penup()
turtle.goto(SIZE_X / 2 - 200, SIZE_Y / 2 - 30)

number_of_types = 4
food_pos = []
food_drop_pos = []
food_drop_stamp = []
Exemplo n.º 13
0
turtle.register_shape("questBorder.gif")
turtle.register_shape("waterCan.gif")
turtle.register_shape("gameoverv1.gif")
turtle.register_shape("plantx.gif")
turtle.register_shape("tree.gif")
turtle.register_shape("questBorder.gif")
turtle.register_shape("waterCan2.gif")
turtle.register_shape("deadPlant.gif")
turtle.register_shape("bg.gif")

#bg and text turtle

turtle.bgpic("bg.gif")
turtle.hideturtle()
a = turtle.clone()
a.hideturtle()

#title

titleTurtle = turtle.clone()
titleTurtle.hideturtle()
titleTurtle.penup()
titleTurtle.goto(0, 350)
titleTurtle.color('black')
titleTurtle.write("Answer And Win!",
                  move=True,
                  align="center",
                  font=('Comic Sans MS', 100, 'bold'))
titleTurtle.hideturtle()
Exemplo n.º 14
0
player2_score = 0

running = True
players.append(player1)
players.append(player2)

turtle.bgcolor("black")
spacing = 110
max_height = 3
min_height = -2
max_width = 4
min_width = -4
turtle.ht()
turtle.tracer(0)
turtle.setup(width=1500, height=1500, startx=None, starty=None)
numberer = turtle.clone()
numberer.ht()

player1_turtle = turtle.clone()
player1_turtle.ht()
player1_turtle.pu()
player1_turtle.goto(-600, 300)
player1_turtle.color("white")
player1_turtle.write(player1 + "'s score is " + str(player1_score),
                     font=("Papyrus", 20, "normal"))
player2_turtle = turtle.clone()
player2_turtle.ht()
player2_turtle.pu()
player2_turtle.goto(400, 300)
player2_turtle.color("white")
player2_turtle.write(player2 + "'s score is " + str(player2_score),
Exemplo n.º 15
0
turtle.colormode(255)
hideturtle()
tracer(0)
screen = turtle.Screen()
screen.bgpic('agario_background.gif')

number_of_balls = 8
minimum_ball_radius = 10
maximum_ball_radius = 40
minimum_ball_dx = -2
maximum_ball_dx = 2
minimum_ball_dy = -2
maximum_ball_dy = 2
balls = []
score = 0
scoress = turtle.clone()

for i in range(number_of_balls):

    screen_random1_x = int(-screen_width + maximum_ball_radius)
    screen_random2_x = int(screen_width - maximum_ball_radius)
    random_x = random.randint(screen_random1_x, screen_random2_x)

    screen_random1_y = int(-screen_height + maximum_ball_radius)
    screen_random2_y = int(screen_height - maximum_ball_radius)
    random_y = random.randint(screen_random1_y, screen_random2_y)

    random_dx = random.randint(minimum_ball_dx, maximum_ball_dx)
    while random_dx == 0:
        random_dx = random.randint(minimum_ball_dx, maximum_ball_dx)
    "green",
    "gray",
    "pink",
    "purple",
    "white",
    "GOLD",
]
turtle.hideturtle()
turtle.bgcolor("cyan")
SIZE_X = 1200

SIZE_Y = 600

turtle.setup(SIZE_X + 50, SIZE_Y + 50)

border = turtle.clone()
border.penup()
border.goto(SIZE_X / 2, -SIZE_Y / 2)
border.pendown()
border.goto(SIZE_X / 2, SIZE_Y / 2)
border.goto(-SIZE_X / 2, SIZE_Y / 2)
border.goto(-SIZE_X / 2, -SIZE_Y / 2)
border.goto(SIZE_X / 2, -SIZE_Y / 2)
border.hideturtle()

pygame.init()

pygame.mixer.music.load("music.wav")

pygame.mixer.music.play(-1)
pygame.mixer.music.set_volume(0.3)
Exemplo n.º 17
0
import turtle
import time
turtle.setup(1000,650)
turtle.penup()
turtle.speed(0)
turtle.register_shape("bottle.gif")
turtle.register_shape("background.gif")
background=turtle.clone()
background.shape("background.gif")
turtle.register_shape("plastic_bag.gif")
turtle.register_shape("paper.gif")
turtle.register_shape("trash_can_paper.gif")
turtle.register_shape("trash_can_plastic.gif")
turtle.register_shape("trash_can_nylon.gif")
background.stamp()
turtle.ht()

trash_can_paper=turtle.clone()
trash_can_paper.shape("trash_can_paper.gif")
trash_can_plastic=turtle.clone()
trash_can_plastic.shape("trash_can_plastic.gif")
trash_can_nylon=turtle.clone()
trash_can_nylon.shape("trash_can_nylon.gif")
plastic_bottle_1=turtle.clone()
plastic_bottle_2=turtle.clone()
plastic_bottle_3=turtle.clone()
plastic_bottle_4=turtle.clone()
turtle.hideturtle()
plastic_bottle_1.ht()
plastic_bottle_1.shape("bottle.gif")
plastic_bottle_2.ht()
Exemplo n.º 18
0
import turtle
import random
turtle.setup(800, 700)
turtle.tracer(1, 0)
score_frame1 = turtle.clone()
score_frame2 = turtle.clone()
score_frame1.shape("square")
score_frame2.color("orange")
score_frame1.color("orange")
score_frame2.shape("square")
score_frame1.goto(390, 340)
score_frame2.goto(370, 340)
score_frame3.goto(350, 340)
Exemplo n.º 19
0
"""
This is an example of what students might make out of the mini project.
"""

import turtle
import random

turtle.penup()
turtle.ht()
turtle.title("Python the Python Python")
#turtle.tracer()

# draw wall
wall = turtle.clone()
wall.shape("square")
wall.shapesize(20, 40, 20)
wall.pencolor("black")
wall.fillcolor("light blue")
wall.stamp()

# get the wall boundaries
wall_poly = wall.get_shapepoly()
x_points = []
y_points = []
for point in wall_poly:
    y_points.append(point[0])
    x_points.append(point[1])
MAX_X = max(x_points)
MIN_X = min(x_points)
MAX_Y = max(y_points)
Exemplo n.º 20
0
Created on Sun Jul  1 23:58:42 2018

Snake Mini project Starter Code
Name:
Date:
"""

import turtle
import random  #We'll need this later in the lab

colorList = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink']
count = 0

turtle.tracer(1, 0)  #This helps the turtle move more smoothly

textTurtle = turtle.clone()
textTurtle.hideturtle()
textTurtle.penup()
textTurtle.goto(0, 350)
textTurtle.write("Snake Game !!!", align="center", font=("times", 33, "bold"))

scoreTurtle = turtle.clone()
scoreTurtle.hideturtle()
scoreTurtle.penup()
scoreTurtle.goto(0, -350)

SIZE_X = 1000
SIZE_Y = 1000
turtle.setup(SIZE_X, SIZE_Y)  #Curious? It's the turtle window
#size.
turtle.penup()
Exemplo n.º 21
0
    global n
    if n == 0:
        print("blast off")
        return
    print(n)
    n = n - 1
    countdown_list.append(n)
    turtle.ontimer(countdown, 1000)


pos_list = []
stamp_list = []
trash_pos = []
trash_stamps = []

robot = turtle.clone()
screen = turtle.Screen()
image = "robot.gif"
screen.addshape(image)
robot.shape(image)

turtle.listen()
screen = turtle.Screen()
screen.setup(size_x, size_y)
screen.bgpic('ocen.gif')

turtle.hideturtle()

robot.direction = "Up"
UP_EDGE = 250
DOWN_EDGE = -250
Exemplo n.º 22
0
import turtle
#the square
turtle.shape('turtle')
turtle.goto(200, 0)
turtle.goto(100, 200)
turtle.goto(0, 0)
finn = turtle.clone()
finn.shape('square')
finn.goto(200, 0)
finn.goto(200, 200)
finn.goto(0, 200)
finn.goto(0, 0)
finn.goto(200, 0)
turtle.mainloop()

#the triangle
def snake_game():
    global turtle
    #size.
    turtle.penup()

    SQUARE_SIZE = 20

    #Initialize lists
    pos_list = []
    stamp_list = []
    food_pos = []
    food_stamps = []
    snake_color = [
        "red", "yellow", "green", "blue", "orange", "black", "purple",
        "light blue", "turquoise"
    ]
    turtle.color(random.choice(snake_color))

    #Set up positions (x,y) of boxes that make up the snake
    snake = turtle.clone()
    snake.shape("circle")

    #Hide the turtle object (it's an arrow - we don't need to see it)
    turtle.hideturtle()

    #Draw a snake at the start of the game with a for loop
    #in the snake (i.e. START_LENGTH)
    for i in range(START_LENGTH):
        x_pos = snake.pos()[0]  #Get x-position with snake.pos()[0]
        y_pos = snake.pos()[1]
        x_pos += SQUARE_SIZE

        my_pos = (x_pos, y_pos)  #Store position variables in a tuple
        snake.goto(x_pos, y_pos)
        #Move snake to new (x,y)
        #Append the new position tuple to pos_list
        pos_list.append(my_pos)
        #
        #    #Save the stamp ID! You'll need to erase it later. Then append
        #    # it to stamp_list.
        stamp = snake.stamp()
        stamp_list.append(stamp)

    ###############################################################
    #                    PART 2 -- READ INSTRUCTIONS!!
    ###############################################################
    UP_ARROW = "Up"  #Make sure you pay attention to upper and lower
    #case
    LEFT_ARROW = "Left"  #Pay attention to upper and lower case
    DOWN_ARROW = "Down"  #Pay attention to upper and lower case
    RIGHT_ARROW = "Right"  #Pay attention to upper and lower case
    #Update snake position after this many
    #milliseconds
    SPACEBAR = "space"  # Careful, it's not supposed to be capitalized!

    UP = 0
    DOWN = 1
    LEFT = 2
    RIGHT = 3
    UP_EDGE = 250
    DOWN_EDGE = -250
    RIGHT_EDGE = 400
    LEFT_EDGE = -400

    turtle.register_shape("trash.gif")
    food = turtle.clone()
    food.shape("trash.gif")

    def up():
        global direction  #snake direction is global (same everywhere)
        direction = UP  #Change direction to up

    def left():  #LEFT
        global direction
        direction = LEFT

    def right():  #right
        global direction
        direction = RIGHT

    def down():  #down
        global direction
        direction = DOWN

    turtle.onkeypress(up, "Up")
    turtle.onkeypress(down, "Down")
    turtle.onkeypress(right, "Right")
    turtle.onkeypress(left, "Left")

    def make_food():
        global food_stamps, food_pos
        #The screen positions go from -SIZE/2 to +SIZE/2
        #But we need to make food pieces only appear on game squares
        #So we cut up the game board into multiples of SQUARE_SIZE.
        min_x = -int(250 / 2 / SQUARE_SIZE) + 1
        max_x = int(250 / 2 / SQUARE_SIZE) - 1
        min_y = -int(250 / 2 / SQUARE_SIZE) - 1
        max_y = int(250 / 2 / SQUARE_SIZE) + 1

        #Pick a position that is a random multiple of SQUARE_SIZE
        food_x = random.randint(min_x, max_x) * SQUARE_SIZE
        food_y = random.randint(min_y, max_y) * SQUARE_SIZE
        food.goto(food_x, food_y)
        food_pos.append((food_x, food_y))
        a = food.stamp()
        food_stamps.append(a)

    def move_snake():
        global food_stamps, food_pos, START_LENGTH, score, TIME_STEP, direction
        x_pos = snake.pos()[0]
        y_pos = snake.pos()[1]
        if len(food_stamps) <= 6:
            make_food()

        if direction == RIGHT:
            snake.goto(x_pos + SQUARE_SIZE, y_pos)

        elif direction == LEFT:
            snake.goto(x_pos - SQUARE_SIZE, y_pos)

        elif direction == UP:
            snake.goto(x_pos, y_pos + SQUARE_SIZE)

        elif direction == DOWN:
            snake.goto(x_pos, y_pos - SQUARE_SIZE)

        new_pos = snake.pos()
        new_x_pos = new_pos[0]
        new_y_pos = new_pos[1]
        my_pos = snake.pos()
        pos_list.append(my_pos)
        new_stamp = snake.stamp()
        stamp_list.append(new_stamp)
        if new_x_pos >= 250:
            turtle.goto(-400, 150)
            turtle.write("game over! your score is: ",
                         font=("Arial", 55, "normal"))
            turtle.goto(-100, 75)
            turtle.write(str(score), font=("Arial", 55, "normal"))
            turtle.done()
        elif new_x_pos <= -250:
            turtle.goto(-400, 150)
            turtle.write("game over! your score is: ",
                         font=("Arial", 55, "normal"))
            turtle.goto(-100, 75)
            turtle.write(str(score), font=("Arial", 55, "normal"))
            turtle.done()
        elif new_y_pos >= 250:
            turtle.goto(-400, 150)
            turtle.write("game over! your score is: ",
                         font=("Arial", 55, "normal"))
            turtle.goto(-100, 75)
            turtle.write(str(score), font=("Arial", 55, "normal"))
            turtle.done()

        elif new_y_pos <= -250:
            turtle.goto(-400, 150)
            turtle.write("game over! your score is: ",
                         font=("Arial", 55, "normal"))
            turtle.goto(-100, 75)
            turtle.write(str(score), font=("Arial", 55, "normal"))
            turtle.done()

    #    ######## SPECIAL PLACE - Remember it for Part 5
        if snake.pos() in food_pos:
            food_ind = food_pos.index(snake.pos())
            #What does this do?
            food.clearstamp(food_stamps[food_ind])
            snake.color(random.choice(snake_color))
            food_pos.pop(food_ind)
            food_stamps.pop(food_ind)
            score += 100
            if TIME_STEP >= 40:
                TIME_STEP -= 40
        else:
            old_stamp = stamp_list.pop(0)
            snake.clearstamp(old_stamp)
            pos_list.pop(0)

            #Remove eaten food stamp
        if snake.pos() in pos_list[:-1]:
            turtle.goto(-400, 150)
            turtle.write("game over! your score is: ",
                         font=("Arial", 55, "normal"))
            turtle.goto(-100, 75)
            turtle.write(str(score), font=("Arial", 55, "normal"))
            turtle.done()

        turtle.ontimer(move_snake, TIME_STEP)  #end loop
    move_snake()
Exemplo n.º 24
0
import turtle
import random

turtle.register_shape('fireball.gif')
turtle.register_shape('sc.gif')
turtle.register_shape('hf.gif')

character = turtle.clone()
character.shape('sc.gif')
height = 600
character.penup()
character.goto(0, -height / 2 + 100)

width = 800
unitsize = 20
turtle.tracer(1, 0)
turtle.setup(width, height)
#turtle.hideturtle()
turtle.penup()
counter_fireballs = 0

fire_list = []
step = 20
bottom = -height / 2 + 100


def create_fire():
    y_pos = height / 2 - 40
    min_x = -int(width / 2 / unitsize) + 1
    max_x = int(width / 2 / unitsize) - 1
    x_pos = random.randint(min_x, max_x) * unitsize
Exemplo n.º 25
0
    "orange",
    "green",
    "gray",
    "pink",
    "purple",
    "white",
    "GOLD",
]

turtle.bgcolor("black")
SIZE_X = 1000
SIZE_Y = 500

turtle.setup(SIZE_X + 50, SIZE_Y + 50)

border = turtle.clone()
border.penup()
border.color("white")
border.goto(SIZE_X / 2, -SIZE_Y / 2)
border.pendown()
border.goto(SIZE_X / 2, SIZE_Y / 2)
border.goto(-SIZE_X / 2, SIZE_Y / 2)
border.goto(-SIZE_X / 2, -SIZE_Y / 2)
border.goto(SIZE_X / 2, -SIZE_Y / 2)
border.hideturtle()

Number_of_balls = 30
BLOCKS = []
screen_width = 900 / 2
screen_height = 300 / 2
MINIMUM_DX = -2
SIZE_X = 1000
SIZE_Y = 700
turtle.setup(SIZE_X, SIZE_Y)
turtle.tracer(1, 0)
turtle.shape('square')
##platform=turtle.clone()
##platform.shape('square')
##platform.penup()
##platform.goto(-350,-482)
##platform.pendown()
##platform.goto(-300,-482)
##platform.stamp()

SQUARE_SIZE = 20
START_LENGTH = 7
player = turtle.clone()
turtle.register_shape("player.gif")
turtle.register_shape("cloud.gif")
player.shape("player.gif")
#put the player gif in the row above .don't forget to define it
turtle.hideturtle()
pos_list = []
lava_hight = 20
turtle.register_shape('lava.gif')
lava = turtle.clone()
lava.penup()
lava.shape('lava.gif')
lava.showturtle()
lava.goto(0, -SIZE_Y / 2 + lava_hight)
turtle.penup()
turtle.goto(-SIZE_X / 2, -SIZE_Y / 2 + lava_hight)
Exemplo n.º 27
0
turtle.setup(SIZE_X, SIZE_Y) #Curious? It's the turtle window  
                             #size.    
turtle.penup()

SQUARE_SIZE = 20
START_LENGTH = 6
TIME_STEP = 100

#Initialize lists
pos_list = []
stamp_list = []
food_pos = []
food_stamps = []

#Set up positions (x,y) of boxes that make up the snake
snake = turtle.clone()
snake.shape("square")

#Hide the turtle object (it's an arrow - we don't need to see it)
turtle.hideturtle()

#Function to draw a part of the snake on the screen

def new_stamp():
    snake_pos = snake.pos() #Get snake’s position
    #Append the position tuple to pos_list
    pos_list.append(snake_pos) 
    #snake.stamp() returns a stamp ID. Save it in some variable         
    snake_stamp = snake.stamp(#Draw a snake at the start of the game with a for loop
    stamp_list.append(snake_stamp)
Exemplo n.º 28
0
def start_screen(color):

    turtle.hideturtle()
    screen = turtle.Screen()
    screen.setup(800, 800)
    yuval = turtle.clone()
    yuval.pensize(7)
    yuval.color(color)
    yuval.shape("arrow")
    caleb = turtle.clone()
    caleb.hideturtle()
    caleb.shape("arrow")
    screen.bgcolor("light green")
    yuval.penup()
    yuval.goto(150, -300)
    yuval.left(180)
    yuval.pendown()
    yuval.forward(300)
    yuval.right(90)
    yuval.forward(500)
    yuval.left(90)
    yuval.forward(20)
    yuval.left(90)
    yuval.forward(35)
    yuval.left(90)
    yuval.forward(20)
    yuval.left(90)
    yuval.forward(50)
    yuval.right(90)
    yuval.forward(300)
    yuval.right(90)
    yuval.forward(15)
    yuval.right(90)
    yuval.forward(300)
    yuval.backward(20)
    yuval.right(90)

    for i in range(7):
        yuval.forward(15)
        yuval.right(90)
        yuval.forward(20)
        yuval.right(90)
        yuval.forward(15)
        yuval.left(90)
        yuval.forward(20)
        yuval.left(90)
    yuval.right(180)
    yuval.forward(35)
    yuval.left(90)
    yuval.forward(20)
    yuval.left(90)
    yuval.forward(35)
    yuval.left(90)
    yuval.forward(20)
    yuval.left(90)
    yuval.forward(500)
    caleb.penup()
    caleb.color(color)
    caleb.goto(-136, -30)
    caleb.pendown()
    caleb.write('Junk\nJourney', font=('Ariel', 48, 'bold'))
Exemplo n.º 29
0
#settings

import turtle
import random
turtle.tracer(1, 0)
score = 0
x_size = 800
y_size = 700
turtle.setup(x_size, y_size)
SQUARE_SIZE = 20

#background
background = turtle.clone()
turtle.register_shape("background.gif")
background.shape("background.gif")
background.penup()
background.goto(0, 0)
background.stamp()
background.hideturtle()

#farmer
farmer = turtle.clone()
turtle.register_shape("farmer.gif")
farmer.shape("farmer.gif")
farmer_xsize = 50
farmer_ysize = 50
farmer_xpos = farmer.pos()[0]
farmer_ypos = farmer.pos()[1]
farmer_xpos_list = [
    farmer_xpos, farmer_xpos + farmer_xsize / 2, farmer_xpos - farmer_xsize / 2
]
Exemplo n.º 30
0
import turtle
import random
turtle.tracer(1,0)

x_size=800
y_size=700
turtle.setup(x_size,y_size)
turtle.penup()
background = turtle.clone()
turtle.register_shape("background.gif")
background.shape("background.gif")
background.penup()
background.goto(0,0)
background.stamp()
background.hideturtle()

turtle.mainloop()
Exemplo n.º 31
0
import turtle
import random

t = turtle.clone()

words = ('entrepreneurship', 'meet', 'nature', 'global warming', 'animals',
         'recycle', 'tree', 'plastic', ' pollution')
underscore_position = []

#user_word_input = input('enter a letter')
#user_input = input()
t.penup()
t.goto(-400, 0)
#functions here
#secret_word chooses a random word
secret_word = random.choice(words)
print(secret_word)


def words_length_underscore():
    for letter in secret_word:
        underscore_position.append(t.pos())
        t.pendown()
        t.forward(20)
        t.penup()
        t.forward(20)
        print(underscore_position)


words_length_underscore()
DOWN_EDGE = -300

turtle.tracer(1,0)
###the platform





###platform movements
turtle.hideturtle()
turtle.penup()
pos_list=[]
stamp_list=[]

obj = turtle.clone()

obj.showturtle()
obj.shape("square")
obj.resizemode('user')
obj.shapesize(1,LENGHT,1)
platform_height = -SCREEN_HEIGHT/2 + 50
obj.goto(0, platform_height)
obj.color("White")
    
LEFT_ARROW = 'Left'
RIGHT_ARROW= 'Right'
LEFT_EDGE = -SCREEN_WIDTH/2
RIGHT_EDGE = SCREEN_WIDTH/2

Exemplo n.º 33
0
"""
This is an example of what students might make out of the mini project.
"""

import turtle
import random

turtle.penup()
turtle.ht()

turtle.tracer()

# draw wall
wall = turtle.clone()
wall.shape("square")
wall.shapesize(20, 40, 20)
wall.pencolor('black')
wall.fillcolor("light blue")
wall.stamp()

# get the wall boundaries
wall_poly = wall.get_shapepoly()
x_points = []
y_points = []
for point in wall_poly:
    y_points.append(point[0])
    x_points.append(point[1])
MAX_X = max(x_points)
MIN_X = min(x_points)
MAX_Y = max(y_points)
Exemplo n.º 34
0
import turtle
import time
import random
from ball import Ball
import math
import numpy as np
import cv2

o = 55
oo = 125
heart = turtle.clone()
heart.up()
turtle.addshape("heart.gif")
heart.shape("heart.gif")
heart1 = heart.clone()
heart2 = heart.clone()
heart.goto(0, o)
heart1.goto(oo, o)
heart2.goto(oo - oo * 2, o)
hear = 3

turtle.bgcolor(random.randint(0, 225), random.randint(0, 225),
               random.randint(0, 225))
turtle.tracer(0)
turtle.shape("blank")
RUNNING = True
SLEEP = 0.0077
score = 1
SCREEN_WIDTH = turtle.getcanvas().winfo_width() / 2
SCREEN_HEIGHT = turtle.getcanvas().winfo_height() / 2
red = random.randint(0, 255)
Exemplo n.º 35
0
import meet
import turtle
import random
import time

turtle.register_shape("skull.gif")
turtle.ht()
skull=turtle.clone()
skull.shape("skull.gif")
turtle.hideturtle()

skull.penup()
skull.goto(random.randint(-250,250),random.randint(-250,250))
skull.st()
skull.ondrag(skull.goto)



x=3
while x>0:
    turtle.hideturtle()
    turtle.color("black")
    turtle.write(" "+str(x),align='center',font=('ariel',80,'bold'))
    turtle.speed("slowest")
    time.sleep(0.4)
    turtle.clear()
    x-=1


Exemplo n.º 36
0
turtle.shape('turtle')

#I made the size of the turtle larger
turtle.shapesize(2)

#I made the color of the turtle dark green with a black outline.
turtle.color("black", "darkgreen")

#Prints the turtle on the screen right when you start the program to show where you began as you move the turtle around the world.
turtle.stamp()

#I changed the background color to dark khaki.
screen.bgcolor("darkkhaki")

#I added the clone method which clones the original turtle.
turtle2 = turtle.clone()

#I made the color of turtle2 blue with a white outline.
turtle2.color("white", "blue")

#I changed the speed of both turtles to be a little faster.
move_speed = 20
turn_speed = 20

#these defs control the movement of our "turtle"


#Changed the name of my method to jakeforward.
def jakeforward():
    turtle.forward(move_speed)
    x, y = turtle.position()
Exemplo n.º 37
0
##In order complete this challenge you need to debug the following code.
##It may be easier to do so if you improve the code quality.
##copy and paste this code into a new file named “debugging.py”

import turtle  # imports the turtle library

yp7 = turtle.clone()  #this creates a new turtle and stores it in a variable
t = 200
b = -200

#draw the letter ‘A’

turtle.hideturtle()  # this hides the arrow of the turtle called turtle

yp7.penup()
yp7.goto(-200, 0)
yp7.pendown()

a, c = yp7.pos()

yp7.penup()
yp7.goto(a, c)
yp7.pendown()

yp7.goto(a + 100, c + 300)
yp7.goto(a + 200, c)

yp7.penup()
yp7.goto(a + 30, c + 100)
yp7.pendown()
Exemplo n.º 38
0
"""
This is an example of what a MEET student's mini-project might look like
"""
import turtle as t

# Get boundaries
bg = t.clone()
# bg.bgpic()
t.pu()
t.ht()
t.shape("square")
snake = t.clone()

block_pos = []
UP, DOWN, LEFT, RIGHT = 0, 1, 2, 3
SNAKE_LENGTH = 5
DIRECTION = RIGHT

for i in range(SNAKE_LENGTH):
    snake.stamp()
    block_pos.append(snake.pos())
    x, y = snake.pos()
    snake.setpos(x + 20, y)


def move_snake():
    """
    Moves a multiple-block snake
    """
    global block_pos
    global DIRECTION