Python - Turtle Race Game V2.0 (Part 1/2)

preview_player
Показать описание
Learn how to a turtle race game using Python's Turtle module. This is an updated version on my original turtle race game.

~ CODE FOR PART 1 ~
from turtle import *
from random import *
import turtle
import time

# SCREEN SETUP
setup(800, 500)
title("Turtle Race")
bgcolor("forestgreen")
speed(0)

# HEADING
penup()
goto(-100, 205)
color("white")
write("TURTLE RACE", font=("Arial", 20, "bold"))

# DIRT
goto(-350, 200)
pendown()
color("chocolate")
begin_fill()
for i in range(2):
forward(700)
right(90)
forward(400)
right(90)
end_fill()

# FINISH LINE
gap_size = 20
shape("square")
penup()

# WHITE SQUARES ROW 1
color("white")
for i in range(10):
goto(250, (170 - (i * gap_size * 2)))
stamp()

# WHITE SQUARES ROW 2
for i in range(10):
goto(250 + gap_size, ((210 - gap_size) - (i * gap_size * 2)))
stamp()

# BLACK SQUARES ROW 1
color("black")
for i in range(10):
goto(250, (190 - (i * gap_size * 2)))
stamp()

# BLACK SQUARES ROW 2
for i in range(10):
goto(251 + gap_size, ((190 - gap_size) - (i * gap_size * 2)))
stamp()
Рекомендации по теме
Комментарии
Автор

I found out how to do turtle key pressed events so do you know how to make it multilayered? using the wn = turtle.Screen() then wn.onkeypress

Scottc
Автор

Is there a way to use this code in Colab so I can play the game there? I've installed the colabturtle correctly but the program keeps getting syntax error for the setup?

mariekevandermaelen
Автор

bro is this applicable in visual studio code?

miguelcornejo
Автор

how to draw dfd diagram for this game ?

harshitha
Автор

I want the flow chat of turtle race game
If you make a flow chat please give me a flow chat of turtle race game

dwmnnky
Автор

why on this channel very few subcribers

metro