예제 #1
0
파일: menu.py 프로젝트: sefiamor/Game-1
    def call_game(self):
        self.config = config.OptionConfig()
#        SoundPlayer().play_music('CharSelect.mp3')
        
        while True:
            menu = CharSelectMenu(self.screen, self.config.keysP1, self.config.keysP2, Point(0,0))
            characters = menu.mainloop()
            if characters == 0:
                break
            char1 = characters[0][0]
            alt1 = characters[0][1]
            char2 = characters[1][0]
            alt2 = characters[1][1]
            if char1 == char2 and alt1 == alt2:
                alt2 = not alt1
            print('loading characters...')
            player1 = Round.Player(char1, 120, 100, alt_color = alt1)
            player2 = Round.Player(char2, 120, 100, Player2=True, alt_color = alt2)
            print('loading background...')
            list = getBckgrndList()
            rand = randint(0, len(list)-1)
            background = Round.Background('../res/Background/'+list[rand])
            config.SoundPlayer().play_music('Bckgrnd3.mp3')
            print('creating game...')
            game = Round.Game(self.screen, background, player1, player2)
            game.mainloop()
            config.SoundPlayer().play_music('Intro.mp3')
예제 #2
0
파일: main.py 프로젝트: hedayaty/snake
def main():
	
	pygame.init()

	size = width, height = [640,480+16]
	renderer.init(size)
	pygame.display.set_caption("snake")
	menu.init()
	
	
	# number of player, game type, lives, mapname
	while 1:	
		gametype = menu.choose ("",																			\
		[{ "label" : "Single Player", "value": "1p"}, 									\
		 { "label" : "Multi Players Game", "value": "multi"},						\
		 { "label" : "Join a Network Game", "value" : "join"},					\
		 { "label" : "QUIT", "value": None}])	

		if gametype == None : 
			break
		
		if game.init (gametype):
			game.mainloop ()

	pygame.display.quit()
예제 #3
0
 def call_fight(self, player1, player2):
     print('loading background...')
     list = getBckgrndList()
     rand = randint(0, len(list)-1)
     background = Round.Background('../res/Background/'+list[rand])
     config.SoundPlayer().play_music('Bckgrnd3.mp3')
     print('creating game...')
     game = Round.Game(self.screen, background, player1, player2)
     results = game.mainloop()
     config.SoundPlayer().play_music('Intro.mp3')
     if results == 'QUIT':
         return False
     else:
         self.fight_stats.update(results)
         return True
예제 #4
0
            ext = DrawText(u'Выход', font, surface_menu, midlText(u'Выход', font), (surface_height / 2) + 40, font_color)
        else:
            ext = DrawText(u'Выход', fontBig, surface_menu, midlText(u'Выход', fontBig), (surface_height / 2) + 60, font_big_color)

        for event in pygame.event.get():
            pos = pygame.mouse.get_pos()

            if event.type == pygame.QUIT:
                sys.exit()
            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                if ext.collidepoint(pos):
                    sys.exit()
                if start.collidepoint(pos):
                    surface_menu.fill(cf.green)
                    running = 0
                    game.mainloop()
                if option.collidepoint(pos):
                    surface_menu.fill(cf.green)
                    running = 0
                    Options.loopOption()
            if event.type == pygame.MOUSEMOTION:
                if ext.collidepoint(pos):
                    moveE = 1
                else:
                    moveE = 0
                if start.collidepoint(pos):
                    moveS = 1
                else:
                    moveS = 0
                if option.collidepoint(pos):
                    moveO = 1
예제 #5
0
def loopOption():
    moveL1 = moveL2 = moveE = 0
    width = height = 0
    running = 1
    while running:
        surface_menu.blit(background_menu, (0, 0))

        if moveL1 == 0:
            start1 = TwoTowers.DrawText(
                u'Уровень в 2 масти', font, surface_menu,
                TwoTowers.midlText(u'Уровень в 2 масти', font),
                (surface_height / 2) - 130, font_color)

        else:
            start1 = TwoTowers.DrawText(
                u'Уровень в 2 масти', fontBig, surface_menu,
                TwoTowers.midlText(u'Уровень в 2 масти', fontBig),
                (surface_height / 2) - 140, font_big_color)
            TwoTowers.DrawText(
                str(level1Text1), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level1Text1, cf.fontTutorial),
                (surface_height / 2) - 205, font_color)
            TwoTowers.DrawText(
                str(level1Text2), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level1Text2, cf.fontTutorial),
                (surface_height / 2) - 185, cf.black)
            TwoTowers.DrawText(
                str(level1Text3), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level1Text3, cf.fontTutorial),
                (surface_height / 2) - 165, cf.red)
            TwoTowers.DrawText(
                str(level1Text4), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level1Text4, cf.fontTutorial),
                (surface_height / 2) - 150, font_color)
        if moveL2 == 0:
            start2 = TwoTowers.DrawText(
                u'Уровень в 4 масти', font, surface_menu,
                TwoTowers.midlText(u'Уровень в 4 масти', font),
                (surface_height / 2) - 40, font_color)
        else:
            start2 = TwoTowers.DrawText(
                u'Уровень в 4 масти', fontBig, surface_menu,
                TwoTowers.midlText(u'Уровень в 4 масти', fontBig),
                (surface_height / 2) - 40, font_big_color)
            TwoTowers.DrawText(
                str(level2Text1), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level2Text1, cf.fontTutorial),
                (surface_height / 2) - 225, font_color)
            TwoTowers.DrawText(
                str(level2Text2), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level2Text2, cf.fontTutorial),
                (surface_height / 2) - 205, cf.black)
            TwoTowers.DrawText(
                str(level2Text3), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level2Text3, cf.fontTutorial),
                (surface_height / 2) - 185, cf.red)
            TwoTowers.DrawText(
                str(level2Text4), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level2Text4, cf.fontTutorial),
                (surface_height / 2) - 165, cf.black)
            TwoTowers.DrawText(
                str(level2Text5), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level2Text5, cf.fontTutorial),
                (surface_height / 2) - 145, cf.red)
            TwoTowers.DrawText(
                str(level2Text6), cf.fontTutorial, surface_menu,
                TwoTowers.midlText(level2Text6, cf.fontTutorial),
                (surface_height / 2) - 125, font_color)

        if moveE == 0:
            ext = TwoTowers.DrawText(u'Выход', font, surface_menu,
                                     TwoTowers.midlText(u'Выход', font),
                                     (surface_height / 2) + 40, font_color)
        else:
            ext = TwoTowers.DrawText(u'Выход', fontBig, surface_menu,
                                     TwoTowers.midlText(u'Выход', fontBig),
                                     (surface_height / 2) + 60, font_big_color)

        for event in pygame.event.get():
            pos = pygame.mouse.get_pos()

            if event.type == pygame.QUIT:
                sys.exit()
            if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1:
                if ext.collidepoint(pos):
                    sys.exit()
                if start1.collidepoint(pos):
                    cf.level1 = 1
                    cf.level2 = 0
                    surface_menu.fill(cf.green)
                    game.mainloop()
                if start2.collidepoint(pos):
                    cf.level1 = 0
                    cf.level2 = 1
                    surface_menu.fill(cf.green)
                    game.mainloop()
            if event.type == pygame.MOUSEMOTION:
                if ext.collidepoint(pos):
                    moveE = 1
                else:
                    moveE = 0
                if start1.collidepoint(pos):
                    moveL1 = 1
                else:
                    moveL1 = 0
                if start2.collidepoint(pos):
                    moveL2 = 1
                else:
                    moveL2 = 0

        pygame.display.update()
        pygame.display.flip()