Exemple #1
0
def run_menu():
    timer = 0
    play_music("data/title.ogg")
    game = Game()
    set_global_sound_volume(0.75)
    while True:
        clock.tick()
        button.handle_input()

        # If we pressed start, begin the game
        if button.is_pressed(START):

            play_music("data/algar-orka.xm", -1)
            # Creates text box
            whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
            box = dialog.DialogBox((152, 46), (50, 50, 50),
                GB_SCREEN_COLOR, whitefont)
            box.set_dialog([
                "Spin to \
                win.",
                "- Garen 2008"
            ])
            # Updates box when Z is pressed
            box.set_scrolldelay(2)
            while not box.over():
                clock.tick()
                button.handle_input()
                if button.is_pressed(A_BUTTON):
                    box.progress()
                screen = display.get_surface()
                screen.fill(GB_SCREEN_COLOR)
                screen.blit(game.background, (0, 0))
                box.draw(screen, (4, 4))
                display.update()

            game.won = True
            #game.level = 1
            game.lives = 3
            game.score = 0

            #Play each level
            for lvl in LEVELS:
                game.startLevel(lvl)
                #game.level += 1
                game.loop()
                #if not game.player.alive():
                #    break

        screen = display.get_surface()
        screen.fill(GB_SCREEN_COLOR)
        screen.blit(load_image("data/bg.png"), (0, 0))
        ren = game.font.render("Press Start")
        timer += 1
        timer = timer % 30
        if timer < 15:
            screen.blit(ren, (80-ren.get_width()/2,
                104-ren.get_height()/2))
        display.update()
Exemple #2
0
def call_a_menu(menu,default_option,info,display,font,mainClock):
    menu.option=default_option
    title_image=pygame.image.load("data/title.png")
    while 1:
        mainClock.tick(30)
        Inputs.readkeys()#read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down    
        if Inputs.player_just_U[1]:
            menu.move_cursor(-1)
        if Inputs.player_just_D[1]:
            menu.move_cursor(1)
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            option, text = menu.get_option()
            return option, text
        # If you press B, cancel 
        if Inputs.player_just_B[1]:
            return -1, ""
        
        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image,(0,0))
        
        # Draw the menu boxes
        ren = font.render(info)
        screen.blit(ren, (8, 112))
        menu.draw(screen, (16, 128), background=(0, 0, 0), border=(255, 255, 255))
        # Update and draw the display
        display.update()
Exemple #3
0
def show_info(display,font,mainClock):
    title_image=pygame.image.load("data/title.png")

    dialogbox = dialog.DialogBox((240, 51), (0, 0, 0),(255, 255, 255), font)
    dialogbox.set_dialog([
        "Welcome to pyNekketsu!      Press L to continue.", 
        "Player1 controls:           arrows (to move),           K (shoot or attack),        L (pass), P (pause, start)", 
        "Player2 controls:           F, G, H, T (to move),       A (shoot or attack),        Z (pass), R (pause, start)"])

    while not dialogbox.over():
        mainClock.tick(30)
        
        Inputs.readkeys()#read all the actual keys
          
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()

        if Inputs.player_just_A[1]:
            dialogbox.progress()
        
        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image,(0,0))
        
        dialogbox.draw(screen, (8, 128))

        # Update and draw the display
        display.update()
Exemple #4
0
    def draw(self):
        clock.tick()
        screen = display.get_surface()

        screen.fill(GB_SCREEN_COLOR)
        screen.blit(self.background, ((-self.camera.x/2) % 160, 0))
        screen.blit(self.background, (((-self.camera.x/2) - 160) % -160, 0))
        screen.blit(self.background, (((-self.camera.x/2) + 160) % 160, 0))

        # screen.blit(self.image, (self.rect.x - camera.x + self.offsetx,
        #     self.rect.y - camera.y + self.offsety))

        for object in self.objects:
            object.draw(screen, self.camera)

        ren = self.font.render("score    level      x%d" % self.lives)
        screen.blit(ren, (4, 4))
        ren = self.font.render("%06d    %d-1" % (self.score, self.level-1))
        screen.blit(ren, (4, 14))
        #screen.blit(self.lifeicon, (160-30, 2))

        if self.levelCompleted:
            self.levelCompleted = False
            self.level += 1
            print "lvl", self.level
            if self.level == len(LEVELS):

            self.startLevel(LEVELS[self.level])

        display.update()
Exemple #5
0
def show_info(display, font, mainClock):
    title_image = pygame.image.load("data/title.png")

    dialogbox = dialog.DialogBox((240, 51), (0, 0, 0), (255, 255, 255), font)
    dialogbox.set_dialog([
        "Welcome to pyNekketsu!      Press L to continue.",
        "Player1 controls:           arrows (to move),           K (shoot or attack),        L (pass), P (pause, start)",
        "Player2 controls:           F, G, H, T (to move),       A (shoot or attack),        Z (pass), R (pause, start)"
    ])

    while not dialogbox.over():
        mainClock.tick(30)

        Inputs.readkeys()  #read all the actual keys

        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()

        if Inputs.player_just_A[1]:
            dialogbox.progress()

        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image, (0, 0))

        dialogbox.draw(screen, (8, 128))

        # Update and draw the display
        display.update()
Exemple #6
0
def call_a_menu(menu, default_option, info, display, font, mainClock):
    menu.option = default_option
    title_image = pygame.image.load("data/title.png")
    while 1:
        mainClock.tick(30)
        Inputs.readkeys()  #read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down
        if Inputs.player_just_U[1]:
            menu.move_cursor(-1)
        if Inputs.player_just_D[1]:
            menu.move_cursor(1)
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            option, text = menu.get_option()
            return option, text
        # If you press B, cancel
        if Inputs.player_just_B[1]:
            return -1, ""

        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image, (0, 0))

        # Draw the menu boxes
        ren = font.render(info)
        screen.blit(ren, (8, 112))
        menu.draw(screen, (16, 128),
                  background=(0, 0, 0),
                  border=(255, 255, 255))
        # Update and draw the display
        display.update()
Exemple #7
0
 def win(self):
     splash = display.get_surface().copy()
     pos = 0
     time = 50
     while 1:
         button.handle_input()
         clock.tick()
         if pos < 74:
             pos += 2
         else:
             time -= 1
             if time <= 0:
                 break
         screen = display.get_surface()
         screen.blit(splash, (0, 0))
         ren = self.font.render("You reached Oliland!")
         screen.blit(ren, (80 - ren.get_width() / 2, pos))
         display.update()
     self.playing = False
 def win(self):
     splash = display.get_surface().copy()
     pos = 0
     time = 50
     while 1:
         button.handle_input()
         clock.tick()
         if pos < 74:
             pos += 2
         else:
             time -= 1
             if time <= 0:
                 break
         screen = display.get_surface()
         screen.blit(splash, (0, 0))
         ren = self.font.render("You reached Oliland!")
         screen.blit(ren, (80-ren.get_width()/2, pos))
         display.update()
     self.playing = False
Exemple #9
0
 def pause(self):
     pygame.mixer.music.pause()
     button.handle_input()
     play_sound("data/pause.ogg")
     while not button.is_pressed(START):
         button.handle_input()
         ren = self.font.render("PAUSED")
         screen = display.get_surface()
         screen.blit(ren, (80 - ren.get_width() / 2, 74 - ren.get_height() / 2))
         display.update()
     play_sound("data/pause.ogg")
     pygame.mixer.music.unpause()
Exemple #10
0
 def pause(self):
     pygame.mixer.music.pause()
     button.handle_input()
     play_sound("data/pause.ogg")
     while not button.is_pressed(START):
         button.handle_input()
         ren = self.font.render("PAUSED")
         screen = display.get_surface()
         screen.blit(ren,
                     (80 - ren.get_width() / 2, 74 - ren.get_height() / 2))
         display.update()
     play_sound("data/pause.ogg")
     pygame.mixer.music.unpause()
    def draw(self):
        screen = display.get_surface()

        screen.fill(GB_SCREEN_COLOR)
        screen.blit(self.background, ((-self.camera.x/2) % 160, 0))
        screen.blit(self.background, (((-self.camera.x/2) - 160) % -160, 0))
        screen.blit(self.background, (((-self.camera.x/2) + 160) % 160, 0))

        for object in self.objects:
            object.draw(screen, self.camera)
        
        ren = self.font.render("score    level      x%d" % self.lives)
        screen.blit(ren, (4, 4))
        ren = self.font.render("%06d    %d-1" % (self.score, self.level-1))
        screen.blit(ren, (4, 14))
        screen.blit(self.lifeicon, (160-30, 2))
        
        if not self.player.alive() and not self.dead:
            self.start_level(LEVELS[self.level-2])
        
        display.update()
Exemple #12
0
    def draw(self):
        screen = display.get_surface()

        screen.fill(GB_SCREEN_COLOR)
        screen.blit(self.background, ((-self.camera.x / 2) % 160, 0))
        screen.blit(self.background, (((-self.camera.x / 2) - 160) % -160, 0))
        screen.blit(self.background, (((-self.camera.x / 2) + 160) % 160, 0))

        for object in self.objects:
            object.draw(screen, self.camera)

        ren = self.font.render("score    level      x%d" % self.lives)
        screen.blit(ren, (4, 4))
        ren = self.font.render("%06d    %d-1" % (self.score, self.level - 1))
        screen.blit(ren, (4, 14))
        screen.blit(self.lifeicon, (160 - 30, 2))

        if not self.player.alive() and not self.dead:
            self.start_level(LEVELS[self.level - 2])

        display.update()
Exemple #13
0
def select_teams(display,font,mainClock,west_team_index_init,east_team_index_init):
    path="data/teams/"
    dirList=os.listdir(path)
    allteams=[]
    for fname in dirList:
        if fnmatch.fnmatch(fname, '*.xml'):
            allteams.append(Team("data/teams/"+fname))
    
    title_image=pygame.image.load("data/title.png")
    up_image=pygame.image.load("data/arrow_up.png")
    down_image=pygame.image.load("data/arrow_down.png")

    cursor_on_east_wing=False
    cursor_color_angle=0
    west_team_index=west_team_index_init
    east_team_index=east_team_index_init
    while 1:
        mainClock.tick(30)
        cursor_color_angle+=0.1
        Inputs.readkeys()#read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down    
        if Inputs.player_just_U[1]:
            if (cursor_on_east_wing):
                east_team_index-=1
                if (east_team_index<0):
                    east_team_index=len(allteams)-1
                if (east_team_index==west_team_index):
                    east_team_index-=1
                    if (east_team_index<0):
                        east_team_index=len(allteams)-1
            else:
                west_team_index-=1
                if (west_team_index<0):
                    west_team_index=len(allteams)-1
                if (east_team_index==west_team_index):
                    west_team_index-=1
                    if (west_team_index<0):
                        west_team_index=len(allteams)-1
        if Inputs.player_just_D[1]:
            if (cursor_on_east_wing):
                east_team_index+=1
                if (east_team_index>=len(allteams)):
                    east_team_index=0
                if (east_team_index==west_team_index):
                    east_team_index+=1
                    if (east_team_index>=len(allteams)):
                        east_team_index=0
            else:
                west_team_index+=1
                if (west_team_index>=len(allteams)):
                    west_team_index=0
                if (east_team_index==west_team_index):
                    west_team_index+=1
                    if (west_team_index>=len(allteams)):
                        west_team_index=0
        if Inputs.player_just_R[1] or Inputs.player_just_L[1]:
                cursor_on_east_wing=not cursor_on_east_wing
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            return (allteams[west_team_index].xml_filename,west_team_index,allteams[east_team_index].xml_filename,east_team_index)
        # If you press B, cancel 
        if (Inputs.player_just_B[1]):# or  Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            return ("?",west_team_index,"?",east_team_index)
        
        
        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image,(0,0))
        
        #draw current teams
        if (cursor_on_east_wing):
            pygame.draw.rect(screen, (150+cos(cursor_color_angle)*50,150+cos(cursor_color_angle+2.1)*50 ,150+cos(cursor_color_angle+1.2)*50 ), (185, 95, 25,25),1)
            screen.blit(up_image,(185, 78))
            screen.blit(down_image,(185, 121))
        else:
            pygame.draw.rect(screen, (150+cos(cursor_color_angle)*50,150+cos(cursor_color_angle+2.1)*50 ,150+cos(cursor_color_angle+1.2)*50), (37, 95, 25,25),1)
            screen.blit(up_image,(37, 78))
            screen.blit(down_image,(37, 121))

        draw_team_info_text(screen,font,128)
        #screen.blit(allteams[west_team_index].image,(42,120))
        transf_west_img=pygame.transform.scale(allteams[west_team_index].image,(int(16+4*cos(cursor_color_angle)),int(16+4*cos(1.3*cursor_color_angle+0.5))))
        transf_west_img=pygame.transform.scale(allteams[west_team_index].image,(int(16+4*cos(cursor_color_angle)),int(16+4*cos(1.3*cursor_color_angle+0.5))))
        transf_east_img=pygame.transform.scale(allteams[east_team_index].image,(int(16+4*cos(cursor_color_angle+1)),int(16+4*cos(1.3*cursor_color_angle+1.5))))

        screen.blit(transf_west_img,(42+8-(16+4*cos(cursor_color_angle))/2,100+8-(16+4*cos(1.3*cursor_color_angle+0.5))/2))
        screen.blit(transf_east_img,(190+8-(16+4*cos(cursor_color_angle+1))/2,100+8-(16+4*cos(1.3*cursor_color_angle+1.5))/2))

        allteams[west_team_index].draw_info(screen,78,-1)
        allteams[east_team_index].draw_info(screen,178,1)
        
        ren = font.render(allteams[west_team_index].name)
        screen.blit(ren, (55+font.center_shift(allteams[west_team_index].name), 142))
        ren = font.render(allteams[east_team_index].name)
        screen.blit(ren, (200+font.center_shift(allteams[east_team_index].name), 142))
        ren = font.render("vs.")
        screen.blit(ren, (120, 125))


#        x=100
#        y=100
#        draw_team_info_text(screen,font,10)
#        for team in allteams:
#            screen.blit(team.image,(x,y))
#            team.draw_info(screen,x)
#            x+=50
        # Draw the menu boxes
        #ren = font.render(info)
        #screen.blit(ren, (8, 112))
        # Update and draw the display
        display.update()
Exemple #14
0
 def display(self,display,font,mainClock):
     title_image=pygame.image.load("data/title.png")
     dlg=0
     selected_option=self.default_num
     if (len(self.choices_values_value)>0):#if settings, read in "configuration"
         selected_option=0
         for val in self.choices_values_value :
             if (val==configuration[self.variable]):
                 break
             selected_option+=1
         if (selected_option==len(self.choices_values_value)):
             selected_option=self.default_num
         dlg = dialog.Menu(font, self.choices_values_text)
     else:#look for submenus
         dlg = dialog.Menu(font, self.choices_submenus_text)
     
     dlg.option=selected_option
     if (len(self.dialogtext)>0):
         dialogbox = dialog.DialogBox((240, 51), (0, 0, 0),(255, 255, 255), font)
         dialogbox.set_dialog([self.dialogtext])
     while 1:
         mainClock.tick(30)
         Inputs.readkeys()#read all the actual keys
         if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
             pygame.quit()
             sys.exit()
         # Move the menu cursor if you press up or down    
         if Inputs.player_just_U[1]:
             dlg.move_cursor(-1)
         if Inputs.player_just_D[1]:
             dlg.move_cursor(1)
         # If you press A, check which option you're on!
         if Inputs.player_just_A[1]:
             if (len(self.choices_values_value)>0):#if settings
                 configuration[self.variable]=self.choices_values_value[dlg.get_option()[0]]
                 if (self.choices_values_goto[dlg.get_option()[0]]!=0):
                     self.choices_values_goto[dlg.get_option()[0]].display(display,font,mainClock)
                 else:
                     if (self.exits):
                         configuration["exit_menu"]="yes"
                     return
                 
             else:#if submenus
                 #print(dlg.get_option())
                 self.choices_submenus[dlg.get_option()[0]].display(display,font,mainClock)
         ## If you press B, cancel 
         if Inputs.player_just_B[1]:
             if (self.id!="menu_welcome"):
                 Inputs.player_just_B[1]=False
                 return
             else:
                 print("Nothing to do...")
         
         #if returns from a sub-menu asking to exit :
         if (configuration["exit_menu"]=="yes"):
             return
         
         # Get the surface from the NES game library
         screen = display.get_surface()
         screen.blit(title_image,(0,0))
         
         # Draw the menu boxes
         ren = font.render(self.text)
         screen.blit(ren, (8, 112))
         dlg.draw(screen, (16, 128), background=(0, 0, 0), border=(255, 255, 255))
         if (len(self.dialogtext)>0):
             dialogbox.draw(screen, (8, 180))
         # Update and draw the display
         display.update()
Exemple #15
0
def select_teams(display, font, mainClock, west_team_index_init,
                 east_team_index_init):
    path = "data/teams/"
    dirList = os.listdir(path)
    allteams = []
    for fname in dirList:
        if fnmatch.fnmatch(fname, '*.xml'):
            allteams.append(Team("data/teams/" + fname))

    title_image = pygame.image.load("data/title.png")
    up_image = pygame.image.load("data/arrow_up.png")
    down_image = pygame.image.load("data/arrow_down.png")

    cursor_on_east_wing = False
    cursor_color_angle = 0
    west_team_index = west_team_index_init
    east_team_index = east_team_index_init
    while 1:
        mainClock.tick(30)
        cursor_color_angle += 0.1
        Inputs.readkeys()  #read all the actual keys
        if (Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            pygame.quit()
            sys.exit()
        # Move the menu cursor if you press up or down
        if Inputs.player_just_U[1]:
            if (cursor_on_east_wing):
                east_team_index -= 1
                if (east_team_index < 0):
                    east_team_index = len(allteams) - 1
                if (east_team_index == west_team_index):
                    east_team_index -= 1
                    if (east_team_index < 0):
                        east_team_index = len(allteams) - 1
            else:
                west_team_index -= 1
                if (west_team_index < 0):
                    west_team_index = len(allteams) - 1
                if (east_team_index == west_team_index):
                    west_team_index -= 1
                    if (west_team_index < 0):
                        west_team_index = len(allteams) - 1
        if Inputs.player_just_D[1]:
            if (cursor_on_east_wing):
                east_team_index += 1
                if (east_team_index >= len(allteams)):
                    east_team_index = 0
                if (east_team_index == west_team_index):
                    east_team_index += 1
                    if (east_team_index >= len(allteams)):
                        east_team_index = 0
            else:
                west_team_index += 1
                if (west_team_index >= len(allteams)):
                    west_team_index = 0
                if (east_team_index == west_team_index):
                    west_team_index += 1
                    if (west_team_index >= len(allteams)):
                        west_team_index = 0
        if Inputs.player_just_R[1] or Inputs.player_just_L[1]:
            cursor_on_east_wing = not cursor_on_east_wing
        # If you press A, check which option you're on!
        if Inputs.player_just_A[1]:
            return (allteams[west_team_index].xml_filename, west_team_index,
                    allteams[east_team_index].xml_filename, east_team_index)
        # If you press B, cancel
        if (Inputs.player_just_B[1]
            ):  # or  Inputs.player_just_Esc[1] or Inputs.player_just_Esc[2]):
            return ("?", west_team_index, "?", east_team_index)

        # Get the surface from the NES game library
        screen = display.get_surface()
        screen.blit(title_image, (0, 0))

        #draw current teams
        if (cursor_on_east_wing):
            pygame.draw.rect(screen,
                             (150 + cos(cursor_color_angle) * 50,
                              150 + cos(cursor_color_angle + 2.1) * 50,
                              150 + cos(cursor_color_angle + 1.2) * 50),
                             (185, 95, 25, 25), 1)
            screen.blit(up_image, (185, 78))
            screen.blit(down_image, (185, 121))
        else:
            pygame.draw.rect(screen,
                             (150 + cos(cursor_color_angle) * 50,
                              150 + cos(cursor_color_angle + 2.1) * 50,
                              150 + cos(cursor_color_angle + 1.2) * 50),
                             (37, 95, 25, 25), 1)
            screen.blit(up_image, (37, 78))
            screen.blit(down_image, (37, 121))

        draw_team_info_text(screen, font, 128)
        #screen.blit(allteams[west_team_index].image,(42,120))
        transf_west_img = pygame.transform.scale(
            allteams[west_team_index].image,
            (int(16 + 4 * cos(cursor_color_angle)),
             int(16 + 4 * cos(1.3 * cursor_color_angle + 0.5))))
        transf_west_img = pygame.transform.scale(
            allteams[west_team_index].image,
            (int(16 + 4 * cos(cursor_color_angle)),
             int(16 + 4 * cos(1.3 * cursor_color_angle + 0.5))))
        transf_east_img = pygame.transform.scale(
            allteams[east_team_index].image,
            (int(16 + 4 * cos(cursor_color_angle + 1)),
             int(16 + 4 * cos(1.3 * cursor_color_angle + 1.5))))

        screen.blit(transf_west_img,
                    (42 + 8 - (16 + 4 * cos(cursor_color_angle)) / 2, 100 + 8 -
                     (16 + 4 * cos(1.3 * cursor_color_angle + 0.5)) / 2))
        screen.blit(transf_east_img,
                    (190 + 8 -
                     (16 + 4 * cos(cursor_color_angle + 1)) / 2, 100 + 8 -
                     (16 + 4 * cos(1.3 * cursor_color_angle + 1.5)) / 2))

        allteams[west_team_index].draw_info(screen, 78, -1)
        allteams[east_team_index].draw_info(screen, 178, 1)

        ren = font.render(allteams[west_team_index].name)
        screen.blit(
            ren, (55 + font.center_shift(allteams[west_team_index].name), 142))
        ren = font.render(allteams[east_team_index].name)
        screen.blit(
            ren,
            (200 + font.center_shift(allteams[east_team_index].name), 142))
        ren = font.render("vs.")
        screen.blit(ren, (120, 125))

        #        x=100
        #        y=100
        #        draw_team_info_text(screen,font,10)
        #        for team in allteams:
        #            screen.blit(team.image,(x,y))
        #            team.draw_info(screen,x)
        #            x+=50
        # Draw the menu boxes
        #ren = font.render(info)
        #screen.blit(ren, (8, 112))
        # Update and draw the display
        display.update()
Exemple #16
0
def run_menu():
    timer = 0
    play_music("data/title.ogg")
    game = Game()
    set_global_sound_volume(0.75)

    while 1:
        clock.tick()
        button.handle_input()

        # If we pressed start, begin the game
        if button.is_pressed(START):

            play_music("data/algar-orka.xm", -1)
            whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
            box = dialog.DialogBox((152, 46), (50, 50, 50), GB_SCREEN_COLOR,
                                   whitefont)
            box.set_dialog([
                "bubbman was on his way to oliland,",
                "when his car broke down in the dododu mountains!",
                "can bubbman cross the monster-infested mountain range?"
            ])
            box.set_scrolldelay(2)
            while not box.over():
                clock.tick()
                button.handle_input()
                if button.is_pressed(A_BUTTON):
                    box.progress()
                screen = display.get_surface()
                screen.fill(GB_SCREEN_COLOR)
                screen.blit(game.background, (0, 0))
                box.draw(screen, (4, 4))
                display.update()

            game.won = True
            game.level = 1
            game.lives = 5
            game.score = 0

            # Play each level
            for lvl in LEVELS:
                game.start_level(lvl)
                game.level += 1
                game.loop()
                if not game.player.alive():
                    break

            # If we got to the end of the game, display credits
            if game.won:
                pos = 144
                credits = [
                    "Credits", "", "", "Programmers", "pymike", "saluk", "",
                    "", "Sound Mixing", "pymike", "", "", "Music",
                    "ModArchive.org", "DrPetter", "", "", "Special Thanks To",
                    "SFXR by DrPetter", "The Gimp 2", "Geany", "", "", "", "",
                    "", "", "", "", "", "", "", "", "", " Thanks for playing!!"
                ]
                while pos > -144 - (len(credits) * 7):
                    button.handle_input()
                    if button.is_pressed(START):
                        break
                    screen = display.get_surface()
                    screen.fill(GB_SCREEN_COLOR)
                    screen.blit(game.background, (0, 0))

                    clock.tick()
                    pos -= 0.5
                    y = 0
                    for c in credits:
                        ren = game.font.render(c)
                        screen.blit(ren, (80 - ren.get_width() / 2, pos + y))
                        y += 10
                    display.update()

            play_music("data/title.ogg")

        # Draw the main menu
        screen = display.get_surface()
        screen.fill(GB_SCREEN_COLOR)
        screen.blit(load_image("data/bubbman-menu.png"), (0, 0))
        ren = game.font.render("Press Start")
        timer += 1
        timer = timer % 30
        if timer < 15:
            screen.blit(ren,
                        (80 - ren.get_width() / 2, 104 - ren.get_height() / 2))
        display.update()
Exemple #17
0
     # If you press start, check which option you're on!
     if button.is_pressed(START):
         option, text = menu.get_option()
         print "You pressed '%s'" % text
         if option == 2:
             raise SystemExit
     
     # Jump if the player taps the A button
     if button.is_pressed(A_BUTTON):
         player.jump_speed = -5
         
     # Update the player
     player.update()
 
 # Get the surface from the NES game library
 screen = display.get_surface()
 
 # Call normal pygame draw functions
 screen.fill((200, 200, 255))
 pygame.draw.rect(screen, (50, 100, 0), (0, 208, 256, 32))
 pygame.draw.rect(screen, (255, 200, 185), (0, 209, 256, 1), 1)
 screen.blit(player.image, player.pos)
 
 # Render text with the font
 ren = nesfont.render("Score        Time        World")
 screen.blit(ren, (8, 8))
 ren = nesfont.render("000000        99          1-1")
 screen.blit(ren, (8, 18))
 
 # Draw the dialog and menu boxes
 menu.draw(screen, (8, 202), background=(0, 0, 0), 
Exemple #18
0
def run_menu():
	play_music("sfx/title_screen.ogg")
	timer = 0
	game = Game()
	set_global_sound_volume(0.75)
	
	while True:
		clock.tick()
		button.handle_input()
		
		if button.is_pressed(START):
			
			play_music("sfx/ChibiNinja.ogg", -1)
			whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
			box = dialog.DialogBox((152, 46), (50, 50, 50), 
				GB_SCREEN_COLOR, whitefont)
			box.set_dialog([
				"GET THEM DARN ALIENS!"
			])
			box.set_scrolldelay(2)
			while not box.over():
				clock.tick()
				button.handle_input()
				if button.is_pressed(A_BUTTON):
					box.progress()
				screen = display.get_surface()
				screen.fill(GB_SCREEN_COLOR)
				screen.blit(game.background, (0, 0))
				box.draw(screen, (4, 4))
				display.update()
			
			
			game.won = True
			game.level = 1
			game.lives = 5
			game.score = 0

			# Play each level
			for lvl in LEVELS:
				game.start_level(lvl)
				game.level += 1
				game.loop()
				if not game.player.alive():
					break
			
			# If we got to the end of the game, display credits
			if game.won:
				pos = 144
				credits = [
					"Credits",
					"",
					"",
					"Programming by",
					"Tommy Brunn",
					"pymike",
					"saluk",
					"",
					"",
					"Art by",
					"Tommy Brunn",
					"",
					"",
					"Sound Mixing",
					"Tommy Brunn",
					"",
					"",
					"Music",
					"Eric Skiff",
					"thechad1138",
					"",
					"",
					"Special Thanks To",
					"SFXR by DrPetter",
					"pymike",
					"saluk",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					"",
					" Thanks for playing!"]
				while pos > -144-(len(credits)*7):
					button.handle_input()
					if button.is_pressed(START):
						break
					screen = display.get_surface()
					screen.fill(GB_SCREEN_COLOR)
					screen.blit(game.background, (0, 0))
					
					clock.tick()
					pos -= 0.5
					y = 0
					for c in credits:
						ren = game.font.render(c)
						screen.blit(ren, (80-ren.get_width()/2, pos+y))
						y += 10
					display.update()
		   
			play_music("sfx/title_screen.ogg")
			
		#Draw main menu
		screen = display.get_surface()
		screen.fill(GB_SCREEN_COLOR)
		#screen.blit(load_image("gfx/menu.png"), (0, 0))
		ren = game.font.render("Press Start")
		timer += 1
		timer = timer % 30
		if timer < 15:
			screen.blit(ren, (80-ren.get_width()/2, 
				104-ren.get_height()/2))
		display.update()
Exemple #19
0
        # If you press start, check which option you're on!
        if button.is_pressed(START):
            option, text = menu.get_option()
            print("You pressed '%s'" % text)
            if option == 2:
                raise SystemExit

        # Jump if the player taps the A button
        if button.is_pressed(A_BUTTON):
            player.jump_speed = -5

        # Update the player
        player.update()

    # Get the surface from the NES game library
    screen = display.get_surface()

    # Call normal pygame draw functions
    screen.fill((200, 200, 255))
    pygame.draw.rect(screen, (50, 100, 0), (0, 208, 256, 32))
    pygame.draw.rect(screen, (255, 200, 185), (0, 209, 256, 1), 1)
    screen.blit(player.image, player.pos)

    # Render text with the font
    ren = nesfont.render("Score        Time        World")
    screen.blit(ren, (8, 8))
    ren = nesfont.render("000000        99          1-1")
    screen.blit(ren, (8, 18))

    # Draw the dialog and menu boxes
    menu.draw(screen, (8, 202), background=(0, 0, 0), border=(255, 255, 255))
def run_menu():
        
    timer = 0
    play_music("data/title.ogg")
    game = Game()
    set_global_sound_volume(0.75)
    
    while 1:
        clock.tick()
        button.handle_input()
        
        # If we pressed start, begin the game
        if button.is_pressed(START):

            play_music("data/algar-orka.xm", -1)
            whitefont = font.Font(GAMEBOY_FONT, GB_SCREEN_COLOR)
            box = dialog.DialogBox((152, 46), (50, 50, 50), 
                GB_SCREEN_COLOR, whitefont)
            box.set_dialog([
                "johnny the adventurer discovered a huge tower,",
                "and, being the manly man he is, must explore it!",
                "can you help him climb the perilous tower??"
            ])
            box.set_scrolldelay(2)
            while not box.over():
                clock.tick()
                button.handle_input()
                if button.is_pressed(A_BUTTON):
                    box.progress()
                screen = display.get_surface()
                screen.fill(GB_SCREEN_COLOR)
                screen.blit(game.background, (0, 0))
                box.draw(screen, (4, 4))
                display.update()
            
            
            game.won = True
            game.level = 1
            game.lives = 5
            game.score = 0

            # Play each level
            for lvl in LEVELS:
                game.start_level(lvl)
                game.level += 1
                game.loop()
                if not game.player.alive():
                    break
            
            # If we got to the end of the game, display credits
            if game.won:
                pos = 144
                credits = [
                    "Credits",
                    "",
                    "",
                    "Programmers",
                    "pymike",
                    "saluk",
                    "",
                    "",
                    "Sound Mixing",
                    "pymike",
                    "",
                    "",
                    "Music",
                    "ModArchive.org",
                    "DrPetter",
                    "",
                    "",
                    "Special Thanks To",
                    "SFXR by DrPetter",
                    "The Gimp 2",
                    "Geany",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    " Thanks for playing!!"]
                while pos > -144-(len(credits)*7):
                    button.handle_input()
                    if button.is_pressed(START):
                        break
                    screen = display.get_surface()
                    screen.fill(GB_SCREEN_COLOR)
                    screen.blit(game.background, (0, 0))
                    
                    clock.tick()
                    pos -= 0.5
                    y = 0
                    for c in credits:
                        ren = game.font.render(c)
                        screen.blit(ren, (80-ren.get_width()/2, pos+y))
                        y += 10
                    display.update()
           
            play_music("data/title.ogg")
        
        # Draw the main menu
        screen = display.get_surface()
        screen.fill(GB_SCREEN_COLOR)
        screen.blit(load_image("data/bubbman-menu.png"), (0, 0))
        ren = game.font.render("Press Start")
        timer += 1
        timer = timer % 30
        if timer < 15:
            screen.blit(ren, (80-ren.get_width()/2, 
                104-ren.get_height()/2))
        display.update()