本文整理汇总了Python中threades.resize_pos函数的典型用法代码示例。如果您正苦于以下问题:Python resize_pos函数的具体用法?Python resize_pos怎么用?Python resize_pos使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了resize_pos函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: graphics
def graphics(self):
logo = pygame.image.load(os.path.join("data", "logo.png")).convert()
self.ff_logo = pygame.transform.scale(logo, threades.resize_pos((1111, 250)))
threades.screen.fill((0, 0, 0))
threades.screen.blit(self.ff_logo, threades.resize_pos((40, 50)))
# Font type
myfont = pygame.font.Font("font.ttf", threades.resize_pt(17))
# creating new label showing loading of level
labelStyleCopy = gui.defaultLabelStyle.copy()
labelStyleCopy["border-width"] = 1
labelStyleCopy["wordwrap"] = True
labelStyleCopy["autosize"] = False
labelStyleCopy["font"] = myfont
labelStyleCopy["font-color"] = (0, 200, 0)
text1 = "Loading...."
# creating the label
label = gui.Label(
position=threades.resize_pos((500, 600)),
size=threades.resize_pos((250, 50)),
parent=desktop_level,
style=labelStyleCopy,
text=text1,
)
示例2: pause_screen
def pause_screen(pause_flag = True):
"""
Pauses the screen until user takes any action
"""
start = starting_intro()
#Initialises and creates the starting screen
start.main_menu(pause_flag,threades.game_save_flag)
logo = pygame.image.load(os.path.join('data', 'logo.png')).convert()
ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250)))
#The loop which pauses main screen
while start.run:
pygame.display.set_caption('FoodForce2')
threades.screen.fill((0,0,0))
threades.screen.blit(ff_logo,threades.resize_pos((40,50)))
for e in gui.setEvents(pygame.event.get()):
if e.type == pygame.QUIT:
safe_exit()
if e.type == QUIT:
safe_exit()
desktop2.update()
desktop2.draw()
pygame.display.update()
threades.total_update_flag = True
示例3: graphics
def graphics(self):
logo = pygame.image.load(os.path.join('data', 'logo.png')).convert()
self.ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250)))
threades.screen.fill((0,0,0))
threades.screen.blit(self.ff_logo,threades.resize_pos((40,50)))
# Font type
myfont = pygame.font.Font("font.ttf", threades.resize_pt(17))
#creating new label showing loading of level
labelStyleCopy = gui.defaultLabelStyle.copy()
labelStyleCopy['border-width'] = 1
labelStyleCopy['wordwrap'] = True
labelStyleCopy['autosize'] = False
labelStyleCopy['font'] = myfont
labelStyleCopy['font-color'] = (0,200,0)
if self.level_no==-1:
text1='Loading New Level...'
else:
text1='Loading Level No:'+str(self.level_no)
#creating the label
label = gui.Label(position = threades.resize_pos((500,600)), size = threades.resize_pos((250,50)), parent = desktop_level,style=labelStyleCopy,text=text1)
#self.run=True
示例4: pause_screen
def pause_screen(pause_flag = True):
start = starting_intro()
start.main_menu(pause_flag)
logo = pygame.image.load(os.path.join('data', 'logo.png')).convert()
ff_logo = pygame.transform.scale(logo,threades.resize_pos((1111,250)))
while start.run:
pygame.display.set_caption('FoodForce2')
threades.screen.fill((0,0,0))
threades.screen.blit(ff_logo,threades.resize_pos((40,50)))
for e in gui.setEvents(pygame.event.get()):
if e.type == pygame.QUIT:
safe_exit()
if e.type == QUIT:
safe_exit()
if e.type==mesh.CONNECT :
game_sharing.sharing_handler(e.type,None,'')
#sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,None,'']).start()
elif e.type==mesh.PARTICIPANT_ADD or e.type==mesh.PARTICIPANT_REMOVE :
game_sharing.sharing_handler(e.type,e.handle,'')
#sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,'']).start()
elif e.type==mesh.MESSAGE_MULTI or e.type==mesh.MESSAGE_UNI :
game_sharing.sharing_handler(e.type,e.handle,e.content)
#sharing_thread = threading.Thread(target = game_sharing.sharing_handler, args=[e.type,e.handle,e.content]).start()
desktop2.update()
desktop2.draw()
pygame.display.update()
threades.total_update_flag = True
示例5: __init__
def __init__(self):
''' Draws the Facilities panel
'''
self.update_flag = True
myfont1 = pygame.font.Font("font.ttf", threades.resize_pt(20)) # For model.resources name and their value
self.name_labels = []
self.labelstyle1 = gui.defaultLabelStyle.copy()
self.labelstyle1['border-width'] = 0
self.labelstyle1['wordwrap'] = False
self.labelstyle1['autosize'] = False
self.labelstyle1['font'] = myfont1
self.labelstyle1['font-color'] = self.font_color
#self.labelstyle1['bg-color'] = self.font_bg_color
self.list_titles = model.text_file.facilities_list
self.list_names = [model.text_file.num_text[0]+': ']
self.list_values1 = (model.House.get_number(),model.School.get_number(),model.Hospital.get_number(),model.Workshop.get_number(),model.Farm.get_number(),model.Fountain.get_number())
self.list_values2 = (model.House.get_level(),model.School.get_level(),model.Hospital.get_level(),model.Workshop.get_level(),model.Farm.get_level(),model.Fountain.get_level())
self.value_labels = []
for i in range(6):
label = gui.Label(position = threades.resize_pos((950,50+55*i)),size = threades.resize_pos((300,30)), parent = threades.desktop, text = self.list_titles[i], style = self.labelstyle1)
self.name_labels.append(label)
label = gui.Label(position = threades.resize_pos((950,75+55*i)),size = threades.resize_pos((300,30)), parent = threades.desktop, text = self.list_names[0]+str(int(self.list_values1[i]))+model.text_file.level_text[0]+':'+str(int(self.list_values2[i])), style = self.labelstyle1)
self.name_labels.append(label)
label.surf.set_alpha(200)
self.value_labels.append(label)
示例6: pause_screen
def pause_screen(pause_flag = True):
start = starting_intro()
start.main_menu(pause_flag,threades.game_save_flag)
logo = pygame.image.load(os.path.join('data', 'logo.png')).convert()
ff_logo = pygame.transform.scale(logo,threades.resize_pos((1128,171)))
threades.audio.play_music(False,'soundtrack')
while start.run:
pygame.display.set_caption('FoodForce2')
threades.screen.fill((0,0,0))
threades.screen.blit(ff_logo,threades.resize_pos((40,90)))
for e in gui.setEvents(pygame.event.get()):
if e.type == pygame.QUIT:
safe_exit()
if e.type == QUIT:
safe_exit()
#print 'in pause screen'
desktop2.update()
desktop2.draw()
pygame.display.update()
threades.audio.play_music(True,'soundtrack')
threades.total_update_flag = True
示例7: chatWindow
def chatWindow(self, windowtext=None):
""" Opens a new chat window
"""
global desktopChat
global move_to_next_chatwin_flag
move_to_next_chatwin_flag = False # so that the next window waits for the user to press enter
# Disable other gui
gui_buttons.gui_obj.disable_buttons()
# Stopping the updation thread
threades.pause_update_thread()
# Custom Window Style
win_style = gui.defaultWindowStyle.copy()
win_style["bg-color"] = (0, 0, 0)
# Calculating position and size of window from the size of the desktop
position_win = threades.resize_pos((150.0, 50.0))
size_win = threades.resize_pos((900, 800))
# print 'size win is',size_win,'\n'
# Creating window
self.chatWin = gui.Window(
position=position_win,
size=size_win,
parent=desktopChat,
text="",
style=win_style,
closeable=False,
shadeable=False,
moveable=False,
)
self.chatWin.surf.fill((0, 0, 0, 140))
self.chatWinFlag = True
# NOTE: This part will be used once we know how to blit buttons on the chat window
# self.button_skip = gui.Button(position = threades.resize_pos((500.0,10.0),(900.0,800.0),self.size_win), size = threades.resize_pos((80.0,30.0),(900.0,800.0),self.size_win), parent = self.chatWin, text = "Skip",style = self.button_style)
# self.button_next = gui.Button(position = threades.resize_pos((200.0,10.0),(900.0,800.0),self.size_win), size = threades.resize_pos((80.0,30.0),(900.0,800.0),self.size_win), parent = self.chatWin, text = "Next >",style = self.button_style)
# self.button_skip.onClick=self.closeChatWindow
# self.button_skip.onMouseOver=self.closeChatWindow
# print self.button_skip.enabled
# creating label for writing the text
self.label = gui.Label(
position=threades.resize_pos((100.0, 760.0), (900.0, 800.0), self.chatWin.size),
size=threades.resize_pos((700.0, 30.0), (900.0, 800.0), self.chatWin.size),
parent=self.chatWin,
text=model.text_file.proceed_text[0],
style=self.labelStyleCopy,
)
示例8: update
def update(self):
for i in range(len(model.facilities_list)):
if not (self.list_num_fac[i] == model.facilities_list[i].get_original_number()):
self.update_flag = True
if self.update_flag or threades.map_update_flag or threades.total_update_flag:
threades.screen.blit(self.map,threades.resize_pos((930,390)))
posn = threades.resize_pos((930+int(3200/33.3),390+int(2600/28.57)))
threades.screen.blit(load_images.Map_images[6],posn)
for i in range(len(model.facilities_list)):
for j in range(model.facilities_list[i].get_original_number()):
posn = threades.resize_pos((930+int(load_images.facilities_posn_list[i][j][0]/33.3),390+int(load_images.facilities_posn_list[i][j][1]/28.57)))
threades.screen.blit(load_images.Map_images[i],posn)
self.update_flag = False
示例9: tradingWindow
def tradingWindow(self,handle,buddyName = 'Friend',resource = 'Water', quantity = '0' ,price = '10',trade = 'sell'):
'''Opens the trading window at the reciever end for trading
'''
#self.font_color = (255,214,150) # Brown
self.replyhandle = handle
self.replymessage = ['TradeReply',resource,quantity,price,trade]
color_blue = (0,0,250)
myfont = pygame.font.Font("font.ttf", threades.resize_pt(17))
# Custom Window Style
win_style = gui.defaultWindowStyle.copy()
win_style['font'] = myfont
win_style['bg-color'] = (0,0,0)
win_style['font-color'] = color_blue
# Calculating position and size of window from the size of the desktop
position_win =threades.resize_pos((725.0,42.0))
size_win =threades.resize_pos((470.0,180.0))
# Creating custom label style for the text to be displayed as a message
labelStyleCopy = gui.defaultLabelStyle.copy()
labelStyleCopy['wordwrap'] = True
labelStyleCopy['autosize'] = False
labelStyleCopy['font'] = myfont
labelStyleCopy['font-color'] = color_blue
#labelStyleCopy['font-color'] = font_color
self.win = gui.Window(position = position_win, size = size_win, parent = threades.desktop, text = "Trade " ,style = win_style,shadeable = False, moveable = False)
# Creating label
label_text = '\n'+buddyName + ' wants to ' + trade + ' ' + quantity + ' units of '+ resource + '\n at $ '+ price
message_label = gui.Label(position = threades.resize_pos((5,5),(470.0,180.0),self.win.size),size = threades.resize_pos((460,120),(470.0,180.0),self.win.size), parent = self.win, text = label_text, style = labelStyleCopy)
# Creating button style
myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(16))
button_style = gui.defaultButtonStyle.copy()
button_style['font'] = myfont2
self.button_accept = gui.Button(position = threades.resize_pos((100.0,130.0),(470.0,180.0),size_win), size = threades.resize_pos((100.0,40.0),(470.0,180.0),size_win), parent = self.win, text = " Accept ",style = button_style)
self.button_reject = gui.Button(position = threades.resize_pos((300.0,130.0),(470.0,180.0),size_win), size = threades.resize_pos((100.0,40.0),(470.0,180.0),size_win), parent = self.win, text = " Reject ",style = button_style)
self.button_accept.onClick = self.checkTrade
self.button_reject.onClick = self.closeWin
sleep(6)
if self.win:
self.win.close()
示例10: message_window
def message_window():
''' Thread to display the messages'''
font_color = (255,214,150)
myfont = pygame.font.Font("font.ttf", threades.resize_pt(17))
# Custom gui.Window Style
win_style = gui.defaultWindowStyle.copy()
win_style['font'] = myfont
win_style['bg-color'] = (0,0,0)
# Calculating position and size of window from the size of the threades.desktop
position_win =threades.resize_pos((745.0,42.0))
size_win =threades.resize_pos((450.0,150.0))
# Creating custom label style for the text to be displayed as a threades.message
labelStyleCopy = gui.defaultLabelStyle.copy()
labelStyleCopy['wordwrap'] = True
labelStyleCopy['autosize'] = False
labelStyleCopy['font'] = myfont
#labelStyleCopy['font-color'] = font_color
while True:
(text,color) = threades.message.pop_message()
if text:
# Creating window
win_style['font-color'] = color
labelStyleCopy['font-color'] = color
win = gui.Window(position = position_win, size = size_win, parent = threades.desktop, text = "Message " ,style = win_style ,closeable = False ,shadeable = False,moveable = False)
pygame.draw.rect(win.surf,color,threades.resize_rect((3,3,444,144)),1)
#win.surf.set_alpha(160)
# Creating label
message_label = gui.Label(position = threades.resize_pos((5,50),(450.0,150.0),win.size),size = threades.resize_pos((440,140),(450.0,150.0),win.size), parent = win, text = text, style = labelStyleCopy)
sleep(6)
win.close()
if threades.GAME_EXIT_FLAG:
return
sleep(1)
if threades.GAME_EXIT_FLAG:
return
sleep(1)
if threades.GAME_EXIT_FLAG:
return
示例11: update
def update(self):
for i in range(len(model.facilities_list)):
if not (self.list_num_fac[i] == model.facilities_list[i].get_original_number()):
self.update_flag = True
if self.update_flag or threades.map_update_flag or threades.total_update_flag:
threades.screen.blit(self.map,threades.resize_pos((930,390)))
posn = threades.resize_pos((930+int(3200/23.22),390+int(2600/24.80)))
threades.screen.blit(load_images.Map_images[6],posn)
for i in range(len(model.facilities_list)):
for j in range(model.facilities_list[i].get_original_number()):
posn = threades.resize_pos((930+int(model.facilities_list_sprites[model.facilities_list[i].get_name()][j].position[0]/23.22),390+int(model.facilities_list_sprites[model.facilities_list[i].get_name()][j].position[1]/24.80)))
threades.screen.blit(load_images.Map_images[i],posn)
rect_draw = threades.transform_obj.village_boundary_covered()
rect_final = threades.resize_rect((930+rect_draw[0]/23.22, 390 + rect_draw[1]/24.80, (rect_draw[2]-rect_draw[0])/23.22, (rect_draw[3]-rect_draw[1])/24.80))
pygame.draw.rect(threades.screen, (47, 47, 255, 180), rect_final, 2)
self.update_flag = False
示例12: __init__
def __init__(self):
pygame.sprite.Sprite.__init__(self)
mask= pygame.surface.Surface(threades.resize_pos((930,600)),SRCALPHA)
mask.fill((0,0,0,0))
self.clock = pygame.time.Clock()
self.time = 0
#mask.set_alpha(0)
self.alpha = 0
self.image = mask
self.rect = self.image.get_rect()
self.rect.move(threades.resize_pos((0,0)))
self.counter = 0
self.prev_disp = (0,0)
self.move_dir = [(-20,-20),(-20,-10),(-20,0),(-20,10),(-20,20),(-10,-20),(-10,-20),(-10,0),(-10,10),(-10,20),(0,-20),(0,-10),(0,0),(0,10),(0,20),(10,-20),(10,-20),(10,0),(10,10),(10,20),(20,-20),(20,-10),(20,0),(20,10),(20,20)]
# To close all open windows
if gui_buttons.gui_obj.get_child_win_flag():
gui_buttons.gui_obj.close_child_win()
gui_buttons.gui_obj.close_win()
elif gui_buttons.gui_obj.get_win_flag():
gui_buttons.gui_obj.close_win()
示例13: update_value
def update_value(self):
''' Updates the model.resources panel
'''
self.money_flag = False
for i in range(11):
if not (self.value_labels[i].text == str(int(model.resources[i].get_vquantity()))):
self.update_flag = True
if self.update_flag or threades.panel_update_flag or threades.total_update_flag:
pygame.draw.line(threades.screen,self.color_grey,threades.resize_pos((400,645)),threades.resize_pos((400,855)),1)
pygame.draw.line(threades.screen,self.color_grey,threades.resize_pos((650,645)),threades.resize_pos((650,855)),1)
for i in range(11):
if not (self.value_labels[i].text == str(int(model.resources[i].get_vquantity()))):
self.value_labels[i].text = str(int(model.resources[i].get_vquantity()))
if not (self.money_label.text == model.text_file.money_text[0] +' -: '+str(int(model.money.get_money()))+' '):
self.money_flag = True
self.money_label.text = model.text_file.money_text[0] +' -: '+str(int(model.money.get_money()))+' '
#print 'no of days is',model.game_controller.get_days()
if self.time_flag==True:
#self.time_label.text=''
#NOTE: Here, I am not adding as if years is not 0 , then only it will be blitted becoz if do like that the things will keep on changing, not a nice view
self.time_label.text= model.text_file.time_text[0]+' -: '+model.text_file.time_text[2]+': '+str(model.game_controller.get_years())+' '+model.text_file.time_text[3]+': '+str(model.game_controller.get_months()) +' '+model.text_file.time_text[4]+': '+str(model.game_controller.get_days())
self.time_flag=True
#to update the money flag
#print 'global_time is',model.game_controller.get_global_time(),'while the time_help_value is',self.time_help_value
if (model.game_controller.get_global_time()>((model.game_controller.conversion_factor)+self.time_help_value)):
self.time_flag=True
self.time_help_value=model.game_controller.get_global_time()
self.update_flag = False
示例14: __init__
def __init__(self):
''' Constructor
'''
global background_image
self.chatWinFlag = False
#Initialises the chat window
self.position = threades.resize_pos((15,10))
self.initial_position = threades.resize_pos((15,10))
self.final_position = threades.resize_pos((15,750))
self.update_win_pos=pygame.Rect(threades.resize_pos((150.0,50.0)),threades.resize_pos((900,800)))
self.imageBox = pygame.image.load(os.path.join('storyboards','storyboard1','images','chat images', 'imageBox.png')).convert_alpha()
self.chatBox = pygame.image.load(os.path.join('storyboards','storyboard1','images','chat images', 'chatBox.png')).convert_alpha()
#list for storing the images loaded in the chatbox
self.characterImage={}
if model.storyboard_file == 'storyboard1/storyboard.pkl':
self.characterImage['KAMAT']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'kamat.png')).convert_alpha()
self.characterImage['SON']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'son.png')).convert_alpha()
self.characterImage['AJMAL']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'ajmal.png')).convert_alpha()
self.characterImage['PANCH']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'panch.png')).convert_alpha()
self.characterImage['PRIEST']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'priest.png')).convert_alpha()
self.characterImage['SUKHDEV']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'sukhdev.png')).convert_alpha()
self.characterImage['FARMER']=pygame.image.load(os.path.join('storyboards','storyboard1','images','character images', 'villager.png')).convert_alpha()
else:
self.characterImage['TONY PERALTA']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'tony.png')).convert_alpha()
self.characterImage['STEVENSON GORBACHEV']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'stevenson.png')).convert_alpha()
self.characterImage['GILBERT FERNANDEZ']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'gilbert.png')).convert_alpha()
self.characterImage['JOHN TREMBLAY']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'john.png')).convert_alpha()
self.characterImage['RAGNAR STEFANSSON']=pygame.image.load(os.path.join('storyboards','storyboard2','images','character images', 'ragnar.png')).convert_alpha()
# changes made while adding skip buttons etc
self.size_win =threades.resize_pos((900.0,800.0))
self.myfont = pygame.font.Font("font.ttf", threades.resize_pt(16))
self.button_style=gui.defaultButtonStyle.copy()
self.button_style['font']=self.myfont
#crating label textsurface
#myfont = pygame.font.Font("font.ttf",10)
#textColor = (0,0,0)
#self.label_text=' ENTER : To show whole chat at once ESC : To skip chat '
#self.label_textsurface=gui.renderText(self.label_text,myfont,True,textColor,(700,20),False,True)
#self.label_tempSurface = pygame.transform.scale(self.chatBox,(800,30))
#creating a label for the chat window
self.label_text=' ENTER : To show whole chat ESC : To skip chat '
self.myfont2 = pygame.font.Font("font.ttf", threades.resize_pt(20))
self.labelStyleCopy = gui.defaultLabelStyle.copy()
self.labelStyleCopy['border-width'] = 1
self.labelStyleCopy['wordwrap'] = True
self.labelStyleCopy['autosize'] = False
self.labelStyleCopy['font'] = self.myfont2
self.labelStyleCopy['font-color'] = (255,214,150)
self.labelStyleCopy['border-color'] = (255,214,150)
示例15: new_level_stats
def new_level_stats(self,data_file,graphics_file,level_no=-1):
#global total_update_flag
global animation_obj
threades.pause_update_thread()
self.graphics()
self.level_no=level_no
self.data_file=data_file
self.graphics_file=graphics_file
self.run=True
level_updater=threading.Thread(target=self.level_reinit,args=[]).start()
pygame.display.set_caption('FoodForce2')
threades.screen.fill((0,0,0))
threades.screen.blit(self.ff_logo,threades.resize_pos((40,50)))
desktop_level.update()
desktop_level.draw()
pygame.display.update()
while 1 :
for e in gui.setEvents(pygame.event.get()):
if e.type == pygame.QUIT:
print 'in pygame.quit'
safe_exit()
if e.type == QUIT:
print 'in quit'
safe_exit()
#if level_updater.is_alive()==False:
# self.run=False GREAT THIS IS APPLICABLE ONLY WITH PYTHON 2.6, SO HAVE TO SEARCH SOME OTHER MEANS
if self.run==False:
break
#print 'now reached here\n'
self.ff_logo = 0
threades.initialize_facilities(True)
threades.set_build_facility_placement_flag()
threades.facility_placement_data_obj.clear_placement_data()
#threades.current_level = proceduralFlow.storyboard_level
threades.total_update_flag = True
threades.resume_update_thread()