def __init__(self, screen, fight_stats, position=Point(0, 0)): self.screen = screen self.texts_P1 = [] self.texts_P2 = [] self.keysP1 = config.OptionConfig().keysP1 self.keysP2 = config.OptionConfig().keysP2 win_perc_P1 = round(fight_stats.wins_P1 / (fight_stats.wins_P1 + fight_stats.wins_P2) * 100) rounds_perc_P1 = round( fight_stats.rounds_P1 / (fight_stats.rounds_P1 + fight_stats.rounds_P2) * 100) win_perc_P2 = round(fight_stats.wins_P2 / (fight_stats.wins_P1 + fight_stats.wins_P2) * 100) rounds_perc_P2 = round( fight_stats.rounds_P2 / (fight_stats.rounds_P1 + fight_stats.rounds_P2) * 100) draw_perc = round( fight_stats.draws / (fight_stats.wins_P1 + fight_stats.wins_P2 + fight_stats.draws) * 100) if fight_stats.lastwin != 0: self.addTxt(self.texts_P1, "Player " + str(fight_stats.lastwin) + " wins !") else: self.addTxt(self.texts_P1, "Draw game !!") self.addTxt(self.texts_P1) self.addTxt(self.texts_P1, "Stats") self.addTxt(self.texts_P1, "P1:") self.addTxt(self.texts_P1, str(fight_stats.wins_P1) + " win(s)") self.addTxt(self.texts_P1, "(" + str(win_perc_P1) + "%)") self.addTxt(self.texts_P1, str(fight_stats.rounds_P1) + " round(s)") self.addTxt(self.texts_P1, "(" + str(rounds_perc_P1) + "%)") self.addTxt(self.texts_P1) self.addTxt( self.texts_P1, "Draws:" + str(fight_stats.draws) + "(" + str(draw_perc) + "%)") self.addTxt(self.texts_P2) self.addTxt(self.texts_P2) self.addTxt(self.texts_P2) self.addTxt(self.texts_P2, "P2:") self.addTxt(self.texts_P2, str(fight_stats.wins_P2) + " win(s)") self.addTxt(self.texts_P2, "(" + str(win_perc_P2) + "%)") self.addTxt(self.texts_P2, str(fight_stats.rounds_P2) + " round(s)") self.addTxt(self.texts_P2, "(" + str(rounds_perc_P2) + "%)") self.select = MultChoice("Select", ["rematch", "char. select", "main menu"], 0, Point(0, 200))
def __init__(self, screen, position=Point(0, 0)): self.config = config.OptionConfig('../res/config.txt') Menu.__init__(self, position, screen, 'OptionScreen.png') self.addElt(Text('Game Options')) self.addElt( MultChoice('Time', ['infinite', '30', '60', '99'], value=self.config.time)) self.addElt( MultChoice('Rounds to win', ['1', '2', '3', '5'], value=self.config.rounds)) self.addElt(Text('')) self.addElt(Text('Video Option:')) self.addElt( MultChoice('Size', [ '320x240', '640x480', '640x480(2X)', '800x600', '960x720', '960x720(2X)', '1280x960', '1280x960(2X)', 'Fullscreen' ], value=self.config.video)) # self.addElt(YesNo('Fullscreen', value = self.config.fullscreen)) self.addElt(Text('')) self.addElt(Text('Sound Options')) self.addElt(Value('Sound', value=self.config.sound, maxValue=8)) self.addElt(Value('Music', value=self.config.music, maxValue=8)) self.addElt(Text('')) self.addElt(KeySetter('Set keys for P1', value=self.config.keysP1)) self.addElt(KeySetter('Set keys for P2', value=self.config.keysP2)) self.choice = 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')
def __init__(self, screen, position = Point(0,0)): self.config = config.OptionConfig('../res/config.txt') config.SoundPlayer().play_music('Intro.mp3') Menu.__init__(self, position, screen, 'MenuScreen.png') self.addElt(MenuElt('Start Vs Game', self.call_game)) self.addElt(MenuElt('Options', self.call_option)) self.addElt(MenuElt('Credits', self.call_credits)) self.choice = 0
def call_charmenu(self): self.config = config.OptionConfig() menu = CharSelectMenu(self.screen, self.config.keysP1, self.config.keysP2, Point(0,0)) characters = menu.mainloop() if characters == 0: return 0, 0 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) return player1, player2
import pygame, os import config import menu from menu import getCharList from Round import Player from game import * if __name__ == "__main__": print('loading...') pygame.init() pygame.mixer.init() screen = pygame.display.set_mode((320, 240), 0, 32) pygame.display.set_caption("charSelect") # program title config = config.OptionConfig() print('Loading all...') for name in getCharList(): print('loading', name + '...') char = Player(name, 120, 100, alt_color=False) altchar = Player(name, 120, 100, alt_color=True) print(name, 'ok') menu = menu.CharSelectMenu(screen, config.keysP1, config.keyP2, Point(0, 0)) menu.mainloop() # config.keysP2,(0)
import pygame, os import config import menu from game import Point if __name__ == "__main__": print('loading...') options = config.OptionConfig() pygame.init() pygame.mixer.init() config.Screen() screen = pygame.Surface((320, 240), 0, 32) menu = menu.MainMenu(screen, Point(50, 140)) menu.mainloop()