Ejemplo n.º 1
0
def drawGameOver(screen, upg, eventtype):
    global quit
    pok.draw_text(1, 2, "Game Over...\n Score: " + str(score), 6)
    pok.draw_text(2, 3, "Game Over...\n Score: " + str(score), 7)
    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYUP:
            if eventtype.key == upg.BUT_C:
                initBricker()
            if eventtype.key == upg.BUT_B:
                quit = True
Ejemplo n.º 2
0
def drawWin(screen, upg, eventtype):
    global quit
    bouncy(screen)
    pok.draw_text(1, 2, "You Won!\n Score: " + str(score), 6)
    pok.draw_text(2, 3, "You Won!\n Score: " + str(score), 7)
    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYUP:
            if eventtype.key == upg.BUT_C:
                initBricker()
            if eventtype.key == upg.BUT_B:
                quit = True
Ejemplo n.º 3
0
def drawMenu(screen, upg, eventtype):
    global quit, menu
    bouncy(screen)
    pok.draw_text(1, 2, "Press `C`\n  to begin", 6)
    pok.draw_text(2, 3, "Press `C`\n  to begin", 7)
    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYUP:
            if eventtype.key == upg.BUT_C:
                initBricker()
                menu = False
            if eventtype.key == upg.BUT_B:
                quit = True
Ejemplo n.º 4
0
def playAst(screen, upg, eventtype, audio):
    global score, asteroids, health, shieldpercent, acc, dustParts, wait, best
    #Score logic
    score += 1

    # Start player movement
    moveP(upg, eventtype)
    #End player movement

    # Check player collide on asteroids
    for a in asteroids:
        if collide(x, y, a.x, a.y):
            screen.blit(sprites.danger, 1, 16)
    ###################################

    # Draw and move asteroids
    for a in asteroids:
        a.x, a.y, a.vx, a.vy = moveA(a.x, a.y, a.vx, a.vy)
        screen.blit(sprites.asteroid, a.x, a.y)
    ##########################

    # Check shields and health
    if shieldpercent > 0:
        screen.blit(sprites.shield, x - 2, y - 2)
        for slx in range(shieldpercent):
            screen.blit(sprites.shieldicon, slx + 15, 1)

    if health > 0:
        pok.draw_text(1, 5, str(score), 2)
        for hlx in range(health):
            screen.blit(sprites.healthicon, hlx, 1)

    if health < 0:
        print("ded")
        audio.play_sfx(sounds.lost, len(sounds.lost), True)
        if best < score:
            best = score
        wait = True
    ###############################

    # Draw rocket thrusters and dust particles
    screen.blit(sprites.rocket, x, y)
    if acc:
        screen.blit(sprites.thrusters, x + 2, y + 8)

    for i in dustParts:
        i["y"] = i["y"] + i["vy"]
        if i["y"] > 90:
            i["y"] = 0
            i["vy"] = rand.getrandbits(3) + 1
        screen.blit(sprites.dust, i["x"], i["y"])
Ejemplo n.º 5
0
def drawTitle(screen, upg, eventtype):
    global quit, title, boost, boost_time, index, position, time, speed, mult, current, cx, cy, cind, x, y, score, charge, dashing, best

    pok.draw_text(3, 2, "Explore the ocean  depths!", 6)
    pok.draw_text(3, 3, "Explore the ocean  depths!", 3)

    pok.draw_text(20, 70, "Best:\n     " + str(best), 6)
    pok.draw_text(20, 71, "Best:\n     " + str(best), 3)

    if time <= 5:
        index = 0
    if time <= 10 and time > 5:
        index = 1
    if time <= 15 and time > 10:
        index = 2
    if time <= 20 and time > 15:
        index = 1

    if time > 20:
        time = 0
    screen.blit(narwhal_sprites[index], 45, 25)

    screen.blit(enemies_sprites[0], 2, 38)
    screen.blit(enemies_sprites[1], 90, 38)

    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYDOWN:
            if eventtype.key == upg.BUT_B:
                quit = True
                title = False
                gameover = False
            else:
                title = False
                gameover = False
                initNarwhal()
Ejemplo n.º 6
0
def titleScreen():
    visible = 0
    #g_sound.play_from_sd("ufointro.snd")
    while True:
        urandom.getrandbits(30)
        eventtype = pygame.event.poll()
        if eventtype != pygame.NOEVENT and eventtype.type == pygame.KEYDOWN and eventtype.key == pygame.BUT_C:
            return
        screen.blit(back_sf, 0, 0)
        drawText(55 - 3 * 5, 40, "U.F.O.", 15, 5)
        if visible > 8:
            umachine.draw_text(55 - 3 * 5, 78, "Press C", 15)
        if visible == 16:
            visible = 0
        visible = visible + 1
        pygame.display.flip()
Ejemplo n.º 7
0
    def update(self):
        if self.D == True:
            self.image = upg.surface.Surface(self.w2, self.h2, pixelsDead)
        else:
            self.handleInput()
            # if your within the screen bounds change velocity
            if (self.rect.x + self.vx) <= 105 and (self.rect.x +
                                                   self.vx) >= -10:
                self.rect.x = self.rect.x + self.vx
                # deal with the forward boosting
                if self.rect.y > self.maxHeight:
                    self.rect.y = self.rect.y + self.vy
                if self.rect.y < 70 and self.A == False:
                    #print("hi")
                    self.rect.y = self.rect.y + 1

            #print number of boosts you have available
            umachine.draw_text(0, 0, str(self.B), 5)
Ejemplo n.º 8
0
def drawIntro(screen, upg, eventtype):
    global quit, introX, introY, introRocket, introThrusters, introvx, introvy, wait, Title

    rand.getrandbits(10)  #generate more randoms when starting
    screen.blit(sprites.Title, 0, 0)
    pok.draw_text(8, 62, "Press A", 2)
    pok.draw_text(8, 72, "Avoid The Toast!", 2)

    screen.blit(sprites.asteroid, 12, introY - 2)
    screen.blit(sprites.asteroid, 32, introY - 4)

    screen.blit(sprites.introRocket, introX, introY)
    screen.blit(sprites.introThrusters, introX - 4, introY + 2)
    if introX > 85:
        introvx = -1
    if introX < 60:
        introvx = 1
    if introY > 25:
        introvy = -1
    if introY < 15:
        introvy = 1
    introX = introX + introvx
    introY = introY + introvy

    if score > 0:
        pok.draw_text(8, 52, "Best: " + str(score), 2)
    if eventtype != upg.NOEVENT:
        if eventtype.key == upg.BUT_A:
            initToast()
            wait = False
        if eventtype.key == upg.BUT_B:
            quit = True
Ejemplo n.º 9
0
def draw_help(page):
    
    r=upg.Rect(0,0,scrwidth,scrheight+8)
    screen.fill(10,r)

    if page ==1:
        screen.blit(titlescreen.logo, 20, 2)
        print_shadow("Welcome to jetpack",2,20,3,8)
        print_shadow("you are a daring adventurer in search of precious gems. with your trusty jetpack\nyour quest is to take all the\ngems witout getting killed. collect treasure along the\nway to earn extra lives.\nfind fuel to make your\nsearch easier.",0,20+7,1,8)
    if page ==2:
        screen.blit(sprites.player8_3, 5, 5)
        screen.blit(sprites.player8_3l, 97, 5)
        print_border("Jetpack Model L1069-E",15,6,5,8)
        print_shadow("Your jetpack is a valuable\ntool in your quest for gems,\nfuel must be found before\nthe jet turbines will\nfunction",0,25,1,8)
    if page==3:
        print_shadow("Five different types of\nenemies will try to put an\nend to your quest",2,2,3,8)
        for i in range(5):
            r=upg.Rect(2,21+i*12,10,10)
            screen.fill(8,r)
            
        screen.blit(sprites.bot8_1, 3, 23)
        print_shadow("TRACKBOT",15,24,1,8)
        screen.blit(sprites.sball8, 3, 32+2)
        print_shadow("STEEL BALL",15,34+2,1,8)
        screen.blit(sprites.spring8_1, 3, 46)
        print_shadow("SPRING",15,48,1,8)
        screen.blit(sprites.missile8_Up, 3+1, 58)
        print_shadow("MISSILE",15,60,1,8)
        screen.blit(sprites.spikes8_1, 3+2, 72)
        print_shadow("SPIKES",15,72,1,8)
        
    if page==5:
        screen.blit(titlescreen.logo, 16, 2)
        umachine.draw_text(92,15,version,9)
        print_shadow("This game made by\n@bl_ackrain for the Pokitto\npython competition using the\nonline python editor",2,22,1,8)
        print_shadow("pyinsky.herokuapp.com",2,48,4,8)
        print_shadow("Thanks to @fmanga, @Hanski\nand @jonne for the fantastic Editor.",2,57,1,8)
Ejemplo n.º 10
0
def drawGameOver(screen, upg, eventtype):
    global title, gameover, cind, best, quit
    pok.draw_text(3, 2, "Game over...", 6)
    pok.draw_text(3, 3, "Game over...", 3)

    pok.draw_text(3, 12, "Best:\n " + str(best), 6)
    pok.draw_text(3, 13, "Best:\n " + str(best), 3)
    screen.blit(cind["spr"], 45, 24)
    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYDOWN:
            if eventtype.key == upg.BUT_B:
                quit = True
                title = True
                gameover = False
            else:
                title = True
                gameover = False
                initNarwhal()
Ejemplo n.º 11
0
def game_draw():
    
    level.draw()
    p1.draw()
    
    for bot in bots:
        bot.draw()
    for ball in balls:
        ball.draw()
    for spr in springs:
        spr.draw()
    for msl in missiles:
        msl.draw()
    for spk in spikes:
        spk.draw()
    
    r=upg.Rect(0,scrheight,scrwidth,8)
    screen.fill(11,r)
    umachine.draw_text(2,scrheight+1,"F:",1)
    r=upg.Rect(10-1,scrheight+1,20+2,5)
    screen.fill(8,r)
    r=upg.Rect(10,scrheight+2,p1.fuel//10,3)
    screen.fill(5,r)
    umachine.draw_text(37,scrheight+1,"Lives:"+str(p1.lives),1)
    umachine.draw_text(74,scrheight+1,"S:"+'{:07d}'.format(score),1)
    
    if level.newlvl:
        if level.t_new > 0:
            level.t_new -=1
            
            if level.t_new < 25:
                h=15
            else:
                h=(30-(level.t_new))*3
            
            r=upg.Rect(0,30,scrwidth,h)
            screen.fill(8,r)
            
            if h==15:
                umachine.draw_text(25,35,"Level : "+'{:02d}/{:02d}'.format(level.lvl_nmbr+1,len(levels)),1)
    
        else:
            level.newlvl=False
Ejemplo n.º 12
0
    def showInstructions(self, screen, colour, gameState, page1Images,
                         levelImages, page4Images):
        self.infoY = self.infoYStart

        if gameState == 2:
            for line in self.page1:
                umachine.draw_text(self.infoX, self.infoY, line, colour)
                self.infoY += self.ySpacing

            # Tiles
            screen.blit(levelImages[1], 10, 43)
            screen.blit(levelImages[1], 18, 43)
            screen.blit(levelImages[1], 26, 43)
            screen.blit(levelImages[0], 34, 43)
            screen.blit(levelImages[0], 42, 43)
            screen.blit(levelImages[0], 50, 43)
            screen.blit(levelImages[1], 58, 43)
            screen.blit(levelImages[1], 66, 43)
            screen.blit(levelImages[1], 74, 43)

            screen.blit(levelImages[0], 10, 62)
            screen.blit(levelImages[0], 18, 62)
            screen.blit(levelImages[0], 26, 62)
            screen.blit(levelImages[1], 34, 62)
            screen.blit(levelImages[1], 42, 62)
            screen.blit(levelImages[1], 50, 62)
            screen.blit(levelImages[0], 58, 62)
            screen.blit(levelImages[0], 66, 62)
            screen.blit(levelImages[0], 74, 62)

            screen.blit(levelImages[1], 10, 80)
            screen.blit(levelImages[1], 18, 80)
            screen.blit(levelImages[1], 26, 80)
            screen.blit(levelImages[0], 34, 80)
            screen.blit(levelImages[0], 42, 80)
            screen.blit(levelImages[0], 50, 80)
            screen.blit(levelImages[1], 58, 80)
            screen.blit(levelImages[1], 66, 80)
            screen.blit(levelImages[1], 74, 80)

            # Moby
            screen.blit(page1Images[0], 40, 46, 0, True)

            # Arrow up/down
            screen.blit(page1Images[3], 42, 30)
            screen.blit(page1Images[3], 42, 67, 0, False, True)

        elif gameState == 3:
            for line in self.page2:
                umachine.draw_text(self.infoX, self.infoY, line, colour)
                self.infoY += self.ySpacing

            # Draw graphic
            screen.blit(levelImages[0], 20, 52)
            screen.blit(levelImages[0], 28, 52)
            screen.blit(levelImages[0], 36, 52)
            screen.blit(levelImages[1], 44, 52)
            screen.blit(levelImages[1], 52, 52)
            screen.blit(levelImages[1], 60, 52)
            screen.blit(levelImages[0], 68, 52)
            screen.blit(levelImages[0], 76, 52)
            screen.blit(levelImages[0], 84, 52)

            screen.blit(levelImages[1], 20, 70)
            screen.blit(levelImages[1], 28, 70)
            screen.blit(levelImages[1], 36, 70)
            screen.blit(levelImages[0], 44, 70)
            screen.blit(levelImages[0], 52, 70)
            screen.blit(levelImages[0], 60, 70)
            screen.blit(levelImages[1], 68, 70)
            screen.blit(levelImages[1], 76, 70)
            screen.blit(levelImages[1], 84, 70)

            # Moby
            screen.blit(page1Images[0], 50, 54)

            # Arrows left/right
            screen.blit(page1Images[1], 21, 59)
            screen.blit(page1Images[1], 35, 59)
            screen.blit(page1Images[1], 66, 41)
            screen.blit(page1Images[1], 80, 41)

            screen.blit(page1Images[2], 66, 59)
            screen.blit(page1Images[2], 80, 59)
            screen.blit(page1Images[2], 21, 77)
            screen.blit(page1Images[2], 35, 77)

        elif gameState == 4:
            for line in self.page3:
                umachine.draw_text(self.infoX, self.infoY, line, colour)
                self.infoY += self.ySpacing

            # Draw graphic
            screen.blit(page4Images[0], 4, 51)  # freeze
            screen.blit(page4Images[1], 15, 61)  # life
            screen.blit(page4Images[2], 57, 30)  # time
            screen.blit(page4Images[3], 4, 39)  # bonus
            screen.blit(page4Images[4], 54, 10)  # imp
Ejemplo n.º 13
0
    def updateAndRender(self):
        """main play loop"""
        screen_sf = upg.display.set_mode()

        #create groups for the sprites
        enemy_sprites = sprite.Group()
        nice_sprites = sprite.Group()

        #choose correct info for the level
        timer, numC, freqC, numRl, freqRl, numRr, freqRr, numU, freqU = self.levelInfo(
        )

        #create comets, rockets and ufo sprites
        all_comets = sprite.Group()
        self.enemyCreator(1, numC, 100, 100, all_comets, enemy_sprites)
        all_rocketsL = sprite.Group()
        self.enemyCreator(2, numRl, -100, -100, all_rocketsL, enemy_sprites)
        all_rocketsR = sprite.Group()
        self.enemyCreator(3, numRr, 150, -100, all_rocketsR, enemy_sprites)
        all_ufo = sprite.Group()
        self.enemyCreator(4, numU, 100, 100, all_ufo, enemy_sprites)

        #create player and background sprites
        player = Player()
        nice_sprites.add(player)

        #create background
        bkg1, bkg2, bkg3, bkg4 = background(), background2(), background3(
        ), background4()
        nice_sprites.add(bkg1, bkg2, bkg3, bkg4)

        while True:
            #check for collisions
            hit = sprite.spritecollideany(player, enemy_sprites)
            if hit != None:
                player.D = True
                while self.deathTimer < 25:
                    nice_sprites.update()
                    nice_sprites.draw(screen_sf)
                    upg.display.flip()
                    self.deathTimer += 1
                return cs.state(2, gv.level)

            #draw the timer
            timer -= self.ticker
            umachine.draw_text(90, 0, str(timer), 3)
            #when time gets to zero go to next level
            if timer == 0:
                if gv.level < 5:
                    return cs.state(4, gv.level)
                if gv.level == 5:
                    return cs.state(3, gv.level)

            #place the enemies
            self.cometPlacer(freqC, all_comets)
            self.rocketPlacer(freqRl, all_rocketsL, True)
            self.rocketPlacer(freqRr, all_rocketsR, False)
            self.cometPlacer(freqU, all_ufo)

            #update sprites and draw 'em
            nice_sprites.update()
            nice_sprites.draw(screen_sf)
            enemy_sprites.update()
            enemy_sprites.draw(screen_sf)

            upg.display.flip()

            #count framenums
            self.frameNum += 1
            if self.frameNum > 1000000:
                self.frameNum = 0
Ejemplo n.º 14
0
def print_shadow(txt,x,y,cf,cb):
    
    umachine.draw_text(x,y+1,txt,cb) 
    umachine.draw_text(x,y,txt,cf) 
Ejemplo n.º 15
0
def playBricker(screen, upg, eventtype, audio):
    global life, paddle, active, ball, bricks, particles, score, game_over, win
    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYDOWN:
            if eventtype.key == upg.K_RIGHT or eventtype.key == upg.BUT_A:
                paddle["xs"] = 5
            if eventtype.key == upg.K_LEFT or eventtype.key == upg.BUT_B:
                paddle["xs"] = -5
        if eventtype.type == upg.KEYUP:
            if eventtype.key == upg.BUT_C:
                if active is False:
                    active = True
                    ball["xs"] = rand.getrandbits(2) - 1
                    if ball["xs"] is 0:
                        ball["xs"] = -3
                    ball["ys"] = -2
            if eventtype.key == upg.K_RIGHT or eventtype.key == upg.BUT_A:
                paddle["xs"] = 0
            if eventtype.key == upg.K_LEFT or eventtype.key == upg.BUT_B:
                paddle["xs"] = 0

    #Collision checks
    for x in list(bricks):
        if collide(ball["x"], ball["y"], x["x"], x["y"]):
            ball["ys"] = -ball["ys"]
            part = {"x": (ball["x"] + 1), "y": ball["y"]}
            particles.append(part)
            bricks.remove(x)
            audio.play_sfx(sounds.high, len(sounds.high), True)

    for x in list(particles):
        x["y"] = x["y"] - 1
        if collideT(x["x"], x["y"], paddle["x"], paddle["y"]):
            particles.remove(x)
            score = score + 10
        else:
            screen.blit(sprites.particle, x["x"], x["y"])

    if collideP(ball["x"], ball["y"], paddle["x"], paddle["y"]):
        ball["ys"] = -ball["ys"]
        audio.play_sfx(sounds.low, len(sounds.low), True)

    #Updating positions
    if ball["x"] > 106:
        ball["xs"] = -ball["xs"]
        audio.play_sfx(sounds.mid, len(sounds.mid), True)
    if ball["x"] < 1:
        ball["xs"] = -ball["xs"]
        audio.play_sfx(sounds.mid, len(sounds.mid), True)
    if ball["y"] > 84:
        ball["ys"] = -ball["ys"]
        audio.play_sfx(sounds.mid, len(sounds.mid), True)
    if ball["y"] < 1:
        active = False
        if life > 0:
            score = score - 10
            life = life - 1
        else:
            audio.play_sfx(sounds.lost, len(sounds.lost), True)
            game_over = True

    if active is False:
        ball["xs"] = 0
        ball["ys"] = 0
        ball["x"] = paddle["x"] + 13
        ball["y"] = paddle["y"] + 4

    if paddle["x"] + 28 > 106 and paddle["xs"] > 0:
        paddle["xs"] = 0
    if paddle["x"] - 4 < 1 and paddle["xs"] < 0:
        paddle["xs"] = 0

    ball["x"] = ball["x"] + ball["xs"]
    ball["y"] = ball["y"] + ball["ys"]
    paddle["x"] = paddle["x"] + paddle["xs"]

    #Drawing
    if len(bricks) is 0:
        win = True
        audio.play_sfx(sounds.success, len(sounds.success), True)

    for x in range(life):
        screen.blit(sprites.Ball, x * 4, 1)
    screen.blit(sprites.Ball, ball["x"], ball["y"])
    screen.blit(sprites.Paddle, paddle["x"], paddle["y"])
    for b in bricks:
        screen.blit(b["img"], b["x"], b["y"])

    pok.draw_text(1, 80, "Score: " + str(score), 6)
    pok.draw_text(2, 81, "Score: " + str(score), 7)
Ejemplo n.º 16
0
    def showVersion(self):
        global version

        umachine.draw_text(1, 1, "v0." + str(version), 9)
Ejemplo n.º 17
0
 def draw (self):
     if (self.timer > 0):
         umachine.draw_text(self.x, self.y, self.text, 15)
Ejemplo n.º 18
0
Archivo: main.py Proyecto: jvdw008/efmp
def render():
    global levelComplete, rndLevel, levelImages, flashPlayer, flashTime, flashTimeMax
    
    # Render instruction pages
    if gameState >= STATE_INSTRUCTIONS and gameState < STATE_GAME:
        instructions.showInstructions(screen, 2, gameState, instructionsGraphic1, levelImages[0], instructionsGraphic4)
        
    # Render splash
    if gameState == STATE_MENU:
        screen.blit(graphics.g_splash.splash, 0, 0)
        umachine.draw_text(86, 81, "v0." + str(version), 2)
    
    # Render game
    elif gameState == STATE_GAME:
        # Render platforms
        aLevel.drawLevel(screen, levelImages[rndLevel])
        
        # Render imps
        for localImp in levelImps:
            # Update anims
            if localImp.getState():
                tmpImpType = localImp.getType()
                tmpImpPos = localImp.getPosition()
                tmpImpVisible = localImp.getState()
                if tmpImpVisible:
                    if tmpImpType == 0:
                        imp1Anim.draw(screen, tmpImpPos[0], tmpImpPos[1], 1)
                    elif tmpImpType == 1:
                        imp2Anim.draw(screen, tmpImpPos[0], tmpImpPos[1], 1)
                    elif tmpImpType == 2:
                        imp3Anim.draw(screen, tmpImpPos[0], tmpImpPos[1], 1)
                    elif tmpImpType == 3:
                        imp4Anim.draw(screen, tmpImpPos[0], tmpImpPos[1], 1)
                    elif tmpImpType == 4:
                        imp5Anim.draw(screen, tmpImpPos[0], tmpImpPos[1], 1)
                    else:
                        imp6Anim.draw(screen, tmpImpPos[0], tmpImpPos[1], 1)
        
        if not levelComplete:
            
            # Display bonus items if on screen
            for localItem in bonusItem:
                localitemPos = localItem.getPosition()
                if localItem.getType() == 0:
                    item_stop.draw(screen, localitemPos[0], localitemPos[1], 1)
                    
                elif localItem.getType() == 1:
                    item_heart.draw(screen, localitemPos[0], localitemPos[1], 1)
                
                elif localItem.getType() == 2:
                    item_clock.draw(screen, localitemPos[0], localitemPos[1], 1)
                    
                else:
                    item_bonus.draw(screen, localitemPos[0], localitemPos[1], 1)
                    
            # Render enemies
            for localEnemies in lvlEnemies:
                localEnemyPos = localEnemies.getEnemyPos()
                if localEnemies.getType() == 0:
                    enemy1.draw(screen, localEnemyPos[0], localEnemyPos[1], localEnemies.getDirection())
                    
                elif localEnemies.getType() == 1:
                    enemy2.draw(screen, localEnemyPos[0], localEnemyPos[1], localEnemies.getDirection())
                    
                else:
                    enemy3.draw(screen, localEnemyPos[0], localEnemyPos[1], localEnemies.getDirection())
                    
            # Render bullet
            if bulletVisible:
                if bulletDir > 0:
                    screen.blit(bullet, bulletX, bulletY)
                else:
                    screen.blit(bullet, bulletX, bulletY, 0, True)
            
        # Lives
        screen.blit(numbers[playerLives], 0, 0)
        screen.blit(livesImg, 10, 0)
        
        # Timer
        if timer.getTime() < 0:
            umachine.draw_text(74, 1, "Time up!", 2)
        else:
            timer.drawTime(screen, numbers, 92, 0, 8)      # x, y, fontspace
            
        # Flash text
        flashText.draw()
        
        # Score/Imps collected
        if score < 10:
            umachine.draw_text(20, 1, "00", 2)
            umachine.draw_text(30, 1, str(score), 2)
        elif score < 100:
            umachine.draw_text(20, 1, "0", 2)
            umachine.draw_text(27, 1, str(score), 2)
        else:
            umachine.draw_text(20, 1, str(score), 2)
        
        # Render player
        if levelComplete:
            # Warp image
            player.draw(screen, playerWarp)
            
            # Render level complete
            umachine.draw_text(30, 41, "Level clear!", 2)
            
        else:
            # Flash player counter if player hit
            if flashPlayer:
                if flashTime > 0:
                    flashTime -= 1
                else:
                    flashTime = flashTimeMax
                    flashPlayer = False
                    
                # Also draw imp splash
                player.drawImpSplash(screen, impImages[impId])
                
            # Draw player
            if flashTime % 2 == 0:
                if movePlayerX != 0:
                    playerPos = player.getPlayerPos()
                    playerAnimWalk.draw(screen, playerPos[0], playerPos[1], movePlayerX)    # Anim when moving
                else:
                    player.draw(screen, playerIdle) # Otherwise just draw idle image
            
    # Render imp screen
    elif gameState == STATE_IMPSCREEN:
        levelImps[0].drawStats(screen, level + 1)
        
    # Render game over
    elif gameState == STATE_GAMEOVER:
        umachine.draw_text(35, 20, "Game over", 2)
        umachine.draw_text(12, 30, "Your final score was", 12)
        umachine.draw_text(50, 40, str(score), 13)
Ejemplo n.º 19
0
def render():

    ######################################
    # Menu state
    ######################################
    if gameState == STATE_MENU:
        # Logo
        screen.blit(logo, 0, 0 + shakeY)

        # Version
        modV = version % 10
        umachine.draw_text(83, 80, "v" + str(version // 10) + "." + str(modV),
                           2)

        # Info
        centerText("Use A to jump", 25, 3)

        # Text
        centerText("A: Start game", 35, 9)
        centerText("C: Pause game", 45, 9)

        # Scores
        centerText("Best distance:", 60, 2)
        centerText(str(highscore) + " meters", 70, 1)

    ######################################
    # Game state
    ######################################
    elif gameState == STATE_GAME:

        # Distant bg
        screen.blit(gameBg2, 0, 5 + shakeY)

        # Smoke plume
        if smokePos[0] > -32:
            screen.blit(smoke, smokePos[0], smokePos[1] + shakeY)

        # Draw monster
        screen.blit(monsterImg, monsterPos[0], monsterPos[1] + shakeY)
        # And lasers
        if monsterPos[2]:
            pygame.draw.line(monsterPos[0] + 15, monsterPos[1] + 2 + shakeY,
                             monsterPos[0] - 20, monsterPos[1] + 50 + shakeY,
                             3)
            pygame.draw.line(monsterPos[0] + 15, monsterPos[1] + 2 + shakeY,
                             monsterPos[0] - 40, monsterPos[1] + 40 + shakeY,
                             3)

        # Game bg
        screen.blit(gameBg, 0, -10 + shakeY)

        # Draw buildings
        ######################################
        for building in buildingList:
            building.drawBuilding(screen, floors, windows, walls, shakeY)

    # Display score
    ######################################
        umachine.draw_text(0, 1, str(score) + "m", 1)

        # Draw player anim
        ######################################
        playerAnim.draw(screen,
                        player.getPlayerPos()[0],
                        player.getPlayerPos()[1], shakeY)

        # Draw objects
        for obj in objectList:
            obj.draw(screen, shakeY)

        # Draw pigeons
        for bird in pigeonList:
            if not bird.getStatus():
                # Static sitting bird
                bird.draw(screen, shakeY)
            else:
                # Anim birds
                for anim in birdAnimList:
                    anim.draw(screen,
                              bird.getPosition()[0],
                              bird.getPosition()[1], 0)

    ######################################
    # Pause state
    ######################################
    elif gameState == STATE_PAUSE:
        centerText("Paused", 30, 1)
        centerText("A: Continue", 50, 9)

    ######################################
    # Game over state
    ######################################
    elif gameState == STATE_GAMEOVER:
        screen.blit(gameOverBg, 0, gameOverY)

        centerText("Game over", 10, 1)
        centerText("You reached:", 20, 1)
        centerText(str(score) + " meters", 38, 1)
        centerText("until you hit", 48, 1)
        centerText(str(deathCause), 58, 1)
        centerText("A: Menu", 78, 9)
Ejemplo n.º 20
0
def render():
    global playerFlashing, playerFlashTimer, playerFlashTimerMax, dropImages
    global playerX, playerY

    if gameState == STATE_MENU:
        screen.blit(gameBg, 0, 0)
        screen.blit(logo, logoX, logoY)
        umachine.draw_text(42, 70, "A: START", 1)
        umachine.draw_text(45, 78, "B: INFO", 1)
        umachine.draw_text(88, 82, "v0." + str(version), 2)

    elif gameState == STATE_INSTRUCTIONS:
        screen.blit(dropImages[2], 10, 43)
        screen.blit(dropImages[1], 10, 58)
        screen.blit(dropImages[0], 10, 73)

        textY = 0
        for i in range(len(instructions)):
            umachine.draw_text(0, textY, instructions[i], 1)
            if i < 4:
                textY += 8
            else:
                textY += 7

    elif gameState == STATE_GAME:
        #######################
        # Background
        #######################
        drawBackground(gameBg, screenXOffset, screenWidth)
        #######################
        # Sun
        #######################
        screen.blit(sun, sunPos, 0)
        #######################
        # Clouds
        #######################
        drawClouds(clouds, cloudsPos, screenWidth)
        #######################
        # Mountains
        #######################
        drawMountains(mountains, screenXOffset, screenWidth)
        #######################
        # Kitteh boat
        #######################
        screen.blit(kittyboat, kittyBoatX, kittyBoatY)
        #######################
        # Waves
        #######################
        waves.draw(screen, waveX - screenWidth, 19)
        waves.draw(screen, waveX, 19)
        waves.draw(screen, waveX + screenWidth, 19)
        #######################
        # Interface
        #######################
        screen.blit(interface, 0, 0)
        #######################
        # Score
        #######################
        rightOffset = 6 * len(str(score))
        umachine.draw_text(40 - rightOffset, 0, str(score), 1)
        #######################
        # Draw Lives
        #######################
        heartX = 70
        heartY = 1
        for i in range(6):
            if i < lives:
                screen.blit(life[1], heartX, heartY)
            else:
                screen.blit(life[0], heartX, heartY)

            heartX += 8
        #######################
        # Draw powershots bar
        #######################
        tmpPsLoop = powerShots  #int(powerShots // 2)
        tmpPsX = 13
        tmpPsY = 9
        for i in range(5):
            if i < tmpPsLoop:
                screen.blit(powerBulletBar[0], tmpPsX, tmpPsY)
            else:
                screen.blit(powerBulletBar[1], tmpPsX, tmpPsY)
            tmpPsX += 3

        ######################~
        # Draw milk stations
        #######################
        for i in range(len(milkStations)):
            screen.blit(milkStation, milkStations[i], 63)

        #######################
        # Draw kitteh if alive
        #######################
        for kitteh in kittyList:
            kitteh.draw(screen, kitty)

        #######################
        # Draw enemies
        #######################
        for enemy in enemyList:
            tmpEnemyPos = enemy.getPos()
            enemy.draw(screen)

        #######################
        # Draw player
        #######################
        if playerFlashing:
            if playerFlashTimer > 0:
                playerFlashTimer -= 1
                if playerFlashTimer % 2 == 0:
                    player.draw(screen, playerShip)
            else:
                # Reset flash timer
                playerFlashing = False
                playerFlashTimer = playerFlashTimerMax
        else:
            player.draw(screen, playerShip)

        playerPos = player.getPlayerPos()
        playerY = playerPos[1]

        #######################
        # Draw enemy bullets
        #######################
        for playerBullet in playerBullets:
            playerBullet.draw(screen)

        #######################
        # Draw dropped item
        #######################
        for i in range(len(dropItem)):
            screen.blit(dropImages[dropItem[i][2]], dropItem[i][0],
                        dropItem[i][1])

        #######################
        # Draw explosion
        #######################
        for explody in explosionList:
            explody.draw(screen, explosionFrames)

        #######################
        # Draw pops
        #######################
        for pops in popList:
            pops.draw(screen, popFrames)

        #######################
        # Enemies on screen
        umachine.draw_text(56, 1, str(len(enemyList)), 1)

        #######################
        # Draw cat-nav radar
        #######################
        catnavX = 0
        catnavY = 74
        catnavWidth = 44
        catnavHeight = 13
        aspectRatioX = mapSize // catnavWidth
        aspectRatioY = 70 // catnavHeight
        pygame.draw.rect(
            pygame.Rect(catnavX, catnavY, catnavWidth, catnavHeight), False, 1)
        tmpEnCtr = 0
        tmpPlyX = (playerPos[0] // aspectRatioX) + (catnavWidth // 2 - 4)
        tmpPlyY = catnavY + (playerPos[1] // aspectRatioY) - 3
        pygame.draw.pixel(catnavX + tmpPlyX, tmpPlyY, 6)
        for enemy in enemyList:

            tmpEnemyPos = enemy.getPos()
            tmpX = (tmpEnemyPos[0] // aspectRatioX) + (catnavWidth // 2 - 4)
            if tmpX < 0:
                tmpX += catnavWidth

            if tmpX > catnavWidth:
                tmpX += -catnavWidth

            tmpY = catnavY + (tmpEnemyPos[1] // aspectRatioY) - 3
            if tmpY > catnavY:
                pygame.draw.pixel(catnavX + tmpX, tmpY, 1)

            if enemy.getType() == 2:
                if tmpY > catnavY:
                    pygame.draw.pixel(catnavX + tmpX, tmpY, 7)

                    if enemy.getAbductingState():
                        pygame.draw.circle(catnavX + tmpX, tmpY, 2, False, 1)
            else:
                pygame.draw.pixel(catnavX + tmpX, tmpY, 1)

            tmpEnCtr += 1

        #######################
        # Game over
        #######################
        if gameOver:
            screen.blit(gameoverBG, 14, 20)
            umachine.draw_text(22, 34, "OH NOES...", 13)
            umachine.draw_text(22, 41, "FISH THAT", 13)
            umachine.draw_text(22, 48, "KITTY OUT,", 13)
            umachine.draw_text(22, 55, "TRY AGAIN", 13)

        #######################
        # Level complete?
        #######################
        if levelComplete and not gameOver:
            screen.blit(levelCompleteBG, 14, 20)
            umachine.draw_text(22, 34, "Miners saved:", 1)
            startKittyX = 25
            startKittyY = 44
            for i in range(len(kittyList)):
                screen.blit(kitty, startKittyX, startKittyY)
                startKittyX += 18

            umachine.draw_text(32, 60, "Bonus: " + str(len(kittyList) * 2000),
                               1)
Ejemplo n.º 21
0
    if gameState == 0:  #Show title screen and initialze the game
        titleScreen()
        initializeStars()
        initializeUFO()
        startTime = umachine.time_ms()
        remainingTime = 120
        score = 0
        gameState = 1
    elif gameState == 1:  #Play the game
        if (umachine.time_ms() - startTime) >= 1000:
            remainingTime = remainingTime - 1
            startTime = umachine.time_ms()
        if remainingTime == 0:
            gameState = 2
        screen.blit(timeIndicator_sf, 40, 1)
        umachine.draw_text(55 - 1 * 5, 2, str(remainingTime), 15)
        drawNebula()
        updateStarsPosition()
        drawStars()
        drawUFO()
        if explosionState > 0:
            drawExplosion()
        else:
            updateUFOPosition()

        pollButtons()
        drawPlayerShip()
        screen.fill(14, gunRect)
    elif gameState == 2:  #Game Over
        drawRobot()
Ejemplo n.º 22
0
    # Mirror dot1, 3-way
    screen.blit(dotGob.image, screenW - dotGob.rect.x, dotGob.rect.y)
    screen.blit(dotGob.image, screenW - dotGob.rect.x, screenH - dotGob.rect.y)
    screen.blit(dotGob.image, dotGob.rect.x, screenH - dotGob.rect.y)

    # Animate dot2 to go horizontally
    x = dot2Gob.rect.x
    x -= 1
    if (x < -10):
        x = 110 + 2
    dot2Gob.rect.x = x
    screen.blit(dot2Gob.image, dot2Gob.rect.x, dot2Gob.rect.y)

    all_ships.update()
    all_ships.draw(screen)

    # Animate text to go vertically
    if (frameNum % 2 == 0):
        y = textY
        y += 1
        if (y > screenH - 10):
            y = 0
        textY = y
    pok.draw_text(textX, textY, "PokittoScope", 14)

    pygame.display.flip()

    frameNum += 1
    if frameNum > 1000000:
        frameNum = 0
Ejemplo n.º 23
0
 def draw(self):
     if (self.duration > 0):
         umachine.draw_text(self.x, self.y, self.text, 2)
Ejemplo n.º 24
0
                play = True
            if eventtype.key == upg.K_RIGHT or eventtype.key == upg.K_DOWN:
                if gameSelect < 3:
                    gameSelect = gameSelect + 1
            if eventtype.key == upg.K_LEFT or eventtype.key == upg.K_UP:
                if gameSelect > 1:
                    gameSelect = gameSelect - 1
    if not play:

        if gameSelect == 1:
            upg.display.set_palette_16bit([
                0xffff, 0x03bb, 0xf017, 65535, 0x5acb, 0x07e8, 0x0000, 0xf800
            ])
            screen.fill(1, upg.Rect(0, 0, 110, 88))

            pok.draw_text(1, 1, "Tor's Game Gallery", 6)
            pok.draw_text(2, 2, "Tor's Game Gallery", 3)
            pok.draw_text(1, 12, "Press `C` to play:\n\nMecha Narwhal", 6)
            pok.draw_text(2, 13, "Press `C` to play:\n\nMecha Narwhal", 3)
            screen.blit(sprites.narwhal_sprites[3], 40, 45)
            screen.blit(sprites.enemies_sprites[0], 20, 45)
            screen.blit(sprites.enemies_sprites[1], 75, 45)

        if gameSelect == 2:
            upg.display.set_palette_16bit([
                0,
                4124,
                0xd819,
                65535,
                0xf807,
                0xfe8c,
Ejemplo n.º 25
0
def render():
    screen.blit(bg, 0 + shakeX, 0)
    
    # Always draw stars
    for star in starList:
        star.draw(shakeX)
    
    # Always draw rocks
    for boulders in rockList:
        boulders.draw(screen, rockImages, shakeX)
        
    ######################################
    # Menu state
    ######################################
    if gameState == STATE_MENU:
        
        # Logo
        screen.blit(logo, 3, 5)
        
        # Version
        modV = version % 10
        umachine.draw_text(3, 25, "v0." + str(version // 10) + "." + str(modV), 12)
        
        # Text
        umachine.draw_text(40, 30, "A: Arcade", 1)
        umachine.draw_text(40, 38, "B: Survival", 1)
        umachine.draw_text(40, 46, "C: Info", 1)
        
        # Info
        umachine.draw_text(40, 55, "In-game:", 8)
        umachine.draw_text(5, 63, "A: fire, B: bomb, C: pause", 8)
        
        # Scores
        umachine.draw_text(40, 72, "Highscore:", 10)
        drawScore(40, 82, highscore)
            
    ######################################
    # Game state
    ######################################
    elif gameState == STATE_GAME:
        # Draw crystals
        for crystal in crystalList:
            crystal.draw(screen, crystalImages, shakeX)
        
        # Display score
        umachine.draw_text(0, 1, "S:", 1)
        drawScore(10, 2, score)
        
        # Health
        if gameMode == 0:
            umachine.draw_text(0, 80, "H:", 1)
            drawHealth(10, 81, health)
        
        # Display bomb count
        umachine.draw_text(80, 80, "Bmb:", 1)
        drawCounter(100, 81, bombs)
        
        # Display bullet count
        umachine.draw_text(55, 80, "Bul:", 1)
        drawCounter(70, 81, bulletCount)
        
        # Drops
        for dropItem in dropList:
            dropItem.draw(screen, shakeX, dropImages)
        
        # Bullet
        for bul in bulletList:
            bul.draw(screen, shakeX, bulletImages)
        
        # Draw enemies
        for en in enemyList:
            en.draw(screen, shakeX, enemyShipImages)
        
        # Draw bosses
        for boss in bossList:
            boss.draw(screen, shakeX, bossShipImages)
        
        # Draw shuttle
        if (shuttle[2]):
            screen.blit(shuttleShip, shuttle[0] + shakeX, shuttle[1])
            
        # Draw spacemane
        if (spaceman[2]):
            screen.blit(dropImages[3], spaceman[0] + shakeX, spaceman[1])
        
        # Draw player ship flames
        for flame in flameList:
            flame.draw(shakeX)
            
        # Draw player
        player.draw(screen, playerShip, shakeX)
        
        # Draw explosion
        for explody in explosionList:
            explody.draw(screen, explosionFrames)
    
    ######################################
    # Game over state
    ######################################
    elif gameState == STATE_GAMEOVER:
        umachine.draw_text(40, 30, "Game over", 1)
        umachine.draw_text(12, 38, "Your final score was:", 10)
        drawScore(40, 48, score)
        umachine.draw_text(40, 60, "C: Menu", 1)
        

    elif gameState == STATE_INSTRUCTIONS:
        instructions.showInstructions(umachine, [4, 7, 2])
    
    elif gameState == STATE_PAUSE:
        umachine.draw_text(30, 30, "Game paused", 11)
        umachine.draw_text(20, 40, "A or C to resume", 1)
Ejemplo n.º 26
0
 def drawStats(self, screen, level):
     screen.blit(self.image, 50, 20)  # Image
     umachine.draw_text(40, 0, "LEVEL: " + str(level), 12)
     umachine.draw_text(40, 30, self.getName(), 2)
     umachine.draw_text(0, 50, "HABITAT: " + self.getHabitat(), 15)
     umachine.draw_text(4, 58, "TEMPER: " + self.getTemper(), 13)
     umachine.draw_text(14, 66, "EATS: " + self.getEats(), 14)
     umachine.draw_text(4, 74, "STATUS: " + self.getStatus(), 10)
Ejemplo n.º 27
0
            interface.playGameOver()
            gameOverPlayed = True
    else:
        # Start randomizing on menu
        faces.randomizeFace()

    # Render
    screen.fill(0)  # Clear screen

    # Menu
    if (gameState == 0):
        if (showInstructions == True):
            interface.showInstructions()
        else:
            logo.drawLogo()
            umachine.draw_text(40, 20, "A: START", 4)
            umachine.draw_text(40, 27, "B: INFO (hold)", 4)
            umachine.draw_text(2, 34, "MUSIC: Left(on) Right(off)", 4)
            umachine.draw_text(15, 42, "by Blackjet in 2019", 8)
            umachine.draw_text(87, 82, "v0." + str(version), 14)

    # Game
    else:
        interface.drawInterface()
        interface.drawStats()
        if (gameOver == True):
            # Add left-over coins to score
            if (coins > 0):
                if (pauseTimer > 0):
                    pauseTimer -= 1
                else:
Ejemplo n.º 28
0
def drawMain(screen, upg, eventtype, audio):
    global title, gameover, boost, boost_time, index, position, time, speed, mult, current, cx, cy, cind, x, y, score, charge, dashing, best
    boost_time += 1
    score = score + 1 * mult
    speed = boost * mult

    if boost_time > 500:
        boost += 1
        boost_time = 0

    if eventtype != upg.NOEVENT:
        if eventtype.type == upg.KEYDOWN:
            if eventtype.key == upg.K_UP:
                position = 0
                audio.play_sfx(sounds.low, len(sounds.low), True)
            if eventtype.key == upg.K_DOWN:
                position = 2
                audio.play_sfx(sounds.low, len(sounds.low), True)
            if eventtype.key == upg.K_RIGHT or eventtype.key == upg.BUT_A:
                if charge > 0 and not dashing:
                    dashing = True
            if eventtype.key == upg.K_LEFT or eventtype.key == upg.BUT_B:
                mult = -2
        if eventtype.type == upg.KEYUP:
            if eventtype.key == upg.K_UP:
                position = 1
            if eventtype.key == upg.K_DOWN:
                position = 1
            if eventtype.key == upg.K_RIGHT or eventtype.key == upg.BUT_A:
                dashing = False
            if eventtype.key == upg.K_LEFT or eventtype.key == upg.BUT_B:
                mult = 1

    if position is 0:
        y = 5
    if position is 1:
        y = 35
    if position is 2:
        y = 65

    if time <= 5:
        index = 0
    if time <= 10 and time > 5:
        index = 1
    if time <= 15 and time > 10:
        index = 2
    if time <= 20 and time > 15:
        index = 1

    #Dashing
    if dashing and charge > 0:
        if charge - 5 <= 0:
            charge = 0
            dashing = False
        else:
            audio.play_sfx(sounds.mid, len(sounds.mid), True)
            charge -= 5
            mult = 2
            x = 19
            index = 3
    if not dashing:
        x = 4
        mult = 1

    if time > 20:
        time = 0
        if charge < 100 and not dashing:
            if charge + 25 > 100:
                charge = 100
            else:
                charge += 25
    screen.blit(narwhal_sprites[index], x, y)

    #enemies
    if current == 0:
        current += 1
        spr = rand.getrandbits(3)
        y = 0
        if spr < 2:
            y = 38
        if spr == 7:
            y = 32
        cind = {"id": spr, "spr": enemies_sprites[spr], "x": 110, "y": y}
    else:

        cind["x"] -= speed
        if cind["x"] < -16:
            current = 0

    if cind["id"] < 7:
        if collide(x, y, cind["x"], cind["y"]):
            if cind["id"] > 3 and dashing:
                print("Close call")
            else:
                audio.play_sfx(sounds.lost, len(sounds.lost), True)
                gameover = True
                if score > best:
                    best = score
    else:
        if collide2(x, y, cind["x"], cind["y"]):
            gameover = True
            if score > best:
                best = score

    screen.blit(cind["spr"], cind["x"], cind["y"])
    pok.draw_text(3, 3, "Distance: " + str(score), 6)
    pok.draw_text(2, 2, "Distance: " + str(score), 3)

    for x in seaGunkPart:
        screen.blit(sprites.seaGunk, x["x"], x["y"])
        x["x"] = x["x"] - rand.getrandbits(3)
        if x["x"] < 0:
            x["x"] = 110
            x["y"] = rand.getrandbits(7)

    #charge draw
    screen.fill(7, upg.Rect(3, 83, charge, 3))
    screen.blit(charge_jar, 2, 82)
Ejemplo n.º 29
0
    def drawStats(self):
        global lives, score

        if (score < 10):
            umachine.draw_text(7, 13, "000" + str(score), 9)

        elif (score < 100):
            umachine.draw_text(7, 13, "00" + str(score), 9)

        elif (score < 1000):
            umachine.draw_text(7, 13, "0" + str(score), 9)

        else:
            umachine.draw_text(7, 13, str(score), 9)

        # Lives
        umachine.draw_text(85, 13, str(lives), 9)

        # Time
        umachine.draw_text(15, 76, str(timer), 9)

        # Coins
        umachine.draw_text(90, 76, str(coins), 9)
Ejemplo n.º 30
0
                coinCaught = False

    else:
        # Move fish on menu to improve random - this is also moving the fish when reachign 10 fish in aquarium, ie gameState 3
        for fish in fishList:
            fish.update()

###########################################################################
# Render
    screen.fill(0)  # Clear screen
    if (gameState == 0):
        if (showInstructions):
            interface.showInstructions(umachine)
        else:
            screen.blit(graphics.logo, 10, 10)
            umachine.draw_text(30, 40, "A: START", 1)
            umachine.draw_text(30, 47, "B: INFO (hold)", 15)
            umachine.draw_text(30, 54, "C: TOGGLE MUSIC", 2)
            umachine.draw_text(16, 62, "by Blackjet in 2019", 8)
            umachine.draw_text(87, 82, "v0." + str(version), 14)
    elif (gameState == 1):

        # Draw aquarium
        bg.draw(screen, aquariumBg[level - 1])
        # Draw falling coins
        if (len(coinList) > 0):
            for coin in coinList:
                coinAnim.draw(screen, coin.returnX(), coin.returnY())

        # Draw interface
        interface.draw(screen)