class ToolBar(Bar): def __init__(self,x,y,friends,place,other,goal,image=str('taskbar.png')): Bar.__init__(self,x,y,friends,place,image) self.lives = Lives(self.rect.x+353,self.rect.y+71,self.group,self.screen,str('5lives.png')) self.goRect = pygame.Rect(717,658,118,75) self.barGoal = Goal(self.rect.x+605,self.rect.y+70,self.group) self.barGoal.resize(40,40) self.score = Score(250,665,friends,self.screen,2000,26,(0,0,0)) self.arrow = Arrow(872,665,friends,self.screen) self.menuWidget = MenuWidget(self.rect.x+694,723,self.group,self.screen,self.arrow) self.itemsTab = ItemsTab(self.rect.x-912,self.rect.y+15,self.group,self.screen,-917,-954,-3) self.game = other self.grabbed = None self.item_one_reset() self.items_one_limit = 1 self.items_one_placed = 0 self.items_two_limit = 0 self.items_two_placed = 0 self.items_three_placed = 0 self.items_three_limit = 0 self.goal = goal def lives_over(self): self.lives.no_lives() def lives_update(self): self.lives.update() def reset_lives(self): #print "resetting lives" self.lives.back_to_three(False) def reset_lives_over(self): self.lives.back_to_three(True) def update(self,pos=(0,0)): if self.grabbed != None: self.grabbed.update(pos,self) def clear_grabbed(self): if self.grabbed != None: self.grabbed.dropped() self.grabbed = None def collision_test(self,pos,player,button): if self.goRect.collidepoint(pos) and not self.itemsTab.open and not self.menuWidget.open and button == 1: player.makeANew = True elif self.goRect.collidepoint(pos) and not self.itemsTab.open and not self.menuWidget.open and button == 3: return True elif self.itemsTab.items_rect.collidepoint(pos) and not self.menuWidget.open: self.grabbed = self.itemsTab elif self.menuWidget.widget_rect.collidepoint(pos) and not self.itemsTab.open: self.grabbed = self.menuWidget elif self.menuWidget.quit_rect.collidepoint(pos): self.game.quit() elif self.items_one.collidepoint(pos) and self.itemsTab.open and self.items_one_placed < self.items_one_limit: x,y = pos x -= 30 y -= 30 self.grabbed = UserPlanet(x,y,60,60,25,self.game.userPlacedObjects,self.group,self.game.obstacles,self,player,1,self.goal,str('rockplanet.png')) self.items_one_placed += 1 if self.items_one_placed >= self.items_one_limit: self.items_one.x = -30 self.itemsTab.rock_item.dark() elif self.itemsTab.earth_item.rect.collidepoint(pos) and self.itemsTab.open and self.itemsTab.earth_item and self.items_two_placed < self.items_two_limit: #print "touch earth" x,y = pos x -= 30 y -= 30 self.grabbed = UserPlanet(x,y,65,65,30,self.game.userPlacedObjects,self.group,self.game.obstacles,self,player,2,self.goal,str('ringed.png')) self.items_two_placed += 1 #print self.items_two_placed if self.items_two_placed >= self.items_two_limit: self.itemsTab.earth_item.dark() elif self.itemsTab.venus_item.rect.collidepoint(pos) and self.itemsTab.open and self.itemsTab.venus_item and self.items_three_placed < self.items_three_limit: #print "touch venus" x,y = pos x -= 30 y -= 30 self.grabbed = UserPlanet(x,y,68,68,40,self.game.userPlacedObjects,self.group,self.game.obstacles,self,player,3,self.goal,str('venus.png')) self.items_three_placed += 1 if self.items_three_placed >= self.items_three_limit: self.itemsTab.venus_item.dark() elif self.menuWidget.instructions_rect.collidepoint(pos) and self.menuWidget.open: self.game.inStructionees() elif self.menuWidget.save_rect.collidepoint(pos) and self.menuWidget.open: self.game.saveFile() return False def item_one_reset(self): self.items_one_placed = 0 self.items_one = pygame.Rect(119,667,55,45) self.itemsTab.rock_item.light() def item_two_reset(self): self.items_two_placed = 0 self.itemsTab.earth_item.light() def item_three_reset(self): self.items_three_placed = 0 self.itemsTab.venus_item.light() def next_level(self,level,reset_lives_bool): #print level-2 self.barGoal.change_image(self.images[level-2]) if level != 3: self.barGoal.resize(40,40) else: self.barGoal.resize(57,40) self.item_one_reset() if reset_lives_bool: self.reset_lives() self.nextPosition += 1 if level == 2: self.item_two_reset() self.items_two_limit = 1 elif level == 3: self.item_three_reset() self.items_two_limit = 1 self.items_three_limit = 1 self.item_two_reset() self.item_one_reset() elif level == 4: self.item_three_reset() self.items_two_limit = 1 self.items_three_limit = 1 self.item_two_reset() self.item_one_reset()