Python Turtle - Code a Night Sky Tutorial

Publié le: 01 janvier 1970
sur la chaîne: Geek Tutorials
12,642
170

Learn how to quickly and easily draw a night sky scene using loops and functions in Python.

Get Mu - https://codewith.mu/

~ CODE ~

from turtle import *
from random import randint

Page setup
setup(800, 500)
speed(0)
bgcolor("black")

Function to draw one star
def star():
color("yellow")
begin_fill()
for i in range(5):
forward(10)
right(144)
end_fill()

Draw multiple stars at random locations on the screen
for i in range(20):
x = randint(-400, 400)
y = randint(-250, 250)
star()
penup()
goto(x, y)
pendown()

Moon - Part 1
penup()
goto(-300, 100)
pendown()
color("white")
begin_fill()
circle(50)
end_fill()

Moon - Part 2
penup()
goto(-280, 100)
pendown()
color("black")
begin_fill()
circle(50)
end_fill()

hideturtle()


Sur cette page du site, vous pouvez voir la vidéo en ligne Python Turtle - Code a Night Sky Tutorial durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Geek Tutorials 01 janvier 1970, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 12,642 fois et il a aimé 170 téléspectateurs. Bon visionnage!