def draw_team_info_text(screen,font,x): y=160 x_scale=1 y_gap=10 color=(200,200,0) ren = font.render("speed") screen.blit(ren,(x+font.center_shift("speed"),y-4)) y+=y_gap ren = font.render("resistance") screen.blit(ren,(x+font.center_shift("resistance"),y-4)) y+=y_gap ren = font.render("control") screen.blit(ren,(x+font.center_shift("control"),y-4)) y+=y_gap ren = font.render("kick") screen.blit(ren,(x+font.center_shift("kick"),y-4)) y+=y_gap ren = font.render("punch") screen.blit(ren,(x+font.center_shift("punch"),y-4)) y+=y_gap ren = font.render("precision") screen.blit(ren,(x+font.center_shift("precision"),y-4)) y+=y_gap ren = font.render("listening") screen.blit(ren,(x+font.center_shift("listening"),y-4)) y+=y_gap
def draw_team_info_text(screen, font, x): y = 160 x_scale = 1 y_gap = 10 color = (200, 200, 0) ren = font.render("speed") screen.blit(ren, (x + font.center_shift("speed"), y - 4)) y += y_gap ren = font.render("resistance") screen.blit(ren, (x + font.center_shift("resistance"), y - 4)) y += y_gap ren = font.render("control") screen.blit(ren, (x + font.center_shift("control"), y - 4)) y += y_gap ren = font.render("kick") screen.blit(ren, (x + font.center_shift("kick"), y - 4)) y += y_gap ren = font.render("punch") screen.blit(ren, (x + font.center_shift("punch"), y - 4)) y += y_gap ren = font.render("precision") screen.blit(ren, (x + font.center_shift("precision"), y - 4)) y += y_gap ren = font.render("listening") screen.blit(ren, (x + font.center_shift("listening"), y - 4)) y += y_gap
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()