コード例 #1
0
def main(debug, hostname, port, name):
    if debug:
        logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.DEBUG)
    else:
        logging.basicConfig(format='[%(asctime)s] %(message)s', level=logging.INFO)

    # Connect to game server
    GameServer = ServerComms(hostname, port)

    # Spawn our tank
    logging.info("Creating tank with name '{}'".format(name))
    GameServer.sendMessage(ServerMessageTypes.CREATETANK, {'Name': name})

    # static reference to game, easier for other files to use it
    game.data = GameData(GameServer, name)

    game.data.game_server.sendMessage(ServerMessageTypes.TOGGLEFORWARD)
    # state.game_server.sendMessage(ServerMessageTypes.MOVEFORWARDDISTANCE, {"Amount": 10})

    behavior_tree: BehaviorTree = behavior_tree_factory.get_tree()

    while True:
        messagePayload = GameServer.readMessage()
        game.data.update(messagePayload)

        behavior_tree.run()
コード例 #2
0
	def prepareGame(self):
		if self.camera:
			# Disable Mouse Control for camera
			self.disableMouse()
			
			self.camera.setPos(0, 0, 500)
			self.camera.lookAt(0, 0, 0)

		self.gameData = GameData(True)
		
		# game data
		self.broadcastData(('gamedata', self.gameData.packageData()))
		self.broadcastData(('state', 'preround'))
		if self.online:
			self.client.sendData(('state', 'preround'))
		print "Preparing Game"
		self.gameTime = 0
		self.tick = 0

		usersData = []
		for user in self.users:
			usersData.append(user.gameData)
		self.game = Game(self, usersData, self.gameData)
		self.taskMgr.doMethodLater(0.5, self.roundReadyLoop, 'Game Loop')
		print "Round ready State"
コード例 #3
0
ファイル: main.py プロジェクト: trbail01/Jeopardy
def main(*flags):
    """Main game loop and event handling."""

    # Initialization
    pygame.init()
    #Put window in center of screen
    os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'

    screen = pygame.display.set_mode(SCREEN_SIZE,
                                     pygame.FULLSCREEN if FULLSCREEN else 0)
    pygame.display.set_caption('Jeopardy!')

    # Declarations
    gameData = GameData()
    gs = JeopGameState()
    uicontroller = Controller(screen, gameData, FPS_LIMIT)
    clock = pygame.time.Clock()

    # Intro sequence (control passed completely to functions)
    if SKIP_INTRO_FLAG not in flags:
        pygame.mouse.set_visible(0)
        do_intro(screen, clock, uicontroller.audioplayer)
        do_scroll(screen, clock, gameData.categories)
        pygame.mouse.set_visible(1)

    # Prep for primary loop
    pygame.event.set_allowed(None)
    pygame.event.set_allowed(EVENTS_ALLOWED)
    uicontroller.draw(screen)

    # Primary loop
    while not gs.state == gs.GAME_END:
        # Events
        handle_events(gs, gameData, uicontroller)
        handle_buzzers(gs, gameData)

        if gs.state == gs.QUIT:
            pygame.quit()
            sys.exit()

        # Update
        gameData.update(gs)
        uicontroller.update(gs, gameData)
        gs.transition_state_immediate_linear(gameData)
        transition_state_branching(gs, gameData, uicontroller)

        # Draw
        uicontroller.draw(screen)

        # Cleanup
        pygame.event.pump()
        clock.tick_busy_loop(FPS_LIMIT)

    # Post game: Congratulations screen and credits
    pygame.mouse.set_visible(0)
    do_congrats(screen, clock, gameData.winners, uicontroller.audioplayer)
    do_credits(screen, clock, uicontroller.audioplayer, FPS_LIMIT)
コード例 #4
0
ファイル: pregame.py プロジェクト: H3LLB0Y/Centipede
    def __init__(self, showbase):
        self.showbase = showbase

        self.ready = False

        self.background = DirectFrame(
            frameSize=(-1, 1, -1, 1),
            frameTexture='media/gui/mainmenu/menu.png',
            parent=self.showbase.render2d,
        )

        self.title = OnscreenText(text='Lobby!',
                                  fg=(1, 1, 1, 1),
                                  parent=self.background,
                                  pos=(-0.6, 0.1),
                                  scale=0.06)

        self.buttons = []
        controlButtons = Vec3(-0.60, 0, -0.79)
        # Toggle ready
        p = controlButtons + Vec3(-0.25, 0, 0)
        self.toggleReadyButton = DirectButton(
            text='Ready/Unready',
            pos=p,
            scale=0.048,
            relief=DGG.GROOVE,
            command=self.toggleReady,
        )
        self.buttons.append(self.toggleReadyButton)
        # Disconnect
        p = controlButtons + Vec3(0.0, 0.0, 0.0)
        self.disconnectButton = DirectButton(
            text='Disconnect',
            pos=p,
            scale=0.048,
            relief=DGG.GROOVE,
            command=self.disconnect,
        )
        self.buttons.append(self.disconnectButton)

        # Send message
        p = controlButtons + Vec3(0.25, 0.0, 0.0)
        self.sendMessageButton = DirectButton(
            text='Send Message',
            pos=p,
            scale=0.048,
            relief=DGG.GROOVE,
            command=self.sendMessage,
            extraArgs=[''],
        )
        self.buttons.append(self.sendMessageButton)
        # Message input
        self.message = DirectEntry(
            command=self.sendMessage,
            focusInCommand=self.clearText,
            frameSize=(-3, 3, -.5, 1),
            initialText='',
            parent=self.buttons[2],
            pos=(0, -0.6, -1.5),
            text_align=TextNode.ACenter,
        )

        self.showbase.gameData = GameData()

        self.showbase.users = []

        self.hide()
コード例 #5
0
 def load_realtime_data(self):
     sharedData = {}
     self.parser = self.bot.set_up_parser(sharedData, self.do_turn)
     self.data = GameData(sharedData)
     self.data.reset()