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()
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()
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()
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()
def update(self): Inputs.readkeys() #read all the actual keys if (Inputs.player_just_Start[1] or Inputs.player_just_Start[2]): self.pause = not self.pause if (self.match_time <= 0): self.is_finished = True else: if (configuration["sound"] == "on"): Match.snd_whistle.play() if (not self.pause): if (self.message_drawing_time < 10): if (self.message_drawing_time > 0): self.message_drawing_time -= 1 * configuration["delta_time"] if (self.message_drawing_time > 5) and ( self.message_image == self.start_image): #kick off if (configuration["sound"] == "on"): Match.snd_whistle.play() self.message_drawing_time = 5 if (self.match_time > 0): #when time is out, players stop self.match_time -= 1.0 / 30 * configuration[ "delta_time"] #30 FPS self.team[-1].update(self) self.team[1].update(self) if (-1 < self.match_time < 0): if (configuration["sound"] == "on"): Match.snd_whistle.play() self.ball.update(self) else: self.message_drawing_time -= 1 * configuration["delta_time"] #camera moves even if there is a message if (self.ball.owner == 0): self.cam.aim_to( [self.ball.pos[0], self.ball.pos[1], self.ball.pos[2] / 2], 0, 50) else: self.cam.aim_to( [self.ball.pos[0], self.ball.pos[1], self.ball.pos[2] / 2], self.ball.owner.direction, 5) else: #during pause the ball continues to roll self.ball.animation()
def update(self): Inputs.readkeys()#read all the actual keys if (Inputs.player_just_Start[1] or Inputs.player_just_Start[2]): self.pause=not self.pause if (self.match_time<=0): self.is_finished=True else: if (configuration["sound"]=="on"): Match.snd_whistle.play() if (not self.pause): if (self.message_drawing_time<10): if (self.message_drawing_time>0): self.message_drawing_time-=1*configuration["delta_time"] if (self.message_drawing_time>5)and(self.message_image==self.start_image):#kick off if (configuration["sound"]=="on"): Match.snd_whistle.play() self.message_drawing_time=5 if (self.match_time>0):#when time is out, players stop self.match_time-=1.0/30*configuration["delta_time"] #30 FPS self.team[-1].update(self) self.team[1].update(self) if (-1<self.match_time<0): if (configuration["sound"]=="on"): Match.snd_whistle.play() self.ball.update(self) else: self.message_drawing_time-=1*configuration["delta_time"] #camera moves even if there is a message if (self.ball.owner==0): self.cam.aim_to([self.ball.pos[0],self.ball.pos[1],self.ball.pos[2]/2],0,50) else: self.cam.aim_to([self.ball.pos[0],self.ball.pos[1],self.ball.pos[2]/2],self.ball.owner.direction,5) else:#during pause the ball continues to roll self.ball.animation()
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 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()
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()