<file_sep>import pygame
from pygame import sprite, image, transform, draw,mask
import configuration
class WallModel(sprite.Sprite):
    def __init__(self):
        super().__init__()  
        self.image = image.load('data/sprite/wall/wall_0.png').convert_alpha()
        self.rect = pygame.Rect(0,0,0,0)<file_sep>import pygame
from pygame import sprite, image
import configuration

class GameObject(sprite.Sprite):
    def __init__(self,color = None):
        super().__init__()
       
        self.image = image.load('data/sprite/player/example.png').convert_alpha()
        self.rect = self.image.get_rect()
        self.rect.x = 200
        self.rect.y = 300
        
        self._speed_x = 0
        self._speed_y = 0
        
        self._is_alive = True
        
        self._animState = {"idle":True, "run_loop":False, "death":False}
        
        self._images = []
        
    def get_speed(self):
        return (self._speed_x,self._speed_y)
    
    def set_speed(self, speed_x=0,speed_y=0):
        self._speed_x = speed_x
        self._speed_y = speed_y
        
    def get_is_alive(self):
        return self._is_alive
    
    def get_animState(self):
        return self._animState
    
    def get_images(self):
        return self._images
    
    def get_pos(self):
        return (self.rect.x//25,self.rect.y//25)
    
    def update(self):
        self.rect.x += self._speed_x
        self.rect.y += self._speed_y
        
        self.__out_screen()
    
    def update_anim(self):
        #TODO: Hacer este caso de uso
        pass
    
    def __out_screen(self):
        if self.rect.x< - self.image.get_width():
            self.rect.x = configuration.SCREEN_WIDTH
        elif self.rect.x> configuration.SCREEN_WIDTH + self.image.get_width():
            self.rect.x = -self.image.get_width()
        elif self.rect.y< - self.image.get_height():
            self.rect.y = configuration.SCREEN_HEIGHT
        elif self.rect.y> configuration.SCREEN_HEIGHT+ self.image.get_height():
            self.rect.y = -self.image.get_height()
    
    def _set_color(self, color):
        colorImage = pygame.Surface(self.image.get_size()).convert_alpha()
        colorImage.fill(color)
        self.image.blit(colorImage, (0,0), special_flags = pygame.BLEND_RGBA_MULT)
        
    def _cheack_walls(self,walls):
        for wall in walls:
            if self.rect.colliderect(wall.rect):
                dx,dy = self.get_speed()
                if dx > 0: # Moving right; Hit the left side of the wall
                    self.rect.right = wall.rect.left
                if dx < 0: # Moving left; Hit the right side of the wall
                    self.rect.left = wall.rect.right
                if dy > 0: # Moving down; Hit the top side of the wall
                    self.rect.bottom = wall.rect.top
                if dy < 0: # Moving up; Hit the bottom side of the wall
                    self.rect.top = wall.rect.bottom
                    
    def stop_move(self):
        self.set_speed(0,0)

    def right(self,speed : int):
        self.set_speed(speed,0)

    def left(self,speed : int):
        self.set_speed(-speed,0)

    def down(self,speed : int):
        self.set_speed(0,speed)

    def up(self,speed : int):
        self.set_speed(0,-speed)<file_sep>import pygame
from pygame import sprite, image, time,transform
from audio_source import AudioSource
from game_object.gameObject import GameObject
import color
class Player(GameObject):
    def __init__(self,color, x = 300,y=300):
        super().__init__(color)
        for i in range(8):
            self._images.append(image.load('data/sprite/player/sprite_{}.png'.format(i)).convert_alpha())
        self.index = 0
        
        
        self.image = self._images[self.index]
        self.images_right = self._images
        self.images_left = [transform.flip(image_,True,False) for image_ in self._images]
        self.images_down = [transform.rotate(image_,-90)for image_ in self.images_right]
        self.images_up = [transform.rotate(image_,90)for image_ in self.images_right]
        self.dead_image = []
        for i in range(10):
            self.dead_image.append(image.load('data\\sprite\\player\\dead\\dead_0{}.png'.format(i)).convert_alpha())
        for i in range(10,13):
            self.dead_image.append(image.load('data\\sprite\\player\\dead\\dead_{}.png'.format(i)).convert_alpha())
        self.time_animation = 0
        self.number_of_frames = 8
        self.rect = self.image.get_rect()
        
        self.isFlip = False 
        
        self.rect.x = x
        self.rect.y = y
        self.__max_speed = 4
        
        self.rotate_down = False
        self.rotate_up = False
        
        self._special_atack = {"shoot_laser":False,"stop_time":False,"atack_on":False}
        self._score = 0
        self._speed_boost = 5
        
        self.audioSource = AudioSource()
        self.audioSource.add_audio_clip('data/sound/Point.wav','beat',0.1)
        self.audioSource.add_audio_clip('data\\sound\\power_up.wav','power_up',0.3)
        self.audioSource.add_audio_clip('data\\sound\\death.wav','death',0.3)
        self.__actual_time = 0
        self.__atack_time = -1
        self.__pause_time = 0
        self.anim_on = False
        self.play_death_sound = False
    def update(self,walls, ghosts):
        super().update()
        
        self._cheack_walls(walls=walls)
        self.__check_ghosts(ghosts)
        
                
        if not self._is_alive:
            self.stop_move()
            if not self.play_death_sound:
                self.audioSource.stop_music()
                self.audioSource.play_audio_clip('death')
                self.play_death_sound = True
            self._images = self.dead_image
            if self.time_animation<time.get_ticks():
                self.time_animation = time.get_ticks() + 50
                self.anim_on = True
            elif self.anim_on:
                self.anim_on = False
                self.dead_animation()
        else:
            self.__change_image()
            
        if self._special_atack['atack_on']: 
            if self.__atack_time==-1:
                self.__atack_time = time.get_ticks() + 15000
            elif self.__atack_time<time.get_ticks():
                self.__atack_time = -1
                self._special_atack['atack_on']=False
        if self._special_atack['stop_time']: 
            if self.__atack_time==-1:
                self.__atack_time = time.get_ticks() + 15000
            elif self.__atack_time<time.get_ticks():
                self.__atack_time = -1
                self._special_atack['stop_time']=False
        
    def dead_animation(self):
        self.index+=1
        if self.index<13:
            self.image = self._images[self.index]

    def __change_image(self):
        if self.isFlip:
            self._images = self.images_left
        else:
            self._images = self.images_right
        if self.rotate_down:
                self._images = self.images_down
        elif self.rotate_up:
            self._images = self.images_up
        if self._speed_x != 0 or self._speed_y != 0:
            if self.time_animation<time.get_ticks():
                self.time_animation = time.get_ticks() + 100
            else:
                self.index+=1
                if self.index>self.number_of_frames-1:
                    self.index = 0
                self.image = self._images[self.index]

    def __check_ghosts(self, ghosts):
        for ghost in ghosts:
            if self.rect.colliderect(ghost.rect):
                if self._special_atack['atack_on']:
                    ghost._is_alive = False
                    # ghost.rect.x = 370
                    # ghost.rect.y = 320
                    self._score+=500
                elif ghost.atack:
                    self._is_alive = False
            elif self._special_atack['stop_time'] and ghost.get_max_speed() == 4:
                ghost.set_max_speed(1)
                ghost.stop_move()
                ghost.up(1)
            elif not self._special_atack['stop_time'] and ghost.get_max_speed() == 1:
                ghost.set_max_speed(4)
                ghost.up(4)
    
    def check_input(self, event):
        if self.get_is_alive():
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_w or event.key == pygame.K_UP:
                    self.up(self.__max_speed)
                    self.__flip_and_rotate(False,False,True) 
                if event.key == pygame.K_s or event.key == pygame.K_DOWN:
                    self.down(self.__max_speed)
                    self.__flip_and_rotate(False,True,False)
                if event.key == pygame.K_a or event.key == pygame.K_LEFT:
                    self.left(self.__max_speed)
                    self.__flip_and_rotate(True,False,False)
                if event.key == pygame.K_d or event.key == pygame.K_RIGHT:
                    self.right(self.__max_speed)
                    self.__flip_and_rotate(False,False,False)
                    
            if event.type == pygame.KEYUP:
                if (event.key == pygame.K_w or event.key == pygame.K_UP) and self.get_speed()[1] == -self.__max_speed:
                    self.stop_move()
                if (event.key == pygame.K_s or event.key == pygame.K_DOWN) and self.get_speed()[1] == self.__max_speed:
                    self.stop_move()
                if (event.key == pygame.K_a or event.key == pygame.K_LEFT) and self.get_speed()[0] == -self.__max_speed:
                    self.stop_move()
                if (event.key == pygame.K_d or event.key == pygame.K_RIGHT) and self.get_speed()[0] == self.__max_speed:
                    self.stop_move()

    def __flip_and_rotate(self, isFlip : bool, rotete_down : bool, rotate_up : bool):
        self.isFlip = isFlip
        self.rotate_down = rotete_down
        self.rotate_up = rotate_up

    
    def check_coin_type(self, coin):
        sound = False
        if coin.coin_model.color == color.YELLOW:
            self._special_atack['atack_on'] = True
            sound = True
        elif coin.coin_model.color == color.BLUE:
            self._special_atack['stop_time'] = True
            sound = True
        if sound:
            self.audioSource.play_audio_clip('power_up')
            #agregar un tiempo de ataque
        self._score+=coin.score
    
    
    def __shoot_laser(self):
        #TODO: Hacer este caso de uso
        pass
    
    # def __pause_time(self):
    #     #TODO: Hacer este caso de uso
    #     pass
    
    def __atack_on(self):
        #TODO: Hacer este caso de uso
        pass 
    def get_time_atack(self):
        return self.__atack_time
    <file_sep>import pygame
from pygame import sprite, image, transform
from audio_source import AudioSource
class CoinModel(sprite.Sprite):
    def __init__(self,color : tuple):
        super().__init__()
        self.image = image.load('data/sprite/coin_model.png').convert_alpha()
        self._set_color(color)
        self.color = color
        self.audioSource = AudioSource()
        self.audioSource.add_audio_clip('data/sound/coin.wav','coin',0.3)
    
    def _set_color(self, color : tuple):
        colorImage = pygame.Surface(self.image.get_size()).convert_alpha()
        colorImage.fill(color)
        self.image.blit(colorImage, (0,0), special_flags = pygame.BLEND_RGBA_MULT)
    
    <file_sep>import pygame
from pygame import sprite, image
from game_object.coin_model import CoinModel
class Coin():
    _id=0
    def __init__(self, coin_model : CoinModel, pos : tuple, score):
        super().__init__()
        self.id = Coin._id
        self.score = score
        self.coin_model = coin_model
        self.pos = pos
        self.rect = pygame.Rect(0,0,0,0)
        Coin._id+=1
        
    def draw(self, screen):
        self.rect = screen.blit(self.coin_model.image,self.pos)
        
        
    def get_rect(self):
        return self.rect
    
    def play_sound(self):
        self.coin_model.audioSource.play_audio_clip('coin')<file_sep>import pygame
import math
import random

import pathfinding.core.diagonal_movement,pathfinding.core.grid,pathfinding.finder.a_star

from pygame import sprite, image, time,transform
from audio_source import AudioSource

from game_object.gameObject import GameObject
from game_object.player import Player

class Ghost(GameObject):
    def __init__(self, color : str,dead_ghost_model,level = "", x=370,y=320):
        super().__init__()
        self.image = image.load('data/sprite/ghost/{}/{}_ghost_0.png'.format(color,color)).convert_alpha()
        
        self.scared = image.load('data\\sprite\\ghost\\scared\\scared_ghost.png').convert_alpha()
        
        for i in range(4):
            self._images.append(image.load('data\\sprite\\ghost\\{}\\{}_ghost_{}.png'.format(color,color,i)))
            
        self.dead_ghost_model = dead_ghost_model
        self.normal_ghost = self._images
        self.rect = self.image.get_rect()
        self.rect.x = x
        self.rect.y = y
        
        self.__max_speed = 4
        self.set_speed(0,self.__max_speed)
        self.audioSource = AudioSource()
        self.atack = True
        self.current_level = Ghost._matrix_str_to_matrix_int(level)
        self.initial_level_form = self.current_level.copy()
        
        self.find_time = 0
        self.restart_time = -1
        self.delay_time = -1
        self.current_path = []
        self.aux = ()
        self.find_path = False
        self.dead_time = -1
        
        self.audioSource.add_audio_clip('data\\sound\\incoming-enemy.wav','incoming',0.5)
        # self.audioSource.add_audio_clip('data/sound/Point.wav','beat',0.1)
    
    def update(self,player : Player,walls):
        super().update()
        self._cheack_walls(walls,player)
        
        if self._is_alive:
            self._images = self.normal_ghost
            self.select_path(player) 
            if self.find_path:
                self.start_path()
            self.atack = True
        else:
            if self.dead_time==-1:
                # self.stop_move()
                self._images = self.dead_ghost_model.images
                self.dead_time = time.get_ticks() + 6000
            elif self.dead_time<time.get_ticks():
                self._is_alive = True
                self.dead_time = -1
            self.atack = False
            
        self.update_anim()
        draw = True
        if self._is_alive:
            if player._special_atack['atack_on']:
                if player.get_time_atack() - 500 < time.get_ticks():
                    draw = (time.get_ticks() % 6) == 0
                if draw:
                    self.image = self.scared
                else: 
                    self.image = pygame.Surface((0,0))
            
                
    
            

    def start_path(self):
        if len(self.current_path)==0:
            self.restart_path_finding()
        elif self.find_time < time.get_ticks():
            self.restart_path_finding()
        else:
            self.advance_in_path()

            if self.get_pos()==self.current_path[0] and self.delay_time<time.get_ticks():
                self.next_node()

    def next_node(self):
        self.aux = self.current_path.pop(0)
        speed_x, speed_y = self.get_speed()
        if speed_y == 4:
            self.delay_time=time.get_ticks() + 10
        elif speed_y == -4:
            self.delay_time=time.get_ticks() + 200

        if speed_x == 4:
            self.delay_time=time.get_ticks() + 40
        elif speed_x == -4:
            self.delay_time=time.get_ticks() + 200

    def advance_in_path(self):
        dx = self.get_pos()[0] - self.current_path[0][0]
        dy = self.get_pos()[1] - self.current_path[0][1]
        if self.delay_time>time.get_ticks():
            dx = self.get_pos()[0] - self.aux[0]
            dy = self.get_pos()[1] - self.aux[1]
        if dx==1:
            self.left(self.__max_speed)
        elif dx==-1:
            self.right(self.__max_speed)
        elif dy==1:
            self.up(self.__max_speed)
        elif dy==-1:
            self.down(self.__max_speed)

    def restart_path_finding(self):
        self.find_path = False
        self.restart_time = time.get_ticks() + 4000
        self.current_path.clear()

    def select_path(self, player):
        if self.distance(player.rect.x, player.rect.y) < 200:
            if not self.find_path and self.restart_time<time.get_ticks():
                # self.stop_move()
                self.iteration = 0
                self.iteration_time = 0
                grid = pathfinding.core.grid.Grid(matrix=self.current_level)

                x_ghost,y_ghost = self.get_pos()
                x_player,y_player = player.get_pos()

                start = grid.node(x_ghost, y_ghost)
                try:
                    end = grid.node(x_player, y_player)
                except IndexError as Error:
                    end = grid.node(1,1)


                finder = pathfinding.finder.a_star.AStarFinder(
                    diagonal_movement=pathfinding.core.diagonal_movement.DiagonalMovement.never)

                path, runs = finder.find_path(start, end, grid)

                # self.current_path = list(path)
                for e in path:
                    self.current_path.append(e)
                self.current_path.pop(0)
                # print(self.current_path)
                self.find_path = True
                self.find_time = time.get_ticks() + 2000
                
                # self.audioSource.play_audio_clip('incoming')

    def update_anim(self):
        if self._speed_x>0:
            self.image = self._images[0]
        elif self._speed_x<0:
            self.image = self._images[2]
        elif self._speed_y>0:
            self.image = self._images[1]
        elif self._speed_y<0:
            self.image = self._images[3]
                    
                    
            
                
        
        
    def distance(self, x_player : int, y_player : int):
        return math.sqrt(pow(self.dx(x_player),2) + pow(self.dy(y_player),2))

    def dx(self, x_player):
        return self.rect.x - x_player
    
    def dy(self, y_player):
        return self.rect.y - y_player
    
    
    def _cheack_walls(self,walls,player : Player, rand = -1):
        result = False
        for wall in walls:
            if self.rect.colliderect(wall.rect):
                result = self.rect.colliderect(wall.rect)
                dx,dy = self.get_speed()
                if rand==-1:
                    rand = random.randint(0,2)
                
            
                
                if dx > 0: # Moving right; Hit the left side of the wall
                    self.rect.right = wall.rect.left
                    if rand == 0:
                        self.up(self.__max_speed)
                    elif rand == 1:
                        self.left(self.__max_speed)
                    elif rand == 2:
                        self.down(self.__max_speed)
                        
                if dx < 0: # Moving left; Hit the right side of the wall
                    self.rect.left = wall.rect.right
                    if rand == 0:
                        self.down(self.__max_speed)
                    elif rand == 1:
                        self.right(self.__max_speed)
                    elif rand == 2:
                        self.up(self.__max_speed)
                        
                if dy > 0: # Moving down; Hit the top side of the wall
                    self.rect.bottom = wall.rect.top
                    if rand == 0:
                        self.right(self.__max_speed)
                    elif rand == 1:
                        self.up(self.__max_speed)
                    elif rand == 2:
                        self.left(self.__max_speed)
                if dy < 0: # Moving up; Hit the bottom side of the wall
                    self.rect.top = wall.rect.bottom
                    if rand == 0:
                        self.left(self.__max_speed)
                    elif rand == 1:
                        self.down(self.__max_speed)
                    elif rand == 2:
                        self.right(self.__max_speed)
        return result
    
    @staticmethod
    def _matrix_str_to_matrix_int(matrix):
        index = 0
        new_matrix = []
        for i in matrix:
            new_matrix_2 = []
            for j in matrix[index]:
                if j =='W':
                    new_matrix_2.append(0)
                else:
                    new_matrix_2.append(1)
            new_matrix.append(new_matrix_2)
            index+=1
        return new_matrix

    def set_max_speed(self ,max_speed : int):
        self.__max_speed = max_speed
    def get_max_speed(self):
        return self.__max_speed
    <file_sep>import pygame
from pygame import sprite, image, mixer, time

class AudioSource():
    def __init__(self):
        self.__audio_clips = {}
        self.__musics = {}
        self.__time = 0
        
    def add_audio_clip(self, audio_path : str, audio_name : str,volume=1.0 ):
        try:
            if self.__audio_clip_exitst(audio_name):
                raise ValueError("[WARNING] The key exists.")
            else:
                self.__audio_clips[audio_name] = mixer.Sound(audio_path)
                self.__audio_clips[audio_name].set_volume(volume)
        except ValueError:
            print("[WARNING] The key exists.")
        except:
            print("[WARINIG] Not found.")
            
    def play_audio_clip(self, audio_name:str):
        if self.__audio_clip_exitst(audio_name):
            self.__audio_clips[audio_name].play()
        else:
            raise ValueError("[WARNING] The key don't exists.")
        
    def stop_audio_clip(self, audio_name:str):
        if self.__audio_clip_exitst(audio_name):
            self.__audio_clips[audio_name].stop()
            self.__time = 0
        else:
            raise ValueError("[WARNING] The key don't exists.")
    
    def play_audio_clip_each(self, audio_name:str, ms : int):
        if self.__audio_clip_exitst(audio_name):
            if self.__time == 0:
                self.__time = time.get_ticks() + ms
                self.__audio_clips[audio_name].play()
            elif self.__time<time.get_ticks():
                self.__time = 0
        else:
            raise ValueError("[WARNING] The key don't exists.")
        
    def __audio_clip_exitst(self,audio_name:str):
        return not self.__audio_clips.get(audio_name,None)==None
    
    @staticmethod
    def play_music_loop(music_path : str,volume = 1.0):
        try:
           mixer.music.load(music_path)
           mixer.music.set_volume(volume)
           mixer.music.play(-1)
        except:
           print("[WARINIG] Not found.")
    
    @staticmethod
    def play_music_each(music_path : str, loops : int, volume = 1.0):
       try:
           mixer.music.load(music_path)
           mixer.music.set_volume(volume)
           mixer.music.play(loops)
       except:
           print("[WARINIG] Not found.")
    
    @staticmethod
    def stop_music():
        mixer.music.stop()<file_sep>import sys
import pygame
from pygame import display, font, sprite, time, event
import color
import configuration
from audio_source import AudioSource
from game_object.player import Player
from game_object.ghost import Ghost
from game_object.dead_ghost_model import DeadGhostModel
from coin_model_factory import CoinModelFactory,Coin
from game_object.wall import Wall
from game_object.wall_model import WallModel
from scene.scene import Scene


class Game(Scene):
    def __init__(self, level : list):
        super().__init__()
        self._coin_model_factory = CoinModelFactory()
        self.wall_model = WallModel()
        self.__coin_list = []
        
        self.__wall_group = sprite.Group()
        self.load_level(level)
        
        self.__player = Player(color.YELLOW,x=30,y=30)
        self.__group = sprite.Group(self.__player)
        
        self.__ghost_group = sprite.Group()
        self.ghost_dead_model = DeadGhostModel()
        self.__ghost_group.add(Ghost('red',self.ghost_dead_model,level))
        self.__ghost_group.add(Ghost('blue',self.ghost_dead_model,level))
        self.__ghost_group.add(Ghost('green',self.ghost_dead_model,level))
        self.__ghost_group.add(Ghost('lila',self.ghost_dead_model,level))
        
        self.__font_score = font.Font('data/dpcomic.ttf',50)
        self._state = {'continue':False, 'exit':False,'win':False}
        
        self.__iteration = 1
        self.__time = 0
        self.audio_source.play_music_loop('data\\music\\my_music.wav',0.5)
        self.play_normal_music = True
        
    def process(self):
        self.__wall_group.update()
        
        for e in event.get():
            if e.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            self.__player.check_input(e)
            
        self.__ghost_group.update(self.__player,self.__wall_group)
        self.__player.update(self.__wall_group,self.__ghost_group)
        
        self.__check_colisions()
        
        if len(self.__coin_list) == 0 and not self._state['win'] and self.__time == 0:
            self._state['win'] = True
            self.__time = time.get_ticks() + 5000
        
        if not self.__player.get_is_alive() and self.__time == 0:
            self.__time = time.get_ticks() + 5000
            
        if time.get_ticks()>self.__time and (self._state['win'] or not self.__player.get_is_alive()):
            self._state['exit'] = True
            
        if self.__player._special_atack['atack_on'] and self.play_normal_music:
            self.audio_source.stop_music()
            self.audio_source.play_music_loop('data\\music\\scared_ghost.wav',0.5)
            self.play_normal_music = False
        elif not self.__player._special_atack['atack_on'] and not self.play_normal_music and not self.__player._special_atack['stop_time']:
            self.audio_source.stop_music()
            self.audio_source.play_music_loop('data\\music\\my_music.wav',0.5)
            self.play_normal_music = True
        
        elif self.__player._special_atack['stop_time'] and self.play_normal_music:
            self.audio_source.stop_music()
            self.audio_source.play_music_loop('data\\music\\my_music_delay.wav',1)
            self.play_normal_music = False
        elif not self.__player._special_atack['stop_time'] and not self.play_normal_music and not self.__player._special_atack['atack_on']:
            self.audio_source.stop_music()
            self.audio_source.play_music_loop('data\\music\\my_music.wav',1)
            self.play_normal_music = True
            
            
    def display_frame(self):
        self._clock.tick(self._fps)
        self.screen.fill(color.BLACK)
        self.__wall_group.draw(self.screen)
        
        for coin in self.__coin_list:
            coin.draw(self.screen)
            
        self.__ghost_group.draw(self.screen)
        
        self.__group.draw(self.screen)
        
        if self._state['win']:
            self._draw_text(self.__font_score,'WIN',365,300)
        if not self.__player.get_is_alive():
            self._draw_text(self.__font_score,'LOSE',365,300)
            
        display.flip()
    
    def __check_colisions(self):
        index=0
        for e in self.__coin_list:
            if self.__player.rect.colliderect(e.get_rect()):
                # print("Me choco una moneda {}".format(e.coin_model.color))
                e.play_sound()
                self.__player.check_coin_type(e)
                self.__coin_list.pop(index)
            index+=1
        
        
    def get_state(self):
        return self._state
    def get_clock(self):
        return self._clock
    
    def load_level(self,level:str):
        x = y = 0
        y_coin = 5
        for row in level:
            for col in row:
                if col == "W":
                    self.__wall_group.add(Wall(self.wall_model,pos=(x,y)))
                if col == "C" or col ==" ":
                    self.__coin_list.append(Coin(self._coin_model_factory.get_coin_model('white_coin_model'),pos=(x,y_coin),score=50))
                if col == "Y":
                    self.__coin_list.append(Coin(self._coin_model_factory.get_coin_model('yellow_coin_model'),pos=(x,y_coin),score=200))
                if col == "R":
                    self.__coin_list.append(Coin(self._coin_model_factory.get_coin_model('red_coin_model'),pos=(x,y_coin),score=200))
                if col == "B":
                    self.__coin_list.append(Coin(self._coin_model_factory.get_coin_model('blue_coin_model'),pos=(x,y_coin),score=200))
                x += 25
                
            y += 25
            y_coin += 25
            x = 0
    def get_score(self):
        return self.__player._score

def main():
    level = [
        "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW",
        "W               W             YW",
        "W WW WWW WWWWWW W WWWWW WWW WW W",
        "W WW WWW WWWWWW W WWWWW WWW WW W",
        "W               W              W",
        "W WWWW W WWWWWWWWWWWWWW W WWWW W",
        "W      WB              BW      W",
        "WWW WW WWWWW WWWWWW WWWWW WW WWW",
        "WWW WW W     WWWWWW     W WW WWW",
        "WWW WW W WWWWWWWWWWWWWW W WW WWW",
        "W   WW W                W WW   WWWW",
        "_        WW W______W WW        ____",
        "W      W WW W______W WW W      WWWW",
        "WWW WW W WW W______W WW W WW WWW",
        "WWW WW W WW WWWWWWWW WW W WW WWW",
        "WWW WW W WW          WW W WW WWW",
        "WWW WW W WW WWWWWWWW WW W WW WWW",
        "W      W       BWB      W      W",
        "W WWWW W WWWWWWWWWWWWWW W WWWW W",
        "W      W                W      W",
        "W WW WWW WWWWWW W WWWWW WWW WW W",
        "W WW WWW WWWWWW W WWWWW WWW WW W",
        "WY       WR          RW       YW",
        "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW"
    ]
    #24 filas
    #32 columnas
    pygame.init()
    continue_ = True
    while continue_:
        myGame = Game(level)
        while not myGame.get_state()['exit']:
            myGame.process()
            myGame.display_frame()
        continue_ = myGame.get_state()['continue']
    
    return myGame.get_score()



<file_sep>import pygame
from pygame import font,time, display
from audio_source import AudioSource
import configuration, color
class Scene():
    def __init__(self):
        self.screen = display.set_mode(size=(configuration.SCREEN_WIDTH,configuration.SCREEN_HEIGHT))
        self._state = {'continue':False, 'exit':False}
        self._clock = time.Clock()
        self._fps = 30
        self.audio_source = AudioSource()
        
    def process(self):
        pass
    def display_frame(self):
        pass
    def _draw_text(self, font, text : str, x : int, y : int):
        text_Obj = font.render(text,1,color.WHITE,self.screen)
        text_rect = text_Obj.get_rect()
        text_rect.topleft = (x,y)
        self.screen.blit(text_Obj, text_rect)<file_sep>import pygame
from pygame import sprite, image, transform, draw,mask
import configuration    
from game_object.wall_model import WallModel    
class Wall(sprite.Sprite):
    def __init__(self,wall_model:WallModel,pos = (0,0)):
        super().__init__()
        self.image = wall_model.image
        self.rect = self.image.get_rect()
        self.rect.x = pos[0]
        self.rect.y = pos[1]
    
    def update(self):
        super().update()
        
        
    
    
    <file_sep>import sys
import pygame
from pygame import display, font, sprite, time, event
import color
import configuration
# from audio_source import AudioSource
# from game_object.player import Player
# from game_object.ghost import Ghost
# from game_object.dead_ghost_model import DeadGhostModel
# from coin_model_factory import CoinModelFactory,Coin
# from game_object.wall import Wall
# from game_object.wall_model import WallModel
from pygame import font
from ui.input_box import InputBox
from scene.scene import Scene

class End(Scene):
    def __init__(self, score : int, name_score_list : []):
        super().__init__()
        self.input_box = InputBox(600,100,30,60)
        self.tittle_text = "HIGHT SCORES"
        self.tittle_font = font.Font('data\\dpcomic.ttf',40)
        self.name_font = font.Font('data\\dpcomic.ttf',55)
        self.score_font = font.Font('data\\dpcomic.ttf',20)
        self.name_score_list = name_score_list
        self.score = score
        
    
    def process(self):
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()
            self.input_box.handle_event(event)

        self.input_box.update()

        
    def display_frame(self):
        self.screen.fill(color.BLACK)
        
        self.input_box.draw(self.screen)
        
        
        end = self.input_box.end
        
        self._draw_text(self.tittle_font,self.tittle_text,30,10)
        self._draw_text(self.name_font,"NAME: ",450,110)
        self._draw_text(self.name_font,"SCORE: {}".format(self.score),450,170)
        len_ = len(self.name_score_list)
        if len_>10:
            len_=10
                   
        for i in range(len_):
            name = self.name_score_list[i][0]
            score = self.name_score_list[i][1]
            self._draw_text(self.score_font,"{}) {}: {}".format(i+1,name,score),20,80 + 25*i)
        
        pygame.display.flip()
        self._clock.tick(self._fps)

def main(score,lst):
    pygame.init()
    my_end = End(score,lst)
    end = False
    while not end:
        my_end.process()
        my_end.display_frame()
        end = my_end.input_box.end
    name = my_end.input_box.text
    print(name)
    return name

if __name__ == "__main__":
    print(main())<file_sep>import pygame
from pygame import sprite, image, transform
from game_object.coin_model import CoinModel
from game_object.coin import Coin
import color
class CoinModelFactory():
    def __init__(self):
        self.__red_coin_model = CoinModel(color.RED)
        self.__white_coin_model = CoinModel(color.WHITE)
        self.__yellow_coin_model = CoinModel(color.YELLOW)
        self.__blue_coin_model = CoinModel(color.BLUE)
        
    def get_coin_model(self, type : str):
        if type == 'red_coin_model':
            return self.__red_coin_model
        elif type == 'white_coin_model':
            return self.__white_coin_model
        elif type == 'yellow_coin_model':
            return self.__yellow_coin_model
        elif type == 'blue_coin_model':
            return self.__blue_coin_model
        else:
            raise ValueError('[WARNING]The type don`t exists.')
    
    @staticmethod
    def get_list_of_types():
        return ['red_coin_model','yellow_coin_model','yellow_big_coin_model','blue_coin_model']<file_sep># import pygame
# pygame.init()
# infoObject = pygame.display.Info()

SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600<file_sep>import pygame
from pygame import sprite, image
import configuration

class DeadGhostModel():
    def __init__(self):
        self.images = []
        for i in range(4):
            self.images.append(image.load('data\\sprite\\ghost\\dead\\dead_ghost_{}.png'.format(i)))