def startGame(self):
     self.started = True
     self.model = GameLogic(self.n)
     self.gameOver = False
     self.onPause = True
     self.master.after(0, self.draw)
     self.numberOfMoves = 0
     self.shuffleBoard()
     self.canvas.bind("<Button-1>", self.mouse)
     self.t = Timer(self.master, self.canvas)
Example #2
0
 def startGame(self):
     # starts game
     # change app state
     self.started = True
     self.gameOver = False
     self.robotSolved = False
     self.model = GameLogic(self.n)
     self.seed = []
     self.numberOfMoves = 0
     self.t = Timer(self.master, self.canvas)
     # run draw loop
     self.master.after(0, self.draw)
     # start shuffling the board
     self.shuffleBoard()
Example #3
0
    def startGame(self):
        settings.PLAYERS = [
            Player(id=i, ai=True) for i in range(settings.NUMBER_OF_PLAYERS)
        ]
        settings.FACTORIES = self.makeFactories(settings.NUMBER_OF_PLAYERS *
                                                2 + 1)
        settings.PILE = Pile()
        settings.BAG = Bag(100)
        settings.FIRSTPLAYERSTONE = Stone(None, firstPlayerStone=True)
        settings.ROUNDLOGIC = RoundLogic()
        settings.GRAPHICS.initTextboxes()
        settings.GAMELOGIC = GameLogic()
        settings.GAMELOGIC.mainLoop()

        # End the game when main loop is over
        settings.GAMELOGIC.gameOver()
        pg.quit()
        quit()
Example #4
0
    def __init__(self, chat):
        """
        
        """
        events.EventEnabled.__init__(self)
        self.gamestate = GameState()
        self.game_logic = GameLogic(self.gamestate)
        self.graphics = Graphics()
        self.event_source = events.RootEventSource()
        self.event_source.set_blocking(False)

        self.chat = chat
        self._running = True

        self.reg_event_func(pygame.QUIT, self.on_quit)
        self.reg_event_func(pygame.KEYDOWN, self.on_key)
        self.event_source.add_listener(self)

        self.clock = pygame.time.Clock()
Example #5
0
            if pos.isSolved():
                solution = pos.path
                break

            for newBoard, newEmpty, move in pos.possibleMoves():
                newPos = Positions(pos.level+1, newBoard,
                                   newEmpty, pos.path + self.tMove(move), self.n)
                if newPos not in self.visited:
                    self.visited.add(newPos)
                    self.queue.put(newPos)
        # print(time.time() - self.start, solution)
        return solution, time.time() - self.start


if __name__ == "__main__":
    from gamelogic import GameLogic
    f = open("data.csv", "a+")
    for _ in range(1000):
        g = GameLogic(4)
        g.shuffleBoard()
        board = g.getBoard()
        out = ""
        for i in range( len(board)):
            for n in board[i]:
                out += str(n) + ","
        soln = Solver(g, 4).getSolution()
        row = out +  str(len(soln)) + "\n"
        print(row)
        f.write(row)
    f.close()
Example #6
0
from player import Player
from sprites import *
from cast import ray_casting_walls
from hud import HUD
from gamelogic import GameLogic
pygame.init()
sc = pygame.display.set_mode((GAME_WIDTH, GAME_HEIGHT), pygame.DOUBLEBUF)
clock = pygame.time.Clock()
mp = pygame.Surface(MAP_RES)
all_s = Sprites()
player = Player(all_s)
drawing = HUD(sc, mp, player, clock)
game_logic = GameLogic(player, all_s, drawing)
drawing.menu()
pygame.mouse.set_visible(False)
game_logic.play_music()
while True:
    player.movement()
    drawing.background()
    walls, wall_shot = ray_casting_walls(player, drawing.textures)
    drawing.world(walls + [obj.locate(player) for obj in all_s.world])
    drawing.hud_fps(clock)
    drawing.mini_map()
    drawing.player_weapon([wall_shot, all_s.shot])
    game_logic.interaction_objects()
    game_logic.npc_action()
    game_logic.clear()
    game_logic.check_win()
    pygame.display.flip()
    clock.tick()
Example #7
0
def resource_path(relative_path):
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")

    return os.path.join(base_path, relative_path)


if __name__ == "__main__":

    setting = Setting(resource_path("setting.config"))

    screen_resolution = setting.get_screen_resolution()

    grid = setting.get_grid()

    pygame.init()

    game_logic = GameLogic(Board(grid[0], grid[1]), setting.get_n())
    game_logic.init()

    screen = pygame.display.set_mode(screen_resolution)

    cell_size = get_cell_size(screen_resolution[0], screen_resolution[1],
                              game_logic.get_board().get_size())

    game_loop(screen, cell_size, game_logic)