<reponame>Jazzboy-12/Star-Wars-Game-With-Python
# This is the First Part:

import turtle
import math
import random

window = turtle.Screen()
window.setup(width=800, height=800)
window.title("Star Wars Game by <NAME>")
window.bgcolor("black")

window.tracer(0)

vertex = ((0, 15), (-15, 0), (-18, 5), (-18, -5), (0, 0), (18, -5), (18, 5), (15, 0))           #our spaceship design
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)


####################
# This is the Second Part:


class Ankur(turtle.Turtle):
    def __init__(self):
        turtle.Turtle.__init__(self)

        self.speed(0)
        self.penup()


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


player = Ankur()
player.color("white")
player.shape("player")
player.score = 0

####################
# This is the Third Part

missiles = []
for _ in range(3):
    missile = Ankur()
    missile.color("red")
    missile.shape("triangle")        #missle shape
    missile.speed = 1
    missile.state = "ready"
    missile.hideturtle()
    missiles.append(missile)

pen = Ankur()
pen.color("white")
pen.hideturtle()
pen.goto(-650, 350)                                 #score board
pen.write("Score: 0", False, align="left", font=("Arial", 24, "normal"))

####################
# This is the Fourth Part


chattans = []

for _ in range(5):
    chattan = Ankur()
    chattan.color("green")              #enemy space ship color
    chattan.shape("arrow")

    chattan.speed = random.randint(2, 3) / 50
    chattan.goto(0, 0)
    taauko = random.randint(0, 260)
    distance = random.randint(300, 400)
    chattan.setheading(taauko)
    chattan.fd(distance)
    chattan.setheading(ankur1(player, chattan))
    chattans.append(chattan)


####################
# This is the Functions for Defence Part

def baanya():
    player.lt(20)


def daanya():
    player.rt(20)


def fire_missile():
    for missile in missiles:
        if missile.state == "ready":
            missile.goto(0, 0)
            missile.showturtle()
            missile.setheading(player.heading())
            missile.state = "fire"
            break


window.listen()
window.onkey(baanya, "Left")
window.onkey(daanya, "Right")
window.onkey(fire_missile, "space")

####################
# This is the Functioning the Code Part-1

#if alive

sakkyo = False
while True:

    window.update()
    player.goto(0, 0)

    for missile in missiles:
        if missile.state == "fire":
            missile.fd(missile.speed)

        if missile.xcor() > 300 or missile.xcor() < -300 or missile.ycor() > 300 or missile.ycor() < -300:
            missile.hideturtle()
            missile.state = "ready"

    for chattan in chattans:
        chattan.fd(chattan.speed)

        for missile in missiles:
            if chattan.distance(missile) < 20:
                taauko = random.randint(0, 260)
                distance = random.randint(600, 800)
                chattan.setheading(taauko)
                chattan.fd(distance)
                chattan.setheading(ankur1(player, chattan))
                chattan.speed += 0.005   #enemy_space_ship_speed

                missile.goto(600, 600)
                missile.hideturtle()
                missile.state = "ready"

                player.score += 10
                pen.clear()
                pen.write("Score: {}".format(player.score), False, align="center", font=("Arial", 24, "normal"))

        ####################
        # This is the Functioning the Code Part-2

        if chattan.distance(player) < 20:
            taauko = random.randint(0, 260)
            distance = random.randint(600, 800)
            chattan.setheading(taauko)
            chattan.fd(distance)
            chattan.setheading(ankur1(player, chattan))
            chattan.speed += 0.005                      #enemy space ship speed
            sakkyo = True
            pen.clear()

    # if dead

    if sakkyo == True:
        player.hideturtle()
        missile.hideturtle()
        for a in chattans:
            a.hideturtle()
        pen.clear()
        pen.color("red")
        pen.goto(0, 100)
        pen.write("GAME OVER !!", False, align="center", font=("Arial", 24, "normal"))
        pen.goto(0, -100)
        pen.color("blue")
        pen.write("Score: {}".format(player.score), False, align="center", font=("Arial", 24, "normal"))
        break

window.mainloop()
# This Game is build by <NAME>

# This is the First Part:

import turtle
import math
import random

window = turtle.Screen()
window.setup(width=800, height=800)
window.title("Star Wars Game by <NAME>")
window.bgcolor("black")

window.tracer(0)

vertex = ((0, 15), (-15, 0), (-18, 5), (-18, -5), (0, 0), (18, -5), (18, 5), (15, 0))           #our spaceship design
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)


####################
# This is the Second Part:


class Ankur(turtle.Turtle):
    def __init__(self):
        turtle.Turtle.__init__(self)

        self.speed(0)
        self.penup()


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


player = Ankur()
player.color("white")
player.shape("player")
player.score = 0

####################
# This is the Third Part

missiles = []
for _ in range(3):
    missile = Ankur()
    missile.color("red")
    missile.shape("triangle")        #missle shape
    missile.speed = 1
    missile.state = "ready"
    missile.hideturtle()
    missiles.append(missile)

pen = Ankur()
pen.color("white")
pen.hideturtle()
pen.goto(-650, 350)                                 #score board
pen.write("Score: 0", False, align="left", font=("Arial", 24, "normal"))

####################
# This is the Fourth Part


chattans = []

for _ in range(5):
    chattan = Ankur()
    chattan.color("green")              #enemy space ship color
    chattan.shape("arrow")

    chattan.speed = random.randint(2, 3) / 50
    chattan.goto(0, 0)
    taauko = random.randint(0, 260)
    distance = random.randint(300, 400)
    chattan.setheading(taauko)
    chattan.fd(distance)
    chattan.setheading(ankur1(player, chattan))
    chattans.append(chattan)


####################
# This is the Functions for Defence Part

def baanya():
    player.lt(20)


def daanya():
    player.rt(20)


def fire_missile():
    for missile in missiles:
        if missile.state == "ready":
            missile.goto(0, 0)
            missile.showturtle()
            missile.setheading(player.heading())
            missile.state = "fire"
            break


window.listen()
window.onkey(baanya, "Left")
window.onkey(daanya, "Right")
window.onkey(fire_missile, "space")

####################
# This is the Functioning the Code Part-1

#if alive

sakkyo = False
while True:

    window.update()
    player.goto(0, 0)

    for missile in missiles:
        if missile.state == "fire":
            missile.fd(missile.speed)

        if missile.xcor() > 300 or missile.xcor() < -300 or missile.ycor() > 300 or missile.ycor() < -300:
            missile.hideturtle()
            missile.state = "ready"

    for chattan in chattans:
        chattan.fd(chattan.speed)

        for missile in missiles:
            if chattan.distance(missile) < 20:
                taauko = random.randint(0, 260)
                distance = random.randint(600, 800)
                chattan.setheading(taauko)
                chattan.fd(distance)
                chattan.setheading(ankur1(player, chattan))
                chattan.speed += 0.005   #enemy_space_ship_speed

                missile.goto(600, 600)
                missile.hideturtle()
                missile.state = "ready"

                player.score += 10
                pen.clear()
                pen.write("Score: {}".format(player.score), False, align="center", font=("Arial", 24, "normal"))

        ####################
        # This is the Functioning the Code Part-2

        if chattan.distance(player) < 20:
            taauko = random.randint(0, 260)
            distance = random.randint(600, 800)
            chattan.setheading(taauko)
            chattan.fd(distance)
            chattan.setheading(ankur1(player, chattan))
            chattan.speed += 0.005                      #enemy space ship speed
            sakkyo = True
            pen.clear()

    # if dead

    if sakkyo == True:
        player.hideturtle()
        missile.hideturtle()
        for a in chattans:
            a.hideturtle()
        pen.clear()
        pen.color("red")
        pen.goto(0, 100)
        pen.write("GAME OVER !!", False, align="center", font=("Arial", 24, "normal"))
        pen.goto(0, -100)
        pen.color("blue")
        pen.write("Score: {}".format(player.score), False, align="center", font=("Arial", 24, "normal"))
        break

window.mainloop()
# This Game is build by <NAME>
# This is the First Part: #our spaceship design #################### # This is the Second Part: #################### # This is the Third Part #missle shape #score board #################### # This is the Fourth Part #enemy space ship color #################### # This is the Functions for Defence Part #################### # This is the Functioning the Code Part-1 #if alive #enemy_space_ship_speed #################### # This is the Functioning the Code Part-2 #enemy space ship speed # if dead # This Game is build by <NAME>