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 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 drawFace(x,y):
    #assigning values
    #Head
    pscreen.circle(x,y,25,aWhite,0)
    #mouth
    pscreen.line(x-5,y+5,x+5,y+5,black,)
    pscreen.line(x-5,y+5,x-7,y+2,black,0)
    pscreen.line(x+5,y+5,x+7,y+2,black,0)
    #eyes
    pscreen.ellipse(x-5,y-10,4,4,white,0)
    pscreen.ellipse(x+5,y-10,4,4,white,0)
    pscreen.circle(x-5,y-10,2,blue,0)
    pscreen.circle(x+5,y-10,2,blue,0)
    #nose
    pscreen.line(x-2,y+2,x,y-1,black,0)
    pscreen.line(x-2,y+2,x+1,y+1,black,0)
Ejemplo n.º 4
0
 def draw(self):
     self.update()
     p1x = self.x + self.radius * math.cos(math.radians(self.angle + 18))
     p1y = self.y + (-1) * self.radius * math.sin(
         math.radians(self.angle + 18))
     p2x = self.x + self.radius * math.cos(math.radians(self.angle + 90))
     p2y = self.y - self.radius * math.sin(math.radians(self.angle + 90))
     p3x = self.x + self.radius * math.cos(math.radians(self.angle + 162))
     p3y = self.y - self.radius * math.sin(math.radians(self.angle + 162))
     p4x = self.x + self.radius * math.cos(math.radians(self.angle + 234))
     p4y = self.y - self.radius * math.sin(math.radians(self.angle + 234))
     p5x = self.x + self.radius * math.cos(math.radians(self.angle + 308))
     p5y = self.y - self.radius * math.sin(math.radians(self.angle + 308))
     pscreen.line(p1x, p1y, p3x, p3y, self.color, 1)
     pscreen.line(p1x, p1y, p4x, p4y, self.color, 1)
     pscreen.line(p2x, p2y, p4x, p4y, self.color, 1)
     pscreen.line(p2x, p2y, p5x, p5y, self.color, 1)
     pscreen.line(p3x, p3y, p5x, p5y, self.color, 1)
     pscreen.circle(self.x, self.y, self.radius, self.color, 1)
 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)
 def drawStar(self):
     self.update()
     self.radius += .02 * math.sin(math.radians(modulation_angle))
     p1x = self.x + self.radius * math.cos(math.radians(self.angle + 18))
     p1y = self.y + (-1) * self.radius * math.sin(
         math.radians(self.angle + 18))
     p2x = self.x + self.radius * math.cos(math.radians(self.angle + 90))
     p2y = self.y + (-1) * self.radius * math.sin(
         math.radians(self.angle + 90))
     p3x = self.x + self.radius * math.cos(math.radians(self.angle + 162))
     p3y = self.y + (-1) * self.radius * math.sin(
         math.radians(self.angle + 162))
     p4x = self.x + self.radius * math.cos(math.radians(self.angle + 238))
     p4y = self.y + (-1) * self.radius * math.sin(
         math.radians(self.angle + 238))
     p5x = self.x + self.radius * math.cos(math.radians(self.angle + 308))
     p5y = self.y + (-1) * self.radius * math.sin(
         math.radians(self.angle + 308))
     pscreen.line(p1x, p1y, p3x, p3y, self.color, 1)
     pscreen.line(p1x, p1y, p4x, p4y, self.color, 1)
     pscreen.line(p2x, p2y, p4x, p4y, self.color, 1)
     pscreen.line(p2x, p2y, p5x, p5y, self.color, 1)
     pscreen.line(p3x, p3y, p5x, p5y, self.color, 1)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
def drawP():
    #body
    pscreen.circle(pX, pY, pR, aWhite, 0)
    #eyes
    pscreen.circle(int(pX) - 15, int(pY) - 12, pR - 20, white, 0)
    pscreen.circle(int(pX) + 15, int(pY) - 12, pR - 20, white, 0)
    #eye color
    pscreen.circle(int(pX) - 15, int(pY) - 12, pR - 25, nBlue, 0)
    pscreen.circle(int(pX) + 15, int(pY) - 12, pR - 25, nBlue, 0)
    #pupils
    pscreen.circle(int(pX) - 15, int(pY) - 12, pR - 27, black, 0)
    pscreen.circle(int(pX) + 15, int(pY) - 12, pR - 27, black, 0)
    #Mouth
    pscreen.line(int(pX) - 15, int(pY) + 15, (pX) + 15, pY + 15, black, 3)
    pscreen.line(int(pX) - 15, int(pY) + 15, (pX) - 20, pY + m, black, 3)
    pscreen.line(int(pX) + 15, int(pY) + 15, (pX) + 20, pY + m, black, 3)
    #Nose
    pscreen.circle(pX, pY, pR - 25, S, 0)
    pscreen.circle(pX, pY, pR - 27, dS, 0)
def drawFace(x, y, randMood):
    #face
    pscreen.circle(x, y, 20, c, 0)
    #whites of eyes
    pscreen.circle(x - 5, y - 5, 5, white, 0)
    pscreen.circle(x + 5, y - 5, 5, white, 0)
    #color of eyes
    pscreen.circle(x - 5, y - 5, 2, b, 0)
    pscreen.circle(x + 5, y - 5, 2, b, 0)
    #pupils
    pscreen.circle(x - 5, y - 5, 1, (0, 0, 0), 0)
    pscreen.circle(x + 5, y - 5, 1, (0, 0, 0), 0)
    #nose
    pscreen.line(x - 2, y, x + 3, y + 2, (0, 0, 0), 1)
    pscreen.line(x - 2, y, x + 3, y - 2, (0, 0, 0), 1)
    #Mouth
    if randMood == "happy":
        pscreen.line(x - 5, y + 5, x + 5, y + 5, black)
        pscreen.line(x - 5, y + 5, x - 7, y + 3, black)
        pscreen.line(x + 5, y + 5, x + 7, y + 3, black)
    elif randMood == "nuetral":
        pscreen.line(x - 5, y + 5, x + 5, y + 5, black)
    elif randMood == "sad":
        pscreen.line(x - 5, y + 5, x + 5, y + 5, black)
        pscreen.line(x - 5, y + 5, x - 7, y + 8, black)
        pscreen.line(x + 5, y + 5, x + 7, y + 8, black)
        playerY += 1
    #contain player on the screen
    if playerX < 0:
        playerX = 0
    if playerX > 799:
        playerX = 799
    if playerY < 0:
        playerY = 0
    if playerY > 599:
        playerY = 599

    #render objects / draw stuff
    #clear the screen
    pscreen.clearScreen((0, 0, 0))
    #draw a circle
    pscreen.circle(playerX, playerY, 20, (255, 255, 0), 0)  #head outline
    pscreen.circle(playerX - 6, playerY - 6, 3)  #left eye (our left)
    pscreen.circle(playerX - 6, playerY - 6, 2, (0, 255, 255), 0)  #left pupil
    pscreen.circle(playerX + 6, playerY - 6, 3)  #right eye (our right)
    pscreen.circle(playerX + 6, playerY - 6, 2, (0, 255, 255), 0)  #right pupil
    pscreen.line(playerX - 8, playerY + 8, playerX + 8, playerY + 8,
                 (255, 0, 255))  #mouth

    pscreen.fontWrite(
        0, 0, "Game Loop Example",
        (255, 255, 255))  #display text in upper left hand corner (our left)
    pscreen.updateScreen()

#Clean-up
pscreen.unloadScreen()
def drawFace2(x,y,randColor,randMood):
    #Head
    pscreen.circle(x,y,25,randColor,0)
    #mouth
    if randMood == "happy":#happy face
        pscreen.line(x-5,y+5,x+5,y+5,black)
        pscreen.line(x-5,y+5,x-7,y+2,black,0)
        pscreen.line(x+5,y+5,x+7,y+2,black,0)
    if randMood == "mad":#mad face
        pscreen.line(x-5,y+5,x+5,y+5,black)
        pscreen.line(x-5,y+5,x-7,y+7,black,0)
        pscreen.line(x+5,y+5,x+7,y+7,black,0)
    if randMood == "nuetral":#nuetral face
        pscreen.line(x-5,y+5,x+5,y+5,black)
    #eyes
    if randMood == "happy":
        pscreen.ellipse(x-5,y-10,4,4,white,0)
        pscreen.ellipse(x+5,y-10,4,4,white,0)
        pscreen.circle(x-5,y-10,2,blue,0)
        pscreen.circle(x+5,y-10,2,blue,0)
    if randMood == "nuetral":
        pscreen.ellipse(x-5,y-10,4,4,white,0)
        pscreen.ellipse(x+5,y-10,4,4,white,0)
        pscreen.circle(x-5,y-10,2,blue,0)
        pscreen.circle(x+5,y-10,2,blue,0)
    if randMood == "mad":
        pscreen.line(x-10,y-18,x-5,y-15,black)
        pscreen.line(x+10,y-18,x+5,y-15,black)
        pscreen.ellipse(x-5,y-10,4,4,white,0)
        pscreen.ellipse(x+5,y-10,4,4,white,0)
        pscreen.circle(x-5,y-10,2,blue,0)
        pscreen.circle(x+5,y-10,2,blue,0)
    #nose
    pscreen.line(x-2,y+2,x,y-1,black,0)
    pscreen.line(x-2,y+2,x+1,y+1,black,0)
# pscreen Test Program

import pscreen
import time
import random

pscreen.loadScreen()

pscreen.circle(200,200,100)
pscreen.circle(400,400,100,(0,0,255),5)
pscreen.circle(300,300,100,(0,0,254),0)

pscreen.line(200,200,400,400,(255,0,0),5)

i=0
while i<100:
    rand_x = random.randint(0,799)
    rand_y = random.randint(0,599)
    rand_radius = random.randint(20,100)
    rand_r = random.randint(0,255)
    rand_g = random.randint(0,255)
    rand_b = random.randint(0,255)
    pscreen.circle(rand_x,rand_y,rand_radius)
    i+=1
    

while pscreen.keyIsNotPressed("q"):
    pscreen.updateScreen()
time.sleep(5)

pscreen.unloadScreen()
import time

#loading of the screen
pscreen.loadScreen()

#assigning values to white and black
#Face
pscreen.circle(200, 200, 50, (255, 255, 255), 1)
#Eyes
pscreen.ellipse(175, 185, 10, 5, (255, 255, 255),
                1)  #changed it from (140,175,20,10)
pscreen.ellipse(225, 185, 10, 5, (255, 255, 255), 1)
pscreen.circle(175, 185, 2, (255, 255, 255), 1)
pscreen.circle(225, 185, 2, (255, 255, 255), 1)
#smile
pscreen.line(175, 225, 225, 225, (255, 255, 255),
             1)  #changed it from (150,250,250,250)
pscreen.line(175, 225, 170, 230, (255, 255, 255),
             1)  #changed it from (150,250,130,260)
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)