Exemplo n.º 1
0
    def get_random_learning_cards(self):

        # we position images, sounds and texts which will be used
        # (in case there would be more than one in some learning_cards)
        for learning_card in self.learning_cards:
            learning_card.select_random_elements()

        # the amount of draggable items will be a random value between min_draggable and max_draggable
        amount_draggable = self.min_draggable + random.randint(
            0, self.max_draggable - self.min_draggable)

        cards_amount = len(self.item_areas)

        self.learning_cards_to_display = []

        for i in range(cards_amount):

            for learning_card in self.learning_cards:
                if (learning_card.selected == False):
                    if (learning_card not in self.learning_cards_to_display):
                        self.learning_cards_to_display.append(learning_card)

                        break
            else:
                # if all the learning_cards were found, there's nothing more to draw !
                raise common.EndActivityException()

        return
Exemplo n.º 2
0
	def __init__(self, game, globalvars) :
	
		common.info("Running transformation activity")

		game = Transform_game(game, globalvars.main_language)

		common.Run_Screen.__init__(self, globalvars, game)	

		self.current_page = Page_transform(globalvars, self.game.get_transformation(), self.game)
	
		self.current_page.draw()
		pygame.display.flip()
	

		while self.running :

			common.Run_Screen.run_pre(self)

			# actions after keyboard events

			for key_event in self.key_events :
								
				if key_event.key == K_SPACE :
					if (self.current_page.transformation.done == True) :
						self.current_page = next_page(self.current_page, self.game, globalvars)
						if (self.current_page == None) :
							return
	
			# actions for mouse actions
			if (self.mouse_clicked == True) :
			
				clicked = self.current_page.was_something_clicked(self.mouse_pos, self.mousebutton)
		
				if (clicked != None) :
					(component_clicked, xml_file, some_dirty_rects) = clicked

					if (component_clicked == self.current_page.quit_icon) :
						raise common.EndActivityException()

					elif (component_clicked == self.current_page.next_icon) :
						self.current_page = next_page(self.current_page, self.game, globalvars)

						if (self.current_page == None) :
							return
		
					self.dirty_rects = self.dirty_rects + some_dirty_rects

			
			# let's see if we have some image part to unveil
	
			mouse_pos = pygame.mouse.get_pos()

			if (self.current_page.image.rect.collidepoint(mouse_pos)) :
				self.dirty_rects = self.dirty_rects + self.current_page.unveil(mouse_pos)


		
			common.Run_Screen.run_post(self)
Exemplo n.º 3
0
	def __init__(self, game, globalvars, total_score) :

		common.info("Running differences activity")

		game = Differences_game(game, total_score)
		
		game.select_random_differences()

		common.Run_Screen.__init__(self, globalvars, game)

		self.current_page = Page_differences(self.game, globalvars)
		
		self.current_page.draw()
		
		pygame.display.flip()

		game.start_timer()

		while self.running :

			common.Run_Screen.run_pre(self)

			# actions after keyboard events

			for key_event in self.key_events :
								
				if key_event.key == K_SPACE :
					if (self.current_page.completed == True) :
						self.running = False


				
			if (self.mouse_clicked == True) :
				
				clicked = self.current_page.was_something_clicked(self.mouse_pos, self.mousebutton)
					
				if (clicked != None) :
					(component_clicked, foo, some_dirty_rects) = clicked
		
					if (component_clicked == self.current_page.quit_icon) :
						raise common.EndActivityException()

					elif (component_clicked == self.current_page.next_icon) :
						self.running = False

					self.dirty_rects = self.dirty_rects + some_dirty_rects

			common.Run_Screen.run_post(self)
Exemplo n.º 4
0
	def __init__(self, game, globalvars, total_score) :
	
		common.info("Running puzzle activity")

		game = Puzzle_game(game, globalvars.main_language, total_score)

		common.Run_Screen.__init__(self, globalvars, game)	

		self.current_page = next_page(self.game, globalvars)
	

		while self.running :

			common.Run_Screen.run_pre(self)

			# actions after keyboard events

			for key_event in self.key_events :
								
				if key_event.key == K_SPACE :
					if (self.current_page.puzzle.done == True) :
						self.current_page.fade_out()
						self.current_page = next_page(self.game, globalvars)
						if (self.current_page == None) :
							return
	
			# actions for mouse actions
			if (self.mouse_clicked == True) :
			
				clicked = self.current_page.was_something_clicked(self.mouse_pos, self.mousebutton)
		
				if (clicked != None) :
					(component_clicked, xml_file, some_dirty_rects) = clicked

					if (component_clicked == self.current_page.quit_icon) :
						raise common.EndActivityException()

					elif (component_clicked == self.current_page.next_icon) :
						self.current_page.fade_out()
						self.current_page = next_page(self.game, globalvars)

						if (self.current_page == None) :
							return
		
					self.dirty_rects = self.dirty_rects + some_dirty_rects
		
			common.Run_Screen.run_post(self)
Exemplo n.º 5
0
    def __init__(self, game, globalvars, total_score):

        common.info("Running association game")

        game = Associate_game(game, globalvars.main_language, total_score)

        common.Run_Screen.__init__(self, globalvars, game)

        self.current_page = next_page(self.game, self.globalvars)

        while self.running:

            common.Run_Screen.run_pre(self)

            # actions after keyboard events

            goto_next_page = False

            for key_event in self.key_events:

                if (key_event.key == K_SPACE):
                    if (self.current_page.completed == True):
                        goto_next_page = True

            if (self.mouse_clicked == True):

                clicked = self.current_page.was_something_clicked(
                    self.mouse_pos, self.mousebutton)

                if (clicked != None):
                    (component_clicked, foo, some_dirty_rects) = clicked

                    # we try to play an associated sound (if any)
                    component_clicked.play_random_associated_sound()

                    if (component_clicked == self.current_page.quit_icon):
                        raise common.EndActivityException()

                    elif (component_clicked == self.current_page.next_icon):

                        goto_next_page = True

                    elif ((component_clicked.associated_object != None)
                          and (self.mousebutton == 3)):

                        # right click on an item (draggable or to associate)
                        # it will be displayed in big

                        if (component_clicked not in self.current_page.goals):
                            association = component_clicked.associated_object

                            if (component_clicked
                                    in self.current_page.items_to_associate):
                                (
                                    text, image_file, associated_sounds
                                ) = association.get_infos_for_display_big_to_associate(
                                )
                            else:
                                (
                                    text, image_file, associated_sounds
                                ) = association.get_infos_for_display_big_to_drag(
                                )

                            if (image_file != None):

                                if (self.current_page.completed == False):
                                    self.game.stop_timer()

                                self.current_page.fade_out()

                                display_big.Run_Display_Big(
                                    self.globalvars, text, image_file,
                                    associated_sounds)

                                # redraw the whole screen
                                self.current_page.draw()

                                some_dirty_rects = [self.screen.get_rect()]

                                self.mouse_clicked = False

                                if (self.current_page.completed == False):
                                    self.game.start_timer()

                    self.dirty_rects = self.dirty_rects + some_dirty_rects

            # mouse may be going over elements

            if (self.current_page.dragged_sprite == None):

                # yet mouse over is checked only when no object is being dragged

                (mouse_over_new,
                 mouse_over_old) = self.current_page.components_mouse_over(
                     pygame.mouse.get_pos())

                if (mouse_over_old != None):
                    self.dirty_rects = self.dirty_rects + self.current_page.remove_legend_text(
                    )

                if (mouse_over_new != None):
                    self.dirty_rects = self.dirty_rects + self.current_page.add_legend_text(
                        mouse_over_new)

            if (goto_next_page == True):
                self.current_page.fade_out()

                ####self.total_time = self.total_time + self.current_page.timer.getValue()

                self.current_page = next_page(self.game, globalvars)

                if (self.current_page == None):
                    return

            common.Run_Screen.run_post(self)
Exemplo n.º 6
0
    def __init__(self, game, globalvars):

        common.info("Running learning game")

        game = Learning_game(game, globalvars.main_language)

        common.Run_Screen.__init__(self, globalvars, game)

        self.current_page = next_page(self.game, self.globalvars)

        while self.running:

            common.Run_Screen.run_pre(self)

            # actions after keyboard events

            goto_next_page = False

            for key_event in self.key_events:

                if (key_event.key == K_SPACE):
                    if (self.current_page.completed == True):
                        goto_next_page = True

            if (self.mouse_clicked == True):

                clicked = self.current_page.was_something_clicked(
                    self.mouse_pos, self.mousebutton)

                if (clicked != None):
                    (component_clicked, foo, some_dirty_rects) = clicked

                    # we try to play an associated sound (if any)
                    component_clicked.play_random_associated_sound()

                    if (component_clicked == self.current_page.quit_icon):
                        raise common.EndActivityException()

                    elif (component_clicked == self.current_page.next_icon):

                        goto_next_page = True

                    self.dirty_rects = self.dirty_rects + some_dirty_rects

            # mouse may be going over elements

            if (self.current_page.dragged_sprite == None):

                # yet mouse over is checked only when no object is being dragged

                (mouse_over_new,
                 mouse_over_old) = self.current_page.components_mouse_over(
                     pygame.mouse.get_pos())

                if (mouse_over_old != None):
                    self.dirty_rects = self.dirty_rects + self.current_page.remove_legend_text(
                    )

                if (mouse_over_new != None):
                    self.dirty_rects = self.dirty_rects + self.current_page.add_legend_text(
                        mouse_over_new)

            if (goto_next_page == True):
                self.current_page.fade_out()

                self.current_page = next_page(self.game, globalvars)

                if (self.current_page == None):
                    return

            common.Run_Screen.run_post(self)