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()
# Keep the player in-bounds if self.pos[0] < 0: self.pos[0] = 0 if self.pos[0] > 240: self.pos[0] = 240 # Initalise the display display.init(scale=2.0, caption="NES Demo", res=NESRES) player = Player() # Create the player # Create a font nesfont = font.Font(NES_FONT, (255, 255, 255)) dialogbox = dialog.DialogBox((240, 51), (0, 0, 0), (255, 255, 255), nesfont) dialogbox.set_dialog([ "This is a dialog box! Press the a button to go to the next page.", "Press it again and this box will close." ]) menu = dialog.Menu(nesfont, ["Close", "Pause", "Exit"]) # dialogbox.close() while 1: # Tick, tock, at 30 frames per second clock.tick() # Handle button and key input button.handle_input()
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()
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()