예제 #1
0
 def __init__(self):
     self.status = False
     self.select_sound = mixer.Sound(
         Utils.get_path('sound/select-menu.wav'))
     self.select_sound.set_volume(2)
     self.check_sound = mixer.Sound(Utils.get_path('sound/select-menu.wav'))
     self.check_sound.set_volume(5)
예제 #2
0
    def init_screen(self):

        self.sounds = {
            'ping': pygame.mixer.Sound(Utils.get_path('sound/click.wav')),
            'click': pygame.mixer.Sound(Utils.get_path('sound/paddle-hit.wav')),
            'da-ding': pygame.mixer.Sound(Utils.get_path('sound/da-ding.wav'))
        }
        self.sounds['ping'].set_volume(0.05)
        self.sounds['click'].set_volume(0.5)
        self.sounds['da-ding'].set_volume(0.5)
        self.bg = pygame.image.load(Utils.get_path('image/pingpong-table.png'))
        self.font = {
            18: pygame.font.SysFont('Times New Roman', 18),
            72: pygame.font.SysFont('Times New Roman', 72)
        }

        up_key = pygame.K_w
        down_key = pygame.K_s
        if Setting.PLAY_MODE == Setting.SINGLE_MODE:
            up_key = None
            down_key = None

        paddle_1 = Paddle(5, self.screen_size[1]/2-30, 10, 60, None, None, down_key, up_key, self.surface, self.dt, self.screen_size)
        paddle_2 = Paddle(self.screen_size[0]-5-10, self.screen_size[1]/2-30, 10, 60, None, None, pygame.K_DOWN, pygame.K_UP, self.surface, self.dt, self.screen_size)

        self.paddles = [paddle_1, paddle_2]

        player_1 = Player((0, 255, 0), self.paddles[:1], self.sounds['click'], self.sounds['da-ding'])
        player_2 = Player((247, 52, 12), self.paddles[1:], self.sounds['click'], self.sounds['da-ding'])

        self.players = [player_1, player_2]

        self.ball = Ball(self.screen_size[0]/2, self.screen_size[1]/2,200.0, self.surface)
예제 #3
0
    def __init__(self, base_game, surface):
        BaseScreen.__init__(self)
        self.base_game = base_game
        self.status = False
        self.surface = surface
        self.dt = 1.0/60.0
        self.bg = pygame.image.load(Utils.get_path('image/menu-bg.png'))
        self.font = {
            20: pygame.font.Font(Utils.get_path('font/ActualBook.otf'), 20),
            55: pygame.font.Font(Utils.get_path('font/ActualBook.otf'), 55)
        }

        self.high_score_list = []
        self.get_high_score()
예제 #4
0
    def __init__(self, base_game, surface):
        BaseScreen.__init__(self)
        self.base_game = base_game
        self.status = False
        self.surface = surface
        self.dt = 1.0 / 60.0
        self.bg = pygame.image.load(Utils.get_path('image/menu-bg.png'))
        self.font = {
            20: pygame.font.Font(Utils.get_path('font/ActualBook.otf'), 20),
            55: pygame.font.Font(Utils.get_path('font/ActualBook.otf'), 55)
        }

        self.high_score_list = []
        self.get_high_score()
예제 #5
0
    def __init__(self):
        display.init()
        font.init()
        mixer.init(buffer=0)
        self.screen_size = [800, 500]
        self.surface = display.set_mode(self.screen_size)

        life_image = image.load(Utils.get_path("image/icon.png")).convert_alpha()
        display.set_icon(life_image)
        display.set_caption("Ping Pong")
        display.set_icon(life_image)

        self.theme_sound = mixer.Sound(Utils.get_path("sound/menu-screen-theme.wav"))
        self.theme_sound.set_volume(0.25)
        if Setting.MUSIC:
            self.theme_sound.play(-1)

        self.switch_screen(Setting.MENU_SCREEN)
예제 #6
0
파일: menu.py 프로젝트: kimthuy/pingpong
    def __init__(self, surface, text, font_size, x, y):
        self.font_size = font_size
        self.font = {
            self.font_size: font.Font(Utils.get_path('font/FEASFBI.TTF'), self.font_size),
        }

        self.text = text
        self.surface = surface
        self.x = x
        self.y = y
예제 #7
0
    def init_screen(self):

        self.sounds = {
            'ping': pygame.mixer.Sound(Utils.get_path('sound/click.wav')),
            'click':
            pygame.mixer.Sound(Utils.get_path('sound/paddle-hit.wav')),
            'da-ding': pygame.mixer.Sound(Utils.get_path('sound/da-ding.wav'))
        }
        self.sounds['ping'].set_volume(0.05)
        self.sounds['click'].set_volume(0.5)
        self.sounds['da-ding'].set_volume(0.5)
        self.bg = pygame.image.load(Utils.get_path('image/pingpong-table.png'))
        self.font = {
            18: pygame.font.SysFont('Times New Roman', 18),
            72: pygame.font.SysFont('Times New Roman', 72)
        }

        up_key = pygame.K_w
        down_key = pygame.K_s
        if Setting.PLAY_MODE == Setting.SINGLE_MODE:
            up_key = None
            down_key = None

        paddle_1 = Paddle(5, self.screen_size[1] / 2 - 30, 10, 60, None, None,
                          down_key, up_key, self.surface, self.dt,
                          self.screen_size)
        paddle_2 = Paddle(self.screen_size[0] - 5 - 10,
                          self.screen_size[1] / 2 - 30, 10, 60, None, None,
                          pygame.K_DOWN, pygame.K_UP, self.surface, self.dt,
                          self.screen_size)

        self.paddles = [paddle_1, paddle_2]

        player_1 = Player((0, 255, 0), self.paddles[:1], self.sounds['click'],
                          self.sounds['da-ding'])
        player_2 = Player((247, 52, 12), self.paddles[1:],
                          self.sounds['click'], self.sounds['da-ding'])

        self.players = [player_1, player_2]

        self.ball = Ball(self.screen_size[0] / 2, self.screen_size[1] / 2,
                         200.0, self.surface)
예제 #8
0
    def __init__(self):
        display.init()
        font.init()
        mixer.init(buffer=0)
        self.screen_size = [800, 500]
        self.surface = display.set_mode(self.screen_size)

        life_image = image.load(
            Utils.get_path('image/icon.png')).convert_alpha()
        display.set_icon(life_image)
        display.set_caption('Ping Pong')
        display.set_icon(life_image)

        self.theme_sound = mixer.Sound(
            Utils.get_path('sound/menu-screen-theme.wav'))
        self.theme_sound.set_volume(0.25)
        if Setting.MUSIC:
            self.theme_sound.play(-1)

        self.switch_screen(Setting.MENU_SCREEN)
예제 #9
0
파일: menu.py 프로젝트: kimthuy/pingpong
    def __init__(self, surface, text, font_size, x, y):
        self.font_size = font_size
        self.font = {
            self.font_size:
            font.Font(Utils.get_path('font/FEASFBI.TTF'), self.font_size),
        }

        self.text = text
        self.surface = surface
        self.x = x
        self.y = y
예제 #10
0
    def __init__(self, base_game, surface):
        BaseScreen.__init__(self)
        self.base_game = base_game
        self.status = False
        self.surface = surface
        self.dt = 1.0/60.0
        self.bg = pygame.image.load(Utils.get_path('image/menu-bg.png'))

        self.menu_text = Menu(self.surface, 'Setting', 70, 565, 60)
        self.menu_text.is_selected = True
        menu_sound = SettingMenu(self.surface, 'Sound', 35, 560, 150)
        menu_sound.is_selected = True
        menu_music = SettingMenu(self.surface, 'Music', 35, 565, 190)
        menu_exit = Menu(self.surface, 'Back', 35, 570, 230)

        self.menus = [menu_sound, menu_music, menu_exit]
예제 #11
0
    def __init__(self, base_game, surface):
        BaseScreen.__init__(self)
        self.base_game = base_game
        self.status = False
        self.surface = surface
        self.dt = 1.0 / 60.0
        self.bg = pygame.image.load(Utils.get_path('image/menu-bg.png'))

        self.menu_text = Menu(self.surface, 'Setting', 70, 565, 60)
        self.menu_text.is_selected = True
        menu_sound = SettingMenu(self.surface, 'Sound', 35, 560, 150)
        menu_sound.is_selected = True
        menu_music = SettingMenu(self.surface, 'Music', 35, 565, 190)
        menu_exit = Menu(self.surface, 'Back', 35, 570, 230)

        self.menus = [menu_sound, menu_music, menu_exit]
예제 #12
0
    def __init__(self, base_game, surface):
        BaseScreen.__init__(self)
        self.base_game = base_game
        self.status = False
        self.surface = surface
        self.bg = pygame.image.load(Utils.get_path('image/menu-bg.png'))

        self.menu_text = Menu(self.surface, 'Menu', 70, 565, 30)

        menu_single = Menu(self.surface, 'Single Player', 35, 560, 120)
        menu_single.is_selected = True
        menu_multi = Menu(self.surface, 'Multi Player', 35, 565, 160)
        menu_setting = Menu(self.surface, 'Settings', 35, 570, 200)
        menu_high_score = Menu(self.surface, 'High Score', 35, 575, 240)
        menu_exit = Menu(self.surface, 'Exit Game', 35, 577, 280)

        self.menus = [menu_single, menu_multi, menu_setting, menu_high_score, menu_exit]
예제 #13
0
 def __init__(self):
     self.status = False
     self.select_sound = mixer.Sound(Utils.get_path('sound/select-menu.wav'))
     self.select_sound.set_volume(2)
     self.check_sound = mixer.Sound(Utils.get_path('sound/select-menu.wav'))
     self.check_sound.set_volume(5)
예제 #14
0
 def get_high_score(self):
     high_score_file = open(Utils.get_path('doc/high-score.txt'), 'r')
     stuff = high_score_file.readlines()
     for line in stuff:
         self.high_score_list.append(line)
     high_score_file.close()
예제 #15
0
 def get_high_score(self):
     high_score_file = open(Utils.get_path('doc/high-score.txt'), 'r')
     stuff = high_score_file.readlines()
     for line in stuff:
         self.high_score_list.append(line)
     high_score_file.close()