def gameRoute(self, event): e = self.game.getEvent(event) if e == 'restart': print(self.session.credit) self.game = Game(self.session) self.uiManager = self.game.getManager() self.pressed()
def homeRoute(self, event): if self.home.getView(event) != self.home: if self.home.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') elif self.home.getView(event) == 'creating': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') self.game = Game(self.session) self.uiManager = self.game.getManager() self.setRoute('game') elif self.home.getView(event) == 'instruction': self.uiManager = self.instruction.getManager() self.setRoute('instruction') elif self.home.getView(event) == 'loading': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') self.game = Game(self.session) self.game.score = self.session.score self.game.setLabelScore() self.uiManager = self.game.getManager() self.setRoute('game')
from main import Katurigja from views.game import Game from controllers.client import Local game = Katurigja() client = Local({'map_name': 'flat_grassland'}) game.bind(on_stop=lambda *args, **kwargs: client.pause()) game.view.add_widget(Game(client)) game.run()
class Katurigja(App): view = ScreenManager(transition=FadeTransition()) def build(self): return self.view if __name__ == '__main__': from controllers.client import Local from views.menu import Menu from views.game_setup import GameSetup from views.game import Game game = Katurigja() client = Local() game.view.add_widget(Menu(name='main_menu', )) game.view.add_widget( GameSetup( last_screen='main_menu', client=client, name='game_setup', )) game.view.add_widget(Game( client=client, name='game', )) game.run()
from views import home from views.game import Game players = home.getPlayers() Game().start(players)
def main(): Game()
class Route(): def __init__(self, route): self.signup = Signup() self.login = Login() self.home = Home() self.instruction = Instruction() # self.loading = Loading() self.createParty = CreateParty() self.session = None self.party = None self.route = route self.uiManager = self.login.getManager() def getRoute(self): return self.route def setRoute(self, route): self.route = route def homeRoute(self, event): if self.home.getView(event) != self.home: if self.home.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') elif self.home.getView(event) == 'creating': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') self.game = Game(self.session) self.uiManager = self.game.getManager() self.setRoute('game') elif self.home.getView(event) == 'instruction': self.uiManager = self.instruction.getManager() self.setRoute('instruction') elif self.home.getView(event) == 'loading': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') self.game = Game(self.session) self.game.score = self.session.score self.game.setLabelScore() self.uiManager = self.game.getManager() self.setRoute('game') def loginRoute(self, event): # if self.getRoute() == 'login': if self.login.getView(event) != self.login: if self.login.getView(event) == 'home': pseudo = self.login.getPseudo().get_text() password = self.login.getPassword().get_text() self.session = Auth().login(pseudo, password) if self.session: self.uiManager = self.home.getManager() self.setRoute('home') elif self.login.getView(event) == 'signup': self.uiManager = self.signup.getManager() self.setRoute('signup') def signupRoute(self, event): # if self.getRoute() == 'signup': if self.signup.getView(event) != self.signup: if self.signup.getView(event) == 'home': pseudo = self.signup.getPseudo().get_text() password = self.signup.getPassword().get_text() self.session = Auth().register(pseudo, password) # print(self.session.credit) if self.session: self.uiManager = self.home.getManager() self.setRoute('home') elif self.signup.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') # def loadingRoute(self, event): # # if self.getRoute() == 'loading': # if self.loading.getView(event) != self.loading: # if self.loading.getView(event) == 'signup': # self.uiManager = self.signup.getManager() # self.setRoute('signup') # elif self.home.getView(event) == 'creating': # self.uiManager = self.createParty.getManager() # self.setRoute('creating') # def CreatePartyRoute(self, event): # if self.getRoute() == 'creating': # if self.createParty.getView(event) != self.createParty: # if self.createParty.getView(event) == 'game': # name = self.createParty.getParty().get_text() # self.party = Part().createParty(name) # print(self.session) # if self.party: # self.game = Game(self.session) # self.uiManager = self.game.getManager() # self.setRoute('game') def gameRoute(self, event): e = self.game.getEvent(event) if e == 'restart': print(self.session.credit) self.game = Game(self.session) self.uiManager = self.game.getManager() self.pressed() def instructionRoute(self, event): if self.instruction.getView(event) != self.instruction: if self.instruction.getView(event) == 'login': self.uiManager = self.login.getManager() self.setRoute('login') elif self.instruction.getView(event) == 'home': self.uiManager = self.home.getManager() self.setRoute('home') def pressed(self): if self.game.pressed.get(pygame.K_RIGHT): self.game.player.move("right") elif self.game.pressed.get(pygame.K_LEFT): self.game.player.move("left") self.game.updatePosPlayer() def getAllEnemy(self): return self.game.allEnemy
def draw_surface(screen, replaying): surface = pygame.Surface(screen.get_size()) surface = surface.convert() game = Game(surface, surface_color1, surface_color2, replaying) game.draw_grid() return surface, game