def init_buttons(self): i_exit=functions.iExit() #button functions i_run=functions.iRun() i_menu=functions.iMenu() f_s = 20 #font size b_s = 5 #border size textbuttons = [objects.t_button(55, 430, "Run", i_run, f_s, b_s, MAGENTA, GREEN, "run"), \ objects.t_button(295,430, "Stop", i_menu, f_s, b_s, BLUE, YELLOW, ), \ objects.t_button(555,430, "EXIT", i_exit, f_s, b_s, BLACK, RED)] #t_y=textlabels.height+textlabels.pos_y+100 t_y=345 self.buttons = objects.WidgetsPack(560, t_y, 45, False, textbuttons)
def set_labels(t_score, t_time, l_score, l_time): i_exit = functions.iExit() if l_time: sss = objects.t_label(270, 310, "last level time - "+str(l_time), i_exit, 16, 1, MAGENTA, WHITE) t_time.add_wig(sss) if l_score: sss = objects.t_label(270, 310, "last score - "+str(l_score), i_exit, 16, 1, RED, WHITE) t_score.add_wig(sss) rrr=functions.load_rec() kkk=rrr.keys() kkk.sort() for iii in kkk: vvv=rrr[iii] sss = objects.t_label(270, 310, str(vvv[1]), i_exit, 16, 1, MAGENTA, YELLOW) t_time.add_wig(sss) sss = objects.t_label(270, 310, str(vvv[0]), i_exit, 16, 1, YELLOW, BLUE) t_score.add_wig(sss)
def mainrun(scr_params=((640,480),0,32), lvl=0, g_score=0): """mainrun(scr_params=((640,480),0,32), lvl=0 g_score=0) - screen of level story scene in ImpactuX""" i_exit=functions.iExit() #button functions i_run=functions.iRun() i_menu=functions.iMenu() #ending_play=functions.Ending_play() button_press_checking=functions.Button_press_checking() #init vars f_s = 20 #font size b_s = 5 #border size if lvl in range(10): bgif="."+os.sep+"pic"+os.sep+"bg_story_"+str(lvl)+".jpg" else: bgif="."+os.sep+"pic"+os.sep+"bgstart.jpg" #soif1="."+os.sep+"sounds"+os.sep+"s1.ogg" l_text = get_text_lvl(lvl) pygame.init() screen=pygame.display.set_mode(scr_params[0], scr_params[1], scr_params[2]) background=pygame.image.load(bgif).convert() textbuttons = \ [objects.t_button(55, 430, "Start round", i_run, f_s, b_s, BLACK, WHITE), \ objects.t_button(295,430, "Cancel", i_menu, f_s, b_s, WHITE, RED), \ objects.t_button(555,430, "EXIT", i_exit, f_s, b_s, BLACK, RED)] textbuttons = objects.WidgetsPack(30, 430, 240, True, textbuttons) textlabels = [objects.t_label(20, 380, l_text, i_exit, 16, 1, BLUE, YELLOW), \ objects.t_label(270, 230, "ImpactuX", i_exit, 32, 1, RED, None)] if g_score>0: sss = objects.t_label(270, 310, "Score: "+str(g_score), i_exit, 20, 1, CYAN, None) textlabels.append(sss) #font1=pygame.font.Font("."+os.sep+"fonts"+os.sep+"LiberationSans-Regular.ttf", 18) pygame.display.set_caption("ImpactuX story "+str(lvl+1)) clock = pygame.time.Clock() run_now = True ####### main loop section ####### while run_now: clock.tick(30) #t=pygame.time.delay(100) for event in pygame.event.get(): if event.type == QUIT: i_exit() #ending_play() return i_exit() if event.type == KEYUP: if event.key == K_ESCAPE: run_now=False return i_exit() elif event.type == MOUSEBUTTONDOWN: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEMOTION: x_n0, y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEBUTTONUP: if int(event.button) == 1: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) return check_tb[1].doing() screen.blit(background, (0,0)) #textbuttons.show_at(screen) textbuttons.show_at(screen) for b_obj in textlabels: b_obj.show_at(screen) #pygame.display.update() pygame.display.flip()
def mainrun(scr_params=((640,480),0,32),last_time=None, last_score=None): """mainrun(scr_params=((640,480),0,32), lvl=0 g_score=0) - screen of level story scene in ImpactuX""" i_menu=functions.iMenu() i_exit = functions.iExit() #button functions #ending_play=functions.Ending_play() button_press_checking=functions.Button_press_checking() #init vars f_s = 20 #font size b_s = 5 #border size bgif="."+os.sep+"pic"+os.sep+"bgrec.jpg" pygame.init() pygame.display.set_caption("ImpactuX Records") screen=pygame.display.set_mode(scr_params[0], scr_params[1], scr_params[2]) background=pygame.image.load(bgif).convert() textbuttons = \ [\ objects.t_button(295,430, "Continue", i_menu, f_s, b_s, BLACK, GREEN), \ ] textbuttons = objects.WidgetsPack(30, 430, 240, True, textbuttons) textlabels = [\ objects.t_label(20, 20, "ImpactuX Best Score", i_exit, 32, 1, RED, None), \ ] textlabels = objects.WidgetsPack(150, 20, 240, True, textlabels) text_score = [\ objects.t_label(200, 20, "Score:", i_exit, 28, 1, GREEN, None), \ ] text_score = objects.WidgetsPack(170, 60, 30, False, text_score) text_time = [\ objects.t_label(200, 20, "Time:", i_exit, 28, 1, GREEN, None), \ ] text_time = objects.WidgetsPack(350, 60, 30, False, text_time) set_labels(text_score, text_time, last_time, last_score) clock = pygame.time.Clock() run_now = True ####### main loop section ####### while run_now: clock.tick(30) #t=pygame.time.delay(100) for event in pygame.event.get(): if event.type == QUIT: i_exit() #ending_play() return i_exit() if event.type == KEYUP: if event.key == K_ESCAPE: run_now=False return i_exit() elif event.type == MOUSEBUTTONDOWN: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEMOTION: x_n0, y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEBUTTONUP: if int(event.button) == 1: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) return check_tb[1].doing() screen.blit(background, (0,0)) #textbuttons.show_at(screen) textbuttons.show_at(screen) textlabels.show_at(screen) text_score.show_at(screen) text_time.show_at(screen) #pygame.display.update() pygame.display.flip()
def mainrun(scr_params=((640,480),0,32)): """mainrun(scr_params=((640,480),0,32)) - screen of main menu ImpactuX""" #print "FULLSCREEN:--- "+str(FULLSCREEN) i_exit = functions.iExit() #button functions i_run = functions.iRun() i_setup = functions.iSetup() i_record = functions.iRecord() i_restore = functions.iRestore() #ending_play=functions.Ending_play() button_press_checking=functions.Button_press_checking() #init vars f_s = 20 #font size b_s = 5 #border size bgif="."+os.sep+"pic"+os.sep+"bgstart.jpg" i_icon="."+os.sep+"pic"+os.sep+"impactuX.png" #soif1="."+os.sep+"sounds"+os.sep+"s1.ogg" pygame.init() #screen=pygame.display.set_mode(scr_params[0], FULLSCREEN, scr_params[2]) screen=pygame.display.set_mode(scr_params[0], scr_params[1], scr_params[2]) pygame.display.set_caption("ImpactuX Menu") m_icon=pygame.image.load(i_icon).convert_alpha() pygame.display.set_icon(m_icon) background=pygame.image.load(bgif).convert() #m_icon=pygame.image.load(i_icon).convert() textbuttons = \ [objects.t_button(285, 40, "Start new game", i_run, f_s, b_s, BLACK, WHITE), \ objects.t_button(270,90, "Restore game", i_restore, f_s, b_s, BLACK, GREEN), \ objects.t_button(295,140, "Options", i_setup, f_s, b_s, BLACK, WHITE), \ objects.t_button(300,190, "Score", i_record, f_s, b_s, BLACK, GREEN), \ objects.t_button(305,240, "EXIT", i_exit, f_s, b_s, BLACK, RED)] textbuttons = objects.WidgetsPack(250, 70, 65, False, textbuttons) #textlabels = [objects.t_label(270, 390, "ImpactuX", i_exit, 32, 1, RED, None),] textbuttons.add_wig(objects.t_label(270, 390, "ImpactuX", i_exit, 32, 1, RED, None)) #objects.t_button(315,240, "EXIT", ending_play, 20, 5, BLACK, red)] #font1=pygame.font.Font("."+os.sep+"fonts"+os.sep+"LiberationSans-Regular.ttf", 18) clock = pygame.time.Clock() run_now = True ####### main loop section ####### while run_now: clock.tick(30) #t=pygame.time.delay(100) for event in pygame.event.get(): if event.type == QUIT: i_exit() #ending_play() return i_exit() if event.type == KEYUP: if event.key == K_ESCAPE: run_now=False return i_exit() elif event.type == MOUSEBUTTONDOWN: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEMOTION: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEBUTTONUP: if int(event.button) == 1: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) return check_tb[1].doing() screen.blit(background, (0,0)) textbuttons.show_at(screen) #for b_obj in textbuttons.w_list: # b_obj.show_at(screen) #for b_obj in textlabels: # b_obj.show_at(screen) #pygame.display.update() pygame.display.flip()
def mainrun(scr_params=((640,480),0,32), game_status="loose",g_score=0, g_time=0, lvl=0): """mainrun(scr_params=((640,480),0,32), game_status="lost",g_score=0, g_time=0, g_lvl=0) - screen of level ending scene in ImpactuX""" i_exit=functions.iExit() #button functions i_menu=functions.iMenu() button_press_checking=functions.Button_press_checking() #init vars f_s = 20 #font size b_s = 5 #border size end_res = get_res(game_status, lvl) pygame.init() screen=pygame.display.set_mode(scr_params[0], scr_params[1], scr_params[2]) background=pygame.image.load(end_res["bg"]).convert() textbuttons = [ \ objects.t_button(295,430, "Continue", i_menu, f_s, b_s, BLACK, GREEN), \ #objects.t_button(555,430, "EXIT", i_exit, f_s, b_s, BLACK, RED) \ ] textbuttons = objects.WidgetsPack(510, 430, 340, True, textbuttons) textlabels = [objects.t_label(240, 380, end_res["txt"], i_exit, 28, 1, MAGENTA, None), \ objects.t_label(270, 290, "ImpactuX", i_exit, 32, 1, RED, None)] if g_score>0: sss = objects.t_label(270, 310, "Score: "+str(g_score), i_exit, 20, 1, CYAN, None) textlabels.append(sss) textlabels = objects.WidgetsPack(30, 330, 35, False, textlabels) pygame.display.set_caption("ImpactuX "+end_res["caption"]) clock = pygame.time.Clock() ttt = time.time() run_now = True ####### main loop section ####### while run_now: clock.tick(30) #t=pygame.time.delay(100) for event in pygame.event.get(): if event.type == QUIT: i_exit() #ending_play() return i_exit() if event.type == KEYUP: if event.key == K_ESCAPE: run_now=False return i_exit() elif event.type == MOUSEBUTTONDOWN: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEMOTION: x_n0, y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEBUTTONUP: if int(event.button) == 1: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) return check_tb[1].doing() screen.blit(background, (0,0)) textbuttons.show_at(screen) textlabels.show_at(screen) #for b_obj in textlabels: # b_obj.show_at(screen) #pygame.display.update() n_ttt = time.time() if n_ttt-ttt>10: #print "+++++++" return 0 pygame.display.flip()
def mainrun(scr_params=((640,480),0,32)): """mainrun(scr_params=((640,480),0,32), lvl=0 g_score=0) - screen of level story scene in ImpactuX""" i_exit=functions.iExit() #button functions i_run=functions.iRun() i_menu=functions.iMenu() i_restore=functions.iRestore() i_record=functions.iRecord() #ending_play=functions.Ending_play() button_press_checking=functions.Button_press_checking() #init vars f_s = 20 #font size b_s = 5 #border size bgif="."+os.sep+"pic"+os.sep+"bgset.jpg" pygame.init() screen=pygame.display.set_mode(scr_params[0], scr_params[1], scr_params[2]) background=pygame.image.load(bgif).convert() m_list=pygame.display.list_modes() m_list.sort() m_index=m_list.index(scr_params[0]) textbuttons = \ [objects.t_button(55, 430, "Save", i_run, f_s, b_s, BLACK, GREEN), \ objects.t_button(295,430, "Cancel", i_menu, f_s, b_s, WHITE, RED), \ objects.t_button(555,430, "EXIT", i_exit, f_s, b_s, BLACK, RED)] textbuttons = objects.WidgetsPack(30, 430, 250, True, textbuttons) if scr_params[1]==0: b1_l="Set Fullscreen" else: b1_l="Set Windowed" if m_index>=(len(m_list)-1): m_next=0 else: m_next=m_index+1 buttons_sets = \ [\ objects.t_button(55, 430, b1_l, i_restore, f_s, b_s, BLACK, CYAN,"mode"), \ #objects.t_button(57, 430, "Set: "+str(m_list[m_next]), i_record, f_s, b_s, BLACK, CYAN,"resolution"), \ ] buttons_sets = objects.WidgetsPack(250, 150, 50, False, buttons_sets) textlabels = [objects.t_label(270, 230, "ImpactuX", i_exit, 32, 1, RED, None),\ objects.t_label(20, 380, "Options", i_exit, 22, 1, GREEN, None)\ ] textlabels = objects.WidgetsPack(250, 30, 30, False, textlabels) #font1=pygame.font.Font("."+os.sep+"fonts"+os.sep+"LiberationSans-Regular.ttf", 18) pygame.display.set_caption("ImpactuX settings") clock = pygame.time.Clock() run_now = True n_scr_param=scr_params[1] n_scr_res=scr_params[0] ####### main loop section ####### while run_now: clock.tick(30) #t=pygame.time.delay(100) for event in pygame.event.get(): if event.type == QUIT: i_exit() #ending_play() return i_exit() if event.type == KEYUP: if event.key == K_ESCAPE: run_now=False return i_exit() elif event.type == MOUSEBUTTONDOWN: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) check_tb=button_press_checking(x_n0,y_n0, buttons_sets.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEMOTION: x_n0, y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) check_tb=button_press_checking(x_n0,y_n0, buttons_sets.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEBUTTONUP: if int(event.button) == 1: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) ddd = check_tb[1].doing() if ddd == "run": functions.save_set(game_dict={"screen_width":n_scr_res[0],\ "screen_height":n_scr_res[1],\ "screen_flags":n_scr_param,\ "screen_depth":scr_params[2]}, \ g_file="conf_game.ini", \ g_section="screen") return ddd check_tb=button_press_checking(x_n0,y_n0, buttons_sets.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) ddd = check_tb[1].doing() if ddd == "restore": if n_scr_param==0: buttons_sets.set_named_obj_str("mode", "Set Windowed") n_scr_param='"fullscreen"' else: buttons_sets.set_named_obj_str("mode", "Set Fullscreen") n_scr_param=0 elif ddd=="record": m_index=m_next n_scr_res=m_list[m_index] if m_index>=(len(m_list)-1): m_next=0 else: m_next=m_index+1 buttons_sets.set_named_obj_str("resolution", "Set: "+str(m_list[m_next])) screen.blit(background, (0,0)) textbuttons.show_at(screen) textlabels.show_at(screen) buttons_sets.show_at(screen) pygame.display.flip()
def mainrun(scr_params=((640,480),0,32), lvl=0, balls_pos=None, g_time=0, g_score=0, n_balls=5): """mainrun(scr_params=((640,480),0,32), lvl=0, balls_pos=None, g_time=0, g_score=0) - screen of level play scene in ImpactuX""" pygame.init() i_exit=functions.iExit() #button functions i_run=functions.iRun() i_menu=functions.iMenu() #ending_play=functions.Ending_play() button_press_checking=functions.Button_press_checking() #init vars f_s = 20 #font size b_s = 5 #border size bgif="."+os.sep+"pic"+os.sep+"bgplay.jpg" #pygame.init() snd = objects.LoadedSounds(("."+os.sep+"sounds"), "ogg") #soif1="."+os.sep+"sounds"+os.sep+"s1.ogg" soif1="impactuX_click1" soif2="impactuX_click2" screen=pygame.display.set_mode(scr_params[0], scr_params[1], scr_params[2]) pygame.mouse.set_visible(False) moif0="."+os.sep+"pic"+os.sep+"impactuX1.png" moif1="."+os.sep+"pic"+os.sep+"coursorI.png" mouse_c0=pygame.image.load(moif0).convert_alpha() mouse_c1=pygame.image.load(moif1).convert_alpha() coursore_type = mouse_c0 coursore_t2 = mouse_c1 c_t2 = True #soif1="."+os.sep+"sounds"+os.sep+"s1.ogg" background=pygame.image.load(bgif).convert() time_in_game = g_time m_time = functions.sec_to_minute(g_time) pngs = objects.LoadedObj("."+os.sep+"pic") bbb=[] x_min, y_min, x_max, y_max = 20, 20, 510, 455 dx_min, dy_min, dx_max, dy_max = 1, 1, 2+lvl, lvl+2 dxy = 60 if balls_pos: n_balls=len(balls_pos) for iii in balls_pos: bbb.append(objects.AnimationObj(pngs, iii[0], \ iii[1], \ iii[2], \ iii[3], 1, 0,\ objects.dsign(iii[2]), "rock", 0, \ (x_min, y_min, x_max, y_max), True, soif1, snd)) else: for iii in range(n_balls): corrupted_b = True sign_dx=random.choice([-1,1]) while corrupted_b: bbb1=objects.AnimationObj(pngs, random.choice(xrange(x_min+dxy,x_max-dxy)), \ random.choice(xrange(y_min+dxy,y_max-dxy)), \ sign_dx*random.choice(xrange(dx_min,dx_max)), \ random.choice([-1,1])*random.choice(xrange(dy_min,dy_max)), \ 1, 0, sign_dx, "rock", 0, \ (x_min, y_min, x_max, y_max), True, soif1, snd) corrupted_b = bbb1.is_impacted_list(bbb) bbb.append(bbb1) textlabels = [objects.t_label(530, 10, "ImpactuX", i_exit, 22, 1, RED, None), \ objects.t_label(540, 40, "Paused", i_exit, 16, 1, MAGENTA, None, "status"), \ objects.t_label(540, 40, "Level: "+str(lvl+1), i_exit, 16, 1, BLUE, WHITE), \ objects.t_label(540, 40, "Score: "+str(g_score), i_exit, 16, 1, BLUE, WHITE, "score"), \ objects.t_label(540, 40, "Time: "+str(m_time[0])+":"+str(m_time[1]), i_exit, 16, 1, BLUE, WHITE, "time"), \ objects.t_label(540, 40, "Balls: "+str(n_balls), i_exit, 16, 1, BLUE, WHITE, "balls")] textlabels = objects.WidgetsPack(540, 20, 30, False, textlabels) textbuttons = \ [objects.t_button(55, 430, "Run", i_run, f_s, b_s, MAGENTA, GREEN, "run"), \ objects.t_button(295,430, "Stop", i_menu, f_s, b_s, BLUE, YELLOW, ), \ objects.t_button(555,430, "EXIT", i_exit, f_s, b_s, BLACK, RED)] #t_y=textlabels.height+textlabels.pos_y+100 t_y=345 textbuttons = objects.WidgetsPack(560, t_y, 45, False, textbuttons) #font1=pygame.font.Font("."+os.sep+"fonts"+os.sep+"LiberationSans-Regular.ttf", 18) allSprites = pygame.sprite.Group(bbb) #print allSprites pygame.display.set_caption("ImpactuX run. Level "+str(lvl+1)) clock = pygame.time.Clock() run_now = True start_runing = False last_time = time.time() c_xxx, c_yyy = x_max/2, y_max/2 x_n0, y_n0 = c_xxx, c_yyy # c_rrr = coursore_type.get_height()/2 c_rrr0 = coursore_type.get_height() c_rrr = coursore_type.get_height()/2 #c_xxx, c_yyy = 0, 0 ####### main loop section ####### while run_now: clock.tick(50) #t=pygame.time.delay(100) for event in pygame.event.get(): if event.type == QUIT: #i_exit() #ending_play() #return i_exit() pygame.mouse.set_visible(True) return "exit" #return return_vars(score_g=g_score, time_g=time_in_game, balls_g=bbb, exit_g=True) if event.type == KEYUP: if event.key == K_ESCAPE: pygame.mouse.set_visible(True) return return_vars(score_g=g_score, time_g=time_in_game, balls_g=bbb, exit_g=True) #return {"loose":False, "time":time_in_game, "score":g_score, "win":False, "exit":True} elif event.key==K_p or event.key==K_PAUSE: start_runing=not(start_runing) if start_runing: textbuttons.set_named_obj_str("run", "Pause") textlabels.set_named_obj_str("status", "Running") for o_b in bbb: o_b.stopped=False else: textbuttons.set_named_obj_str("run", "Run") textlabels.set_named_obj_str("status", "Paused") for o_b in bbb: o_b.stopped=True last_time = time.clock() elif event.type == MOUSEBUTTONDOWN: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) elif event.type == MOUSEMOTION: #c_xxx, c_yyy = event.pos #x_n0, y_n0=c_xxx, c_yyy x_n0, y_n0=event.pos if x_n0>x_max - c_rrr0+20: c_t2=True else: c_t2=False check_tb=button_press_checking(x_n0,y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) if x_n0<(x_max-c_rrr0+20): if 2<x_n0: c_xxx = x_n0 else: c_xxx = 2 else: c_xxx = x_max-c_rrr0+20 c_t2=True if y_n0<(y_max-mouse_c0.get_height()+20): if 2<y_n0: c_yyy = y_n0 else: c_yyy = 2 else: c_yyy = y_max-mouse_c0.get_height()+20 elif event.type == MOUSEBUTTONUP: if int(event.button) == 1: x_n0,y_n0=event.pos check_tb=button_press_checking(x_n0, y_n0, textbuttons.w_list) if check_tb[0]: check_tb[1].ch_state(event.type) ddd = check_tb[1].doing() if ddd == "run": start_runing=not(start_runing) if start_runing: textbuttons.set_named_obj_str("run", "Pause") textlabels.set_named_obj_str("status", "Running") for o_b in bbb: o_b.stopped=False else: textbuttons.set_named_obj_str("run", "Run") textlabels.set_named_obj_str("status", "Paused") for o_b in bbb: o_b.stopped=True last_time = time.clock() #print start_runing elif ddd == "exit": #print "Exit" pygame.mouse.set_visible(True) return return_vars(score_g=g_score, time_g=time_in_game, balls_g=bbb, exit_g=True, level_g=lvl) elif ddd == "menu": #print "Setup" pygame.mouse.set_visible(True) return return_vars(score_g=g_score, time_g=time_in_game, balls_g=bbb, level_g=lvl) if start_runing: n_time = time.time() d_time = n_time-last_time if d_time>=1: last_time = n_time+(d_time- int(d_time)) time_in_game += 1 g_score += (1+lvl) m_time = functions.sec_to_minute(time_in_game) textlabels.set_named_obj_str("score", "Score: "+str(g_score)) textlabels.set_named_obj_str("time", "Time: "+str(m_time[0])+":"+str(m_time[1])) if ((time_in_game/30.0)-int(time_in_game/30))==0: if n_balls>9: pygame.mouse.set_visible(True) return return_vars(score_g=g_score, time_g=time_in_game, balls_g=bbb, win_g=(lvl==9), winlvl_g=True, level_g=lvl) sign_dx=random.choice([-1,1]) bbb1=objects.AnimationObj(pngs, random.choice(xrange(x_min+dxy,x_max-dxy)), \ random.choice(xrange(y_min+dxy,y_max-dxy)), \ sign_dx*random.choice(xrange(dx_min,dx_max)), \ random.choice([-1,1])*random.choice(xrange(dy_min,dy_max)), \ .1, 0, sign_dx, "rock", 300, \ (x_min, y_min, x_max, y_max), False, soif1, snd) bbb.append(bbb1) n_balls = len(bbb) textlabels.set_named_obj_str("balls", "Balls: "+str(n_balls)) allSprites = pygame.sprite.Group(bbb) if start_runing: for b_1 in bbb: ch_loste = sqcheck.CheckRound(c_xxx+c_rrr, c_yyy+c_rrr, c_rrr, b_1.pos_x, b_1.pos_y, b_1.radius) ch_loste = (ch_loste and b_1.runing) if ch_loste: snd.playsnd(soif2) #pygame.mixer.quit() pygame.mouse.set_visible(True) return return_vars(score_g=g_score, time_g=time_in_game, balls_g=bbb, loose_g=True, level_g=lvl) #showing objects at screen screen.blit(background, (0,0)) allSprites.update() allSprites.draw(screen) textbuttons.show_at(screen) textlabels.show_at(screen) screen.blit(coursore_type,(c_xxx, c_yyy)) if c_t2: screen.blit(coursore_t2,(x_n0, y_n0)) #pygame.display.update() pygame.display.flip()