Example #1
0
def main():
    root = Tk()
    root.title('FlappyBird')
    canvas = Canvas(width=width, height=height)
    canvas.pack()
    game = True
    ground = g.Ground()
    ground.move(canvas, 0)
    background = PhotoImage(file="images/background_day.gif")
    canvas.create_image(width / 2, height / 2 + 20, image=background)
    bird = b.Bird()
    pipes = ps.Pipes()
    bird.draw(canvas, 0)
    n = 0  #every 200th loop create a new pipe
    while game:
        if n % 100 == 0:
            n = 0
            pipes.add()
        bird.update(root)
        for pipe in pipes.pipes:
            pipe.move()
            if (pipe.x <= bird.x + bird.size
                    and bird.x - bird.size <= pipe.x + pipe.w):
                if (pipe.y1 - 1 <= bird.y - bird.size
                        and bird.y + bird.size <= pipe.y2) == False:
                    #game=False
                    pass
            else:
                pass
            pipe.draw(canvas, 1)
        bird.draw(canvas, 1)
        ground.move(canvas, 1)
        root.update()
        n += 1
    root.mainloop()
Example #2
0
async def scheduler():
    env = e.Enviroment()
    gnd = g.Ground()
    pvd = p.CloudProvider()

    await asyncio.gather(
        manageData(env, gnd),
        manageWatering(gnd),
        manageTB(pvd, env, gnd),
    )
 def __init__(self, screen, level):
     self.screen = screen
     self.level = level
     #Create player
     self.player = ship.Ship(screen, 400, 0)
     #Create the ground
     self.ground = ground.Ground(screen)
     #List of intangible animation objects
     self.animation_list = []
     self.victory = False
Example #4
0
 def __init__(self, height, width):
     self.cloud_types = [
         pygame.image.load("images/cloud1.png"),
         pygame.image.load("images/cloud2.png"),
         pygame.image.load("images/cloud3.png")
     ]
     self.screen_width = width
     self.screen_height = height
     self.clouds = []
     self.ground = ground.Ground(width, height)
Example #5
0
 def __init__(self, width, height):
     self.mWidth = width
     self.mHeight = height
     self.mBlueSky = sky.Sky(self.mWidth, self.mHeight)
     self.mGround = ground.Ground(self.mWidth, self.mHeight)
     self.mMountain = mountain.Mountain(self.mWidth, self.mHeight)
     self.mMoon = moon.Moon(self.mWidth, self.mHeight)
     self.mWater = water.Water(self.mWidth, self.mHeight)
     self.mHouse = house.House(self.mWidth, self.mHeight)
     self.mCloud = cloud.Cloud(self.mWidth, self.mHeight)
     self.mBird = bird.Bird(self.mWidth, self.mHeight)
Example #6
0
 def createSquares(self, window):
     x = 0
     y = 0
     for i in range(0, 10):
         newSquareArray = []
         for j in range(0, 10):
             generatedGround = ground.Ground(x, y, window)
             newSquareArray.append(generatedGround)
             x += 40
         self.squares.append(newSquareArray)
         y += 40
         x = 0
Example #7
0
    def blitBoard(self, window):
        x = y = 0
        for i in range(11):
            for j in range(11):
                ground.Ground(x, y, window)
                x += 40

            y += 40
            x = 0

        x = y = 0
        for i in range(11):
            for j in range(11):
                if i % 2 != 0 and j % 2 != 0:
                    metal.Metal(x, y, window)
                x += 40

            y += 40
            x = 0
Example #8
0
    def createBoard(self, window):
        walls = []
        x = y = 0
        for i in range(11):
            for j in range(11):
                ground.Ground(x, y, window)
                x += 40

            y += 40
            x = 0

        x = y = 0
        for i in range(11):
            for j in range(11):
                if i % 2 != 0 and j % 2 != 0:
                    metal.Metal(x, y, window)
                    walls.append(pygame.Rect(x, y, 40, 40))
                x += 40

            y += 40
            x = 0
        x = y = 0
        for i in range(11):
            for j in range(11):
                if (i, j) == (0, 0) or (i, j) == (0, 1) or (i, j) == (1, 0):
                    x += 40
                    continue
                chanceRock = random.randint(1, 2)
                if not (i % 2 != 0 and j % 2 != 0):
                    if chanceRock == 1:
                        walls.append(pygame.Rect(x, y, 40, 40))
                        self.breakableWallPosition[j][i] = 1
                x += 40
            y += 40
            x = 0
        return walls
Example #9
0
    def __init__(self):
        self.world_x = 0
        self.player = player.Player(500, 590)

        self.boss_position = 10000
        self.boss_battle = False

        self.ground = [
            #bottom:

            #flying
            ground.Ground(200, 450, 200, 50),
            ground.Ground(400, 250, 200, 50),
            ground.Ground(800, 450, 200, 50),
            ground.Ground(200 * 11 - 150, 500, 200, 50),
            ground.Ground(4000, 450, 200, 50),
            ground.Ground(4400, 350, 200, 50),
            ground.Ground(4600, 550, 200, 50),
            ground.Ground(5000, 350, 200, 50),
            ground.Ground(5500, 600, 200, 50),
            ground.Ground(7600, 450, 200, 50),
            ground.Ground(8200, 380, 200, 50),

            #bossplatforms
            ground.Ground(self.boss_position + 100, 450, 200, 50),
            ground.Ground(self.boss_position + 700, 450, 200, 50),
            ground.Ground(self.boss_position + 400, 250, 200, 50),
            ground.Ground(self.boss_position + 1000, 250, 200, 50)
        ]

        for n in range(0, 100):
            self.ground.append(ground.Ground(200 * n, 650, 200, 50))

        self.ground.pop(len(self.ground) - 96)
        self.ground.pop(len(self.ground) - 95)
        self.ground.pop(len(self.ground) - 91)
        self.ground.pop(len(self.ground) - 90)
        self.ground.pop(len(self.ground) - 89)
        for n in range(10):
            self.ground.pop(len(self.ground) - (80 - n))
        self.ground.pop(len(self.ground) - 68)

        self.lo = [lo.Lo(600, 580, 140, 80), lo.Lo(7200, 580, 140, 80)]
        self.bjorn = bjorn.Bjorn(11000, 410, 140, 80, self.boss_position)

        self.boss_battle_ground = []
        self.bear_health = 3

        self.varg = [
            varg.Varg(1400, 580, 140, 80),
            varg.Varg(6800, 580, 140, 80)
        ]
        self.jarv = [
            jarv.Jarv(3800, 570, 140, 80),
            jarv.Jarv(8500, 580, 140, 80)
        ]

        self.prevent_movement = 0

        self.victory = False
        self.victory_img = pygame.image.load("img/winwin.png")
        self.victory_rect = self.victory_img.get_rect()

        self.hit_time = 0
        self.current_time = 0
        self.world_speed = 0.3

        self.snow = snow.Snow()
Example #10
0
import pygame
import csv
from itertools import chain

import ground as ground_class
import side_menu
import goo as goo_class
import weapons as weapon_class
import buildings as buildings_class
from screen import screen_width, screen_height, win

pygame.init()
main_font = pygame.font.SysFont("calibri", 20, bold=False)
pygame.display.set_caption("Gray goo by Kuba")

ground = ground_class.Ground()
goo = goo_class.Goo(ground.segment_width, ground.segment_step)
menu = side_menu.SideMenu()
weapons = weapon_class.Weapons()
buildings = buildings_class.Buildings()


def save_level():
    with open("level.csv", "w") as level_csv:
        fields = ["object_type", "x", "y", "width"]
        log_writer = csv.DictWriter(level_csv, fieldnames=fields)
        log_writer.writeheader()
        for segment in ground.segments:
            line_csv = segment.csv_data()
            log_writer.writerow(line_csv)
        for goo_pix in chain.from_iterable(goo.goo_grid):
Example #11
0
 def Update(self, dt, events, keys):
   self.age += dt
   progress = 1 - math.exp(-0.0003 * dt)
   # Remove this for awesome twisting.
   self.age *= 1 - progress
   if self.phase == 'seed' and self.age > 1500:
     self.game.ground = ground.Ground(self.game)
     self.game.AddDrawable(self.game.ground, 2)
     self.phase = 'sink'
     self.scroll_down = Scroller(self.game, 1.5)
     self.game.AddDrawable(self.scroll_down, 0)
   elif self.phase == 'sink':
     if self.scroll_down.done:
       self.phase = 'roots'
   elif self.phase == 'roots':
     if not self.active_root or not self.active_root.growing:
       r = root.Root(self.game, self.game.ground, self.x)
       self.roots.append(r)
       self.active_root = r
       self.game.AddDrawable(r, 2.5 + 0.001 * len(self.roots))
     if not pygame.mixer.music.get_busy():
       # TODO(alex): ugly
       self.active_root.growing = False
       self.phase = 'raise'
       self.scroll_up = Scroller(self.game, 0)
       self.game.AddDrawable(self.scroll_up, 0)
       pygame.mixer.music.load('music/grow.ogg')
       pygame.mixer.music.play()
   elif self.phase == 'raise':
     if self.scroll_up.done:
       for r in self.roots:
         self.game.RemoveDrawable(r)
       self.game.RemoveDrawable(self.game.ground)
       self.flower = Bud(self.game)
       self.game.Transition(self.game.SPRING)
       self.phase = 'bloom'
   elif self.phase == 'bloom':
     self.vcx -= 0.000001 * dt * (self.game.cx + self.x + 0.6)
     self.vcx *= math.exp(-0.002 * dt)
     self.game.cx = self.game.cx + dt * self.vcx
     if not pygame.mixer.music.get_busy():
       pygame.mixer.music.load('music/rain.ogg')
       pygame.mixer.music.play()
       self.game.Transition(self.game.RAIN)
       self.rains = []
       self.rain_x = self.x
       self.rain_vx = 0.001
       self.rain_time = 0
       self.rain_caught = 0
       self.phase = 'rain'
   elif self.phase == 'rain':
     if keys[pygame.K_RIGHT]: self.head_vx += 0.01 * dt
     if keys[pygame.K_LEFT]: self.head_vx -= 0.01 * dt
     self.head_vx *= math.exp(-0.01 * dt)
     self.head_x += dt * self.head_vx
     # Spawn rain.
     self.rain_time += dt
     while self.rain_time > 20:
       r = Rain(self.game, self, self.rain_x, 1.1 - Rain.vy * self.rain_time)
       self.rains.append(r)
       self.game.AddDrawable(r, 5)
       self.rain_time -= 20
     self.rain_x += dt * self.rain_vx
     self.rain_vx += 0.00001 * dt * (self.x - self.rain_x)
     for r in list(self.rains):
       if r.y < -1:
         r.Explode()
         self.rains.remove(r)
       else:
         d2 = (r.x - self.flower.x) ** 2 + (r.y - self.flower.y) ** 2
         if d2 < 0.02:
           r.Explode()
           self.rains.remove(r)
           self.rain_caught += 1
     while self.rain_caught >= 100:
       self.game.AddFairy(self.flower.x, self.flower.y)
       self.rain_caught -= 100
     if not pygame.mixer.music.get_busy():
       pygame.mixer.music.load('music/bee.ogg')
       pygame.mixer.music.play()
       self.game.Transition(self.game.SPRING)
       self.bee = bee.Bee(self.game, self.x, 1)
       self.game.AddDrawable(self.bee, 1.9)
       self.phase = 'bee'
       for r in self.rains:
         r.Explode()
       self.rains = []
   elif self.phase == 'bee':
     if not pygame.mixer.music.get_busy():
       pygame.mixer.music.load('music/ending.ogg')
       pygame.mixer.music.play()
       self.game.Transition(self.game.AUTUMN)
       self.phase = 'absorb'
     if keys[pygame.K_RIGHT]: self.bee.vx += 0.00001 * dt
     if keys[pygame.K_LEFT]: self.bee.vx -= 0.00001 * dt
     if keys[pygame.K_UP]: self.bee.vy += 0.00001 * dt
     if keys[pygame.K_DOWN]: self.bee.vy -= 0.00001 * dt
     d2 = (self.flower.x - self.bee.x) ** 2 + (self.flower.y - self.bee.y) ** 2
     if d2 < 0.01:
       self.bee.vx *= -1
       self.bee.vy *= -1
       self.game.AddDrawable(bee.Pollen(self.game, self.bee.x, self.bee.y, self.bee.vx, self.bee.vy), 1.9)
       f = self.game.AddFairy(self.bee.x, self.bee.y)
       f.vx = self.bee.vx
       f.vy = self.bee.vy
       # Try to make sure the bee doesn't get stuck.
       self.bee.x += dt * self.bee.vx
       self.bee.y += dt * self.bee.vy
       self.bee.vx += random.gauss(0, 0.001)
   elif self.phase == 'absorb':
     free_fairies = 0
     for f in list(self.game.drawable_to_depth):
       if isinstance(f, fairy.Fairy):
         f.dest = self.flower.x, self.flower.y
         d2 = (f.x - self.flower.x) ** 2 + (f.y - self.flower.y) ** 2
         if d2 < 0.01:
           self.game.RemoveDrawable(f)
           self.flower.seed_count += 1
         else:
           free_fairies += 1
     if free_fairies == 0:
       self.flower.BringSeeds()
       if self.flower.seeds:
         self.phase = 'seeds'
       else:
         self.phase = 'done'  # Game over.
   elif self.phase == 'seeds':
     if any(e.type == pygame.KEYDOWN for e in events):
       s = self.flower.seeds.pop(random.randrange(len(self.flower.seeds)))
       s.x = self.flower.x
       s.y = self.flower.y
       s.rot += self.flower.rot
       s.Fly(self.game)
       self.phase = 'done'
     if not pygame.mixer.music.get_busy():
       pygame.mixer.music.load('music/just_wind.ogg')
       pygame.mixer.music.play()
   elif self.phase == 'done':
     if self.game.cy == 1.5:  # Discard seeds in underground view.
       self.flower.seeds = []
     if abs(self.x + self.game.cx) > 2:  # Discard whole thing if off-screen.
       self.game.RemoveDrawable(self)
   if self.flower:
     self.wound = (1 - progress) * self.wound - progress * 0.00005
     self.flower.x, self.flower.y, self.flower.rot = self.BudPosition()
     self.flower.Update(dt, events, keys)
Example #12
0
def main():
    # constants throught program
    SCREEN_WIDTH = 800
    SCREEN_HEIGHT = 500
    BLACK = (0, 0, 0)
    WHITE = (255, 255, 255)
    RED = (255, 0, 0)

    pygame.init()
    mainsurface = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT), 0, 32)
    pygame.display.set_caption("Star Runner")

    # creates group, adds sprite to group and sets the position of the background
    backroundGroup = pygame.sprite.Group()
    mybackround = backround.Backround(mainsurface)
    mybackround.rect.topleft = (0, 0)
    mybackround.add(backroundGroup)

    # creates group, adds sprite to group and sets the position of the spaceship
    manGroup = pygame.sprite.Group()
    myman = man.Man(mainsurface)
    myman.rect.topleft = (50, 250)
    myman.add(manGroup)

    # creates group, adds sprite to group and sets the position of
    # the end line to delete sprites that are not on the screen
    endGroup = pygame.sprite.Group()
    myend = ground.End(mainsurface, RED)
    myend.rect.topleft = (-1, -4000)
    myend.add(endGroup)

    # creates group and defines mystar
    starGroup = pygame.sprite.Group()
    mystar = special.Special(mainsurface)

    # creates various sprite groups
    fireGroup = pygame.sprite.Group()
    finalGroup = pygame.sprite.Group()
    ememyGroup = pygame.sprite.Group()
    groundGroup = pygame.sprite.Group()

    thefire = fire.Fire(mainsurface, RED)
    # defines clock so frames per second can be set

    clock = pygame.time.Clock()

    # loads the music mixer and plays the backround music in a loop
    # music from http://www.thesoundarchive.com/star-wars.asp
    pygame.mixer.music.load("imperial_march.wav")
    pygame.mixer.music.play(-1)

    # while loop for start screen
    end_it = False
    while (end_it == False):

        # stes frames per second
        clock.tick(30)

        mainsurface.fill(BLACK)

        # defines various fonts for labels
        myfont = pygame.font.SysFont("Britannic Bold", 100)
        myfont1 = pygame.font.SysFont("Britannic Bold", 50)
        slabel1 = myfont.render("Star Runner", 1, (255, 0, 0))
        slabel2 = myfont1.render("Click or press space to Play", 1,
                                 (0, 0, 255))

        # sets and updates the x and y positions for the asteroids
        ypos = random.randint(0, 1200)
        xpos = (820)

        # sets up myground to be blit on screen
        myground = ground.Ground(mainsurface)
        myground.rect.topleft = (xpos, ypos)
        myground.add(groundGroup)

        # sets and updates the x and y positions for the rockets
        ypose = random.randint(0, 5000)
        xpose = (820)

        # sets up myenemy to be blit on screen
        myenemy = enemy.Enemy(mainsurface)
        myenemy.rect.topleft = (xpose, ypose)
        myenemy.add(ememyGroup)

        # adds backround and labels to screen
        mainsurface.blit(mybackround.image, mybackround.rect)
        mainsurface.blit(slabel1, (200, 100))
        mainsurface.blit(slabel2, (150, 200))

        # adds endline to screen to delete uneeded sprites
        for myend in endGroup:
            mainsurface.blit(myend.image, myend.rect)

        # adds rockets to screen and updates them
        for myenemy in ememyGroup:
            mainsurface.blit(myenemy.image, myenemy.rect)
            myenemy.update(groundGroup)
            myenemy.update(fireGroup)
        # adds asteroids to screen and updates them
        for myground in groundGroup:
            mainsurface.blit(myground.image, myground.rect)
            myground.update()

        # deletes uneeded sprites that are not on the screen
        myend.collide(ememyGroup)
        myend.collide(groundGroup)

        # ends start screen if mouse/spacebar is pressed
        for event in pygame.event.get():
            if event.type == MOUSEBUTTONDOWN or pygame.key.get_pressed()[
                    pygame.K_SPACE]:
                for myenemy in ememyGroup:
                    myenemy.remove(ememyGroup)
                for myground in groundGroup:
                    myground.remove(groundGroup)
                end_it = True
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            # used to pause/unpause music in game
            if (event.type == pygame.KEYDOWN):
                if (event.key == pygame.K_p):
                    pygame.mixer.music.pause()
                if (event.key == pygame.K_u):
                    pygame.mixer.music.unpause()
        pygame.display.update()
        pygame.display.flip()

    # main game loop
    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if (event.type == pygame.KEYDOWN):
                # adds projectile to screen when spacebar is pressed
                if (event.key == pygame.K_SPACE):
                    thefire.add(fireGroup)
                    thefire.rect.topleft = (myman.rect.left + 5,
                                            myman.rect.top + 10)
                # used to pause/unpause music in game
                if (event.key == pygame.K_p):
                    pygame.mixer.music.pause()
                if (event.key == pygame.K_u):
                    pygame.mixer.music.unpause()

        # sets frames per second in game
        clock.tick(30)

        # sets and updates the x and y positions for the asteroids
        ypos = random.randint(0, 2400)
        xpos = (920)

        # sets up myground to be blit on screen
        myground = ground.Ground(mainsurface)
        myground.rect.topleft = (xpos, ypos)
        myground.add(groundGroup)

        # sets and updates the x and y positions for the rockets
        ypose = random.randint(0, 10000)
        xpose = (920)

        # sets up myenemy to be blit on screen
        myenemy = enemy.Enemy(mainsurface)
        myenemy.rect.topleft = (xpose, ypose)
        myenemy.add(ememyGroup)

        pressed = pygame.key.get_pressed()

        # moves spaceship when arrow keys are pressed
        if pressed[pygame.K_LEFT]:
            myman.left()

        if pressed[pygame.K_RIGHT]:
            myman.right()

        if pressed[pygame.K_UP]:
            myman.up()

        if pressed[pygame.K_DOWN]:
            myman.down()

        # decreases health of spaceship if it hits the asteroids of the rockets
        myman.collide(groundGroup)
        myman.collide(ememyGroup)
        myman.collide_final(finalGroup)

        # deletes uneeded sprites that are not on the screen
        myend.collide(ememyGroup)
        myend.collide(groundGroup)

        # adds and updates level label if player gets enough points
        level = 1
        points = thefire.the_score
        if points >= 15:
            level += 1
        if points >= 30:
            level += 1
        if points >= 45:
            level += 1
        if points >= 60:
            level += 1
        if points >= 75:
            level += 1
        if points >= 90:
            level += 1
        if points >= 105:
            level += 1
        if points >= 120:
            level += 1
        if points >= 135:
            level += 1
        if points >= 150:
            level = "Final"
        scorefont = pygame.font.SysFont("Britannic Bold", 40)
        scorelable = scorefont.render("Score: {0}".format(points), 1, RED)
        levellable = scorefont.render("Level: {}".format(level), 1, RED)

        # defines labels for wining and loosing in the game
        overlable = myfont.render("Game Over", 1, (255, 0, 0))
        winlable = myfont.render("You Won!", 1, (255, 0, 0))
        mainscreenlable = scorefont.render(
            "Press Space to return to home screen", 1, (0, 0, 255))

        # defines lives and lives label
        lives = myman.lives
        liveslable = scorefont.render("Health:".format(lives), 1, RED)

        # adds backround image to screen
        mainsurface.blit(mybackround.image, mybackround.rect)

        # adds endline to delete uneeded sprites to screen
        for myend in endGroup:
            mainsurface.blit(myend.image, myend.rect)

        # adds rockets and updates them
        for myenemy in ememyGroup:
            mainsurface.blit(myenemy.image, myenemy.rect)
            myenemy.update(groundGroup)
            myenemy.update(fireGroup)

        # adds asteroids to screen and updates them
        for myground in groundGroup:
            mainsurface.blit(myground.image, myground.rect)
            myground.update()

        # adds projectile to screen
        for thefire in fireGroup:
            mainsurface.blit(thefire.image, thefire.rect)
            thefire.fire()
            thefire.collide_ground(groundGroup)

        # does needed actions if player wins the game
        # sound from https://www.freesound.org
        win = pygame.mixer.Sound("Ta_Da-SoundBible.wav")
        if points >= 200:
            myman.rect.top = 4000
            myman.rect.left = 4000
            mainsurface.blit(winlable, (200, 200))
            mainsurface.blit(mainscreenlable, (120, 275))
            pygame.mixer.music.stop()
            win.play()
            for myfinal in finalGroup:
                myfinal.remove(finalGroup)
            if pressed[pygame.K_SPACE]:
                main()
        # adds spaceship to screen
        mainsurface.blit(myman.image, myman.rect)

        # adds labels to screen
        mainsurface.blit(scorelable, (10, 10))
        mainsurface.blit(liveslable, (10, 473))
        mainsurface.blit(levellable, (630, 10))

        # makes game harder ass player gains points
        if points >= 15:
            for myground in groundGroup:
                myground.level_up()
        if points >= 30:
            for myenemy in ememyGroup:
                myenemy.level_up()
        if points >= 45:
            for myground in groundGroup:
                myground.level_up()
        if points >= 60:
            for myenemy in ememyGroup:
                myenemy.level_up()
        if points >= 75:
            for myground in groundGroup:
                myground.level_up()
        if points >= 90:
            for myenemy in ememyGroup:
                myenemy.level_up()
        if points >= 105:
            for myground in groundGroup:
                myground.level_up()
        if points >= 120:
            for myenemy in ememyGroup:
                myenemy.level_up()
        if points >= 135:
            for myground in groundGroup:
                myground.level_up()
        # sets up final level for game
        if points >= 150:
            for myenemy in ememyGroup:
                myenemy.remove(ememyGroup)
            for myground in groundGroup:
                myground.remove(groundGroup)
            y = random.randint(0, 2500)
            x = 920
            myfinal = final.Final(mainsurface)
            myfinal.rect.topleft = (x, y)
            myfinal.add(finalGroup)
            mainsurface.blit(myfinal.image, myfinal.rect)
            for myfinal in finalGroup:
                mainsurface.blit(myfinal.image, myfinal.rect)
                myfinal.update(manGroup)
            if thefire.collide_final(finalGroup):
                thefire.remove(fireGroup)
        # sets up star power-up at different points of the game
        if points == 15:
            mystar.rect.topleft = (920, random.randint(5, 495))
            mystar.add(starGroup)
        if points == 45:
            mystar.rect.topleft = (920, random.randint(5, 495))
            mystar.add(starGroup)
        if points == 75:
            mystar.rect.topleft = (920, random.randint(5, 495))
            mystar.add(starGroup)
        if points == 105:
            mystar.rect.topleft = (920, random.randint(5, 495))
            mystar.add(starGroup)
        if points == 135:
            mystar.rect.topleft = (920, random.randint(5, 495))
            mystar.add(starGroup)
        for mystar in starGroup:
            mainsurface.blit(mystar.image, mystar.rect)
            mystar.update()

        # adds lives if spaceship hits the star power-up
        myman.colide_2(starGroup, manGroup)
        pygame.draw.rect(mainsurface, (RED), (115, 480, lives, 15), 0)

        # deletes sprites and adds labels if player looses
        if lives <= 0:
            myman.rect.top = 4000
            myman.rect.left = 4000
            mainsurface.blit(overlable, (200, 200))
            mainsurface.blit(mainscreenlable, (120, 275))
            pygame.mixer.music.stop()
            if pressed[pygame.K_SPACE]:
                main()

        pygame.display.update()