def draw_ship(x, y, angle, thrust):
    # y is inverted in the screen, so use subtraction rather than addition.

    #draw thrust lines coming out of the back of the ship
    if thrust > 0:
        for i in range(0, 20):
            flame_length = random.randint(10, 50)
            flame_spread = random.randint(-30, 30)
            flame_x = x + flame_length * math.cos(
                math.radians(angle + 180 + flame_spread))
            flame_y = y - flame_length * math.sin(
                math.radians(angle + 180 + flame_spread))
            pscreen.line(x, y, flame_x, flame_y,
                         (random.randint(150, 255), random.randint(0, 100), 0),
                         6)

    p1x = x + 40 * math.cos(math.radians(angle))
    p1y = y - 40 * math.sin(math.radians(angle))
    p2x = x + 25 * math.cos(math.radians(angle + 120))
    p2y = y - 25 * math.sin(math.radians(angle + 120))
    p3x = x + 5 * math.cos(math.radians(angle + 180))
    p3y = y - 5 * math.sin(math.radians(angle + 180))
    p4x = x + 25 * math.cos(math.radians(angle - 120))
    p4y = y - 25 * math.sin(math.radians(angle - 120))
    pscreen.triangle(p1x, p1y, p2x, p2y, p3x, p3y, (100, 0, 200), 0)
    pscreen.triangle(p1x, p1y, p3x, p3y, p4x, p4y, (80, 0, 150), 0)
def draw_ship2(x2, y2, angle2, thurst2):
    #second player ship
    p21x = x2 + 25 * math.cos(math.radians(angle2))
    p21y = y2 - 25 * math.sin(math.radians(angle2))
    p22x = x2 + 15 * math.cos(math.radians(angle2 + 110))
    p22y = y2 - 15 * math.sin(math.radians(angle2 + 110))
    p23x = x2 + 2 * math.cos(math.radians(angle2 + 180))
    p23y = y2 - 2 * math.sin(math.radians(angle2 + 180))
    p24x = x2 + 15 * math.cos(math.radians(angle2 - 110))
    p24y = y2 - 15 * math.sin(math.radians(angle2 - 110))
    pscreen.triangle(p21x, p21y, p22x, p22y, p23x, p23y, (168, 255, 150), 0)
    pscreen.triangle(p21x, p21y, p23x, p23y, p24x, p24y, (168, 255, 150), 0)
def draw_ship(x, y, angle, thrust):
    #ship
    p1x = x + 25 * math.cos(math.radians(angle))
    p1y = y - 25 * math.sin(math.radians(angle))
    p2x = x + 15 * math.cos(math.radians(angle + 110))
    p2y = y - 15 * math.sin(math.radians(angle + 110))
    p3x = x + 2 * math.cos(math.radians(angle + 180))
    p3y = y - 2 * math.sin(math.radians(angle + 180))
    p4x = x + 15 * math.cos(math.radians(angle - 110))
    p4y = y - 15 * math.sin(math.radians(angle - 110))
    pscreen.triangle(p1x, p1y, p2x, p2y, p3x, p3y, (150, 25, 168), 0)
    pscreen.triangle(p1x, p1y, p3x, p3y, p4x, p4y, (150, 25, 168), 0)
def drawTreasure(x,y):
    #chest1
    #chest top
    pscreen.rectangle(x-50,y-50,x-40,y-20,brown,0)
    pscreen.triangle(x-50,y-50,x-50,y-20,x-60,y-20,brown,0)
    pscreen.triangle(x-40,y-20,x-40,y-50,x-30,y-20,brown,0)
    #chest body
    pscreen.rectangle(x-60,y-20,x-30,y,brown,0)
    #line between chest lid and chest body
    pscreen.line(x-50,y-20,x-40,y-20,black,0)
    #chest lock
    pscreen.rectangle(x-47,y-23,x-42,y-14,yellow,0)
 def draw_Ship(self):
     Ship.move(self)
     if self.shield==True:
         pscreen.circle(self.x,self.y,25,(132,112,255),1)
     p1x=self.x+25*math.cos(math.radians(self.angle))
     p1y=self.y-25*math.sin(math.radians(self.angle))
     p2x=self.x+15*math.cos(math.radians(self.angle+120))
     p2y=self.y-15*math.sin(math.radians(self.angle+120))
     p3x=self.x+5*math.cos(math.radians(self.angle+180))
     p3y=self.y-5*math.sin(math.radians(self.angle+180))
     p4x=self.x+15*math.cos(math.radians(self.angle-120))
     p4y=self.y-15*math.sin(math.radians(self.angle-120))
     pscreen.triangle(p1x,p1y,p2x,p2y,p3x,p3y,(72,61,139),0)
     pscreen.triangle(p1x,p1y,p3x,p3y,p4x,p4y,(0,191,255),0)
     #draw flame behind ship when thrusting
     if self.thrust==True:
         for i in range(0,5):
             flame_length=random.randint(25,40)
             flame_spread=random.randint(-15,15)
             flame_x=self.x+flame_length*math.cos(math.radians(self.angle+180+flame_spread))
             flame_y=self.y-flame_length*math.sin(math.radians(self.angle+180+flame_spread))
             pscreen.line(self.x,self.y,flame_x,flame_y,(random.randint(150,200),random.randint(100,150),random.randint(150,175)),4)
Example #6
0
def draw_Ship(x, y, angle, thrust):
    #draws thrust lines coming from back of the ship
    if thrust > 0:
        for i in range(0, 10):
            flame_length = random.randint(25, 40)
            flame_spread = random.randint(-30, 30)
            flame_x = x + flame_length * math.cos(
                math.radians(angle + 180 + flame_spread))
            flame_y = y - flame_length * math.sin(
                math.radians(angle + 180 + flame_spread))
            pscreen.line(x, y, flame_x, flame_y, (random.randint(
                100, 200), random.randint(50, 150), random.randint(100, 175)),
                         4)
    #draws ship
    p1x = x + 40 * math.cos(math.radians(angle))
    p1y = y - 40 * math.sin(math.radians(angle))
    p2x = x + 25 * math.cos(math.radians(angle + 120))
    p2y = y - 25 * math.sin(math.radians(angle + 120))
    p3x = x + 10 * math.cos(math.radians(angle + 180))
    p3y = y - 10 * math.sin(math.radians(angle + 180))
    p4x = x + 25 * math.cos(math.radians(angle - 120))
    p4y = y - 25 * math.sin(math.radians(angle - 120))
    pscreen.triangle(p1x, p1y, p2x, p2y, p3x, p3y, (200, 0, 255), 0)
    pscreen.triangle(p1x, p1y, p3x, p3y, p4x, p4y, (255, 0, 200), 0)
Example #7
0
def drawArrow(base_x=300, base_y=400, angle=0):
    #values
    x = base_x
    y = base_y
    #base
    p1x = x + 25 * math.cos(math.radians(angle + 45))
    p1y = y - 10 * math.sin(math.radians(angle + 45))
    p2x = x + 25 * math.cos(math.radians(angle - 45))
    p2y = y + 10 * math.sin(math.radians(angle - 45))
    p3x = x - 25 * math.cos(math.radians(angle + 135))
    p3y = y - 10 * math.sin(math.radians(angle + 135))
    p4x = x - 25 * math.cos(math.radians(angle - 135))
    p4y = y + 10 * math.sin(math.radians(angle - 135))
    #head
    h1x = x + 25 * math.cos(math.radians(angle))
    h1y = y - 15 * math.sin(math.radians(angle))
    h2x = x + 75 * math.cos(math.radians(angle + 90))
    h2y = y * math.sin(math.radians(angle + 90))
    h3x = x + 25 * math.cos(math.radians(angle - 90))
    h3y = y + 15 * math.sin(math.radians(angle - 90))
    #draw the arrow
    pscreen.triangle(h1x, h1y, h2x, h2y, h3x, h3y, (255, 0, 0), 0)
    pscreen.triangle(p1x, p1y, p2x, p2y, p4x, p4y, (255, 0, 0), 0)
    pscreen.triangle(p2x, p2y, p3x, p3y, p4x, p4y, (255, 0, 0), 0)
    x = random.randint(0, 799)  #random x cordinate
    y = random.randint(0, 799)  #random y cordinate
    randR = random.randint(5, 255)  #random Red value
    randG = random.randint(5, 255)  #random Green value
    randB = random.randint(5, 255)  #random Blue value
    c = (randR, randG, randB)  #random colors
    #pressing c prints circles on the screen
    if pscreen.keyIsPressed("c"):
        pscreen.circle(x, y, 20, c)
    #pressing s prints squares on the screen
    if pscreen.keyIsPressed("s"):
        pscreen.rectangle(x, y, x - 20, y - 20, c)
    #pressing f prints faces with moods on the screen
    if pscreen.keyIsPressed("f"):

        #draws the defined face
        drawFace(x, y, randMood)
        #clear screen to a random color
    if pscreen.keyIsPressed("e"):
        pscreen.clearScreen(c)
        #random diamonds
    if pscreen.keyIsPressed("d"):
        pscreen.triangle(x, y, x - 6, y, x - 3, y - 10, c)
        pscreen.triangle(x, y, x - 6, y, x - 3, y + 10, c)
    if pscreen.keyIsPressed("escape"):
        break
    pscreen.updateScreen()

#unloadScreen
pscreen.unloadScreen()
pscreen.line(225, 225, 230, 230, (255, 255, 255),
             1)  #changed it from (250,250,270,260)
#Nose
pscreen.line(190, 200, 200, 205, (255, 255, 255),
             1)  #changed it from (170,180,200,200)
pscreen.line(190, 200, 205, 190, (255, 255, 255),
             1)  #changed it from (170,180,210,170)

#pacman
#body
pscreen.circle(400, 200, 25, (255, 255, 0), 0)  #changed it from (400,200,25)
#eye
pscreen.circle(400, 185, 3, (0, 0, 0), 0)  #changed it from (400,175,10)

#mouth
pscreen.triangle(400, 200, 450, 225, 450, 175, (0, 0, 0), 0)

#ghost
#body
pscreen.circle(700, 205, 25, (0, 255, 255), 0)  #changed from (700,175,25)
#deleted (pscreen.rectangle(675,200,725,175,(0,255,255),0))
pscreen.rectangle(675, 225, 725, 200, (0, 255, 255), 0)

#eyes
pscreen.circle(685, 200, 3, (0, 0, 0), 0)  #changed from (685,185,5)
pscreen.circle(715, 200, 3, (0, 0, 0), 0)  #changed from (715,185,5)
#mouth
pscreen.line(685, 210, 715, 210, (0, 0, 0), 1)
#triagle base
pscreen.triangle(675, 225, 675, 230, 680, 225, (0, 255, 255), 0)
pscreen.triangle(680, 225, 680, 230, 685, 225, (0, 255, 255), 0)
Example #10
0
def drawP():  #draws the player
    #main canon body
    pscreen.triangle(pX - 5, pY, pX + 25, pY, pX + 10, pY - 30,
                     (245, 245, 245), 0)
    pscreen.rectangle(pX + 5, pY, pX + 15, pY - 10, (105, 105, 105), 0)
    pscreen.circle(pX + 10, pY - 20, random.randint(1, 4), (255, 215, 0), 0)