Beispiel #1
0
def win(winner):
    while True:
        pygame.init()
        pygame.display.set_caption('Squabble')
        screen = pygame.display.set_mode((800, 600),0,32)
        font = pygame.font.SysFont(None, 42)
        screen.blit(continuehom,(0,0))
        s=winner+" won!!"
        write_text(s, font, (255, 255, 255), screen,390,160)
        btn=pygame.Rect(263, 360, 270, 90)
        pygame.draw.rect(screen, (235,205,84),btn)
        write_text('Continue', font, (255,255, 255), screen, 400, 406)

        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            mouse_pos = pygame.mouse.get_pos()
            if btn.collidepoint(mouse_pos):                  
                if event.type == MOUSEBUTTONDOWN:
                    print("click")
                    pygame.quit()
                    from game_map import game_map
                    game_map()
                    

        pygame.display.update()
        mainClock.tick(60)
Beispiel #2
0
    def start(self):
        while True:
            button = []
            self.screen.blit(homescreen, (0, 0))
            btn = pygame.Rect(250, 250, 270, 45)
            button.append(btn)
            pygame.draw.rect(self.screen, (255, 255, 255), btn)
            write_text('Play against computer', self.font_sm, (0, 0, 0),
                       self.screen, 390, 275)
            btn = pygame.Rect(290, 380, 270, 45)
            button.append(btn)
            pygame.draw.rect(self.screen, (255, 255, 255), btn)
            write_text('Play online (Multiplayer)', self.font_sm, (0, 0, 0),
                       self.screen, 420, 405)

            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                mouse_pos = pygame.mouse.get_pos()
                for i, rect in enumerate(button):
                    if rect.collidepoint(mouse_pos):
                        if event.type == MOUSEBUTTONDOWN:
                            print("playy!!")
                            running = False
                            if (button.index(rect) == 0):
                                return "local"
                            else:
                                return "online"
            pygame.display.update()
            self.mainClock.tick(60)
Beispiel #3
0
def main_menu():
    while True:
        pygame.init()
        pygame.display.set_caption('Squabble')
        screen = pygame.display.set_mode((800, 600),0,32)
        font = pygame.font.SysFont(None, 42)
        screen.blit(startmenu,(0,0))
        write_text('Select a character to start playing!', font, (255, 255, 255), screen,400,50)
        button=[]
        for i in range(len(data)):
            btn=pygame.Rect(100, 100+(i*70), 600, 50)
            button.append(btn)
            pygame.draw.rect(screen, (0,0,0),btn)
        for i in range(len(data)):
            write_text(data[i]['name'], font, (255,255, 255), screen, 400,125+(i*70))

        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            mouse_pos = pygame.mouse.get_pos()
            for i, rect in enumerate(button):
                if rect.collidepoint(mouse_pos):                  
                    if event.type == MOUSEBUTTONDOWN:
                        print(data[button.index(rect)]['name'],"selected!!")
                        character=data[button.index(rect)]['name']
                        character_id=data[button.index(rect)]['id']
                        running=False
                        player2_id=randint(0,4)
                        player2=data[player2_id]['name']
                        game_obj=Game(character,character_id,player2,player2_id)
                        game_obj.play_()

        pygame.display.update()
        mainClock.tick(60)
Beispiel #4
0
    def attack_bar(self):
        bar = pygame.Rect(0, 450, 10, 110)
        pygame.draw.rect(self.screen, (255, 255, 255), bar)
        rect = self.img1.get_rect()
        # rect.center = x, 220
        # self.screen.blit(self.att_bg, bar)
        for i in range(4):
            if (i < 2):
                margin_left = 80 + (i * 340)
                margin_top = 465
            else:
                margin_left = 80 + (i - 2) * 340
                margin_top = 525
            btn = pygame.Rect(margin_left, margin_top, 310, 50)
            self.button.append(btn)
            pygame.draw.rect(self.screen, (39, 39, 39), btn)

        for i in range(4):
            if (i < 2):
                margin_top = 490
                margin_left = 220 + (i * 360)
            else:
                margin_top = 550
                margin_left = 220 + (i - 2) * 360
            write_text(
                self.data[int(self.player1_id)]['attacks'][i]['attack_name'],
                self.font_sm, (255, 255, 255), self.screen, margin_left,
                margin_top)
Beispiel #5
0
 def health_bar(self, a):
     if (a == 1):
         center_x = 63
         rect_margin = 75
     else:
         center_x = 463
         rect_margin = 475
     write_text("hp", self.font_xs, (255, 255, 255), self.screen, center_x,
                53)
     bar = pygame.Rect(rect_margin, 50, 250, 7)
     pygame.draw.rect(self.screen, (230, 230, 230), bar)
Beispiel #6
0
 def info_bar(self, a):
     bar = pygame.Rect(45, 380, 700, 35)
     pygame.draw.rect(self.screen, (64, 60, 110), bar)
     if (a == 1):
         temp = self.attack_desc
         c = (145, 209, 139)
     else:
         temp = self.attack_message
         c = (245, 106, 121)
     write_text(temp, self.font_info, c, self.screen, 400, 395)
     print(self.attack_message)
Beispiel #7
0
def wip():
    
    while True:
        pygame.init()
        pygame.display.set_caption('Squabble')
        screen = pygame.display.set_mode((800, 600),0,32)
        screen.blit(multi,(0,0))
        font = pygame.font.SysFont(None, 34)
        s="We are still working on this."
        q="Try playing the game locally!!"
        write_text(s, font, (255, 255, 255), screen,400,240)
        write_text(q, font, (255, 255, 255), screen,400,270)
        btn=pygame.Rect(260, 375, 270, 50)
        pygame.draw.rect(screen, (255, 255, 255),btn)
        write_text('Continue', font, (0, 0, 0), screen, 400, 395)

        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            mouse_pos = pygame.mouse.get_pos()
            if btn.collidepoint(mouse_pos):                  
                if event.type == MOUSEBUTTONDOWN:
                    print("click")
                    pygame.quit()
                    from game_map import main
                    main()
                    

        pygame.display.update()
        mainClock.tick(60)
Beispiel #8
0
    def win(self, winner):
        while True:
            self.screen.fill((0, 0, 0))
            self.screen.blit(continuehom, (0, 0))
            s = winner + " won!!"
            write_text(s, self.font, (255, 255, 255), self.screen, 390, 165)
            btn = pygame.Rect(263, 360, 270, 90)
            pygame.draw.rect(self.screen, (235, 205, 84), btn)
            write_text('Play again', self.font, (0, 0, 0), self.screen, 400,
                       406)

            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                mouse_pos = pygame.mouse.get_pos()
                if btn.collidepoint(mouse_pos):
                    if event.type == MOUSEBUTTONDOWN:
                        print("continue")
                        return (1)

            pygame.display.update()
            self.mainClock.tick(60)
Beispiel #9
0
    def main_menu(self):
        while True:
            self.screen.fill((0, 0, 0))
            self.screen.blit(startmenu, (0, 0))
            write_text('Select a character to start playing!', self.font,
                       (255, 255, 255), self.screen, 400, 50)
            button = []
            for i in range(len(data)):
                btn = pygame.Rect(100, 100 + (i * 70), 600, 50)
                button.append(btn)
                pygame.draw.rect(self.screen, (255, 255, 255), btn)
            for i in range(len(data)):
                write_text(data[i]['name'], self.font, (0, 0, 0), self.screen,
                           400, 125 + (i * 70))

            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                mouse_pos = pygame.mouse.get_pos()
                for i, rect in enumerate(button):
                    if rect.collidepoint(mouse_pos):
                        if event.type == MOUSEBUTTONDOWN:
                            print(data[button.index(rect)]['name'],
                                  "selected!!")
                            character = data[button.index(rect)]['name']
                            character_id = data[button.index(rect)]['id']
                            running = False
                            print([character, character_id])
                            return ([character, character_id])
                            # player2_id=randint(0,4)
                            # player2=data[player2_id]['name']
                            # game_obj=Game(character,character_id,player2,player2_id)
                            # game_obj.play()

            pygame.display.update()
            self.mainClock.tick(60)
Beispiel #10
0
    def wip(self):
        while True:
            self.screen.blit(multi, (0, 0))
            s = "We are still working on this."
            q = "Try playing the game locally :)"
            write_text(s, self.font_sm, (255, 255, 255), self.screen, 400, 240)
            write_text(q, self.font_sm, (255, 255, 255), self.screen, 400, 270)
            btn = pygame.Rect(260, 375, 270, 50)
            pygame.draw.rect(self.screen, (255, 255, 255), btn)
            write_text('Continue', self.font, (0, 0, 0), self.screen, 400, 400)

            for event in pygame.event.get():
                if event.type == QUIT:
                    pygame.quit()
                    sys.exit()
                mouse_pos = pygame.mouse.get_pos()
                if btn.collidepoint(mouse_pos):
                    if event.type == MOUSEBUTTONDOWN:
                        print("continue locally")
                        return 1
            pygame.display.update()
            self.mainClock.tick(60)
Beispiel #11
0
 def player2_char_set(self):
     write_text(self.player2, self.font_sm, (255, 255, 255), self.screen,
                600, 30)
     self.health_bar(2)
     self.health_bar_update(2)
     self.set_img(2)
Beispiel #12
0
 def player1_char_set(self):
     write_text(self.player1, self.font_sm, (255, 255, 255), self.screen,
                200, 30)
     self.health_bar(1)
     self.health_bar_update(1)
     self.set_img(1)