RUVIDEO
Поделитесь видео 🙏

(PYTHON) Star Wars Game with Python Turtle. #pycharm #starwar #python #developer смотреть онлайн

In this turtle tutorial, we will be learning how to build a simple star wars game with python turtle. For this game, we will use the turtle, random, and the math module. By the end of this tutorial, you will clear all your concepts regarding python turtle from basics to advanced topics. Many advanced turtle “methods” are used for this game too. If you want to learn the Turtle module in Python just follow me on youtube and instagram.

Star Wars Game with Python Turtle:
First Part:
Import the modules “turtle,” “math,” and “random.” Set a turtle screen in the “window” variable. Set the screen up as “width=600, height=600”. Then, declare the background color of the screens as black.
import turtle
import math
import random

window = turtle.Screen()
window.setup(width=600, height=600)
window.title("Star Wars Game by Vibhas Mahaldar")
window.bgcolor("black")
Set the tracer to 0. Likewise, set the vertices as “(0,15),(-15,0),(-18,5),(-18,-5),(0,0),(18,-5),(18, 5),(15, 0)” in the “vertex” variable. Similarly, register the shape as “player” and the vertex variable from above.
window.tracer(0)
vertex = ((0,15),(-15,0),(-18,5),(-18,-5),(0,0),(18,-5),(18, 5),(15, 0))
window.register_shape("player", vertex)
asVertex = ((0, 10), (5, 7), (3,3), (10,0), (7, 4), (8, -6), (0, -10), (-5, -5), (-7, -7), (-10, 0), (-5, 4), (-1, 8))
window.register_shape("chattan", asVertex)

Second Part:
Inherit the “Turtle” from the “turtle” module into a class named “Ankur”. Initialize with the function __init__(self). Then, set the initializer as the turtle. Likewise, set the speed to 0 and pick the pen up as we are not ready to draw.
class Ankur(turtle.Turtle):
def __init__(self):
turtle.Turtle.__init__(self)

self.speed(0)
self.penup()
Coming out of the function, create a function(ankur1) with the parameters “t1” and “t2”. Inside this function, set the current x coordinate into the variable x1 and the y coordinate into y1. Then, do the same with the t2 and “x2”, “y2”. Similarly, set the arctangent of “y1-y2” and “x1-x2” into “taauko” with the math module. Again, multiply the “taauko” with “180.0 / 3.14159” and return “taauko”.
def ankur1(t1, t2):
x1 = t1.xcor()
y1 = t1.ycor()

x2 = t2.xcor()
y2 = t2.ycor()

taauko = math.atan2(y1 - y2, x1 - x2)
taauko = taauko * 180.0 / 3.14159

return taauko
Create an object named “player” from the Ankur() class. Then, set the color to white and the shape to “player”. Declare the score of the player object to 0.
player = Ankur()
player.color("white")
player.shape("player")
player.score = 0

Third Part:
Create an empty list named “missiles”. Then, create a for loop with the range of 3. Inside this loop, create an object from Ankur() named “missile”. Likewise, set the color of the missile to red, shape as an arrow. Then, declare the speed of the missile to 1 and state it as “ready”. Similarly, hide the turtle and append the current missile into the “missiles” list.
missiles = []
for _ in range(3):
missile = Ankur()
missile.color("red")
missile.shape("arrow")
missile.speed = 1
missile.state = "ready"
missile.hideturtle()
missiles.append(missile)
Now, coming out of the loop, create another object from Ankur() as “pen”. Set the color of this turtle object as white and hide the turtle. Then, position the turtle to (0, 250). After that, we will display the score with the code below.
pen = Ankur()
pen.color("white")
pen.hideturtle()
pen.goto(0, 250)
pen.write("Score: 0", False, align = "center", font = ("Arial", 24, "normal"))

for full code DM me on instagram or see full video.

Copyright Disclaimer under Section 107 of the copyright act 1976, allowance is made for fair use for purposes such as criticism, comment, news reporting, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational or personal use tips the balance in favour of fair use.

Please like my video share my video to your friends and subscribe my channel Techno Hacker and please support me on YouTube also support me on Mx Taka Tak and Instagram.

Instagram ID:- https://www.instagram.com/_.techno_hacker._/
Mx Taka Tak:- vibhasmahaldar

Thank You for reading till the end. We have many other advances and small projects on Python Turtle on this YouTube Channel. You can visit on https://www.youtube.com/channel/UCM3W53Ia-aDg68xkszilx3A . Plus, we have a Beginner’s Guide to Python Turtle. Comment down your queries if you have any.

Help us by commenting if you found something wrong in this article.

Keep Learning, Keep Coding.

Thank you
Vibhas Mahaldar

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «(PYTHON) Star Wars Game with Python Turtle. #pycharm #starwar #python #developer» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.