Example #1
0
	def __init__(self):
		self.mt = multiTimer.multiTimer()
		self.mt.start("runtime")
		self.minValue = -1
		self.maxValue = 0
		self.totalValues = 0
		self.totalAcceptedValues = 0
Example #2
0
 def __init__(self):
     self.mt = multiTimer.multiTimer()
     self.mt.start("runtime")
     self.minValue = -1
     self.maxValue = 0
     self.totalValues = 0
     self.totalAcceptedValues = 0
Example #3
0
    def __init__(self, *args, **kwargs):
        super(Window, self).__init__(*args, **kwargs)

        # Whether or not the window exclusively captures the mouse.
        self.exclusive = False

        # When flying gravity has no effect and speed is increased.
        self.flying = True

        # First element is -1 when moving forward, 1 when moving back, and 0
        # otherwise. The second element is -1 when moving left, 1 when moving
        # right, and 0 otherwise.
        self.strafe = [0, 0]

        # Current (x, y, z) position in the world, specified with floats.
        self.position = (-2, -2, 1)

        # First element is rotation of the player in the x-z plane (ground
        # plane) measured from the z-axis down. The second is the rotation
        # angle from the ground plane up.
        self.rotation = (100, 0)

        # Which sector the player is currently in.
        self.sector = None

        # The crosshairs at the center of the screen.
        self.reticle = None

        # Velocity in the y (upward) direction.
        self.dy = 0

        # A list of blocks the player can place. Hit num keys to cycle.
        self.inventory = []
        for i in range(0, len(MATERIALS), 10):
            # print "inventory:",i, MATERIALS[i]
            self.inventory.append(i)

            # The current block the user can place. Hit num keys to cycle.
        self.block = self.inventory[0]

        # Convenience list of num keys.
        self.num_keys = [key._1, key._2, key._3, key._4, key._5, key._6, key._7, key._8, key._9, key._0]

        # the block that is currently focused
        self.focusedBlock = None

        # Instance of the model that handles the world.
        self.model = Model()

        # Instance of world modificator "blockwork"
        self.blockWork = blockWork.blockWork(self.model)

        self.labelDict = {}

        # The label that is displayed in the top left of the canvas.
        self.labelDict["worldInfo"] = pyglet.text.Label(
            "",
            font_name="Arial",
            font_size=16,
            x=10,
            y=self.height - 10,
            anchor_x="left",
            anchor_y="top",
            color=(0, 0, 0, 255),
        )

        # fix label while rendering the world
        self.labelDict["loabel"] = pyglet.text.Label(
            "!RENDERING WORLD, STAY TUNED!",
            font_name="Arial",
            font_size=16,
            x=self.width / 2,
            y=self.height / 2,
            anchor_x="center",
            anchor_y="top",
            color=(0, 0, 0, 255),
        )

        # notifications from engine
        self.labelDict["notify"] = pyglet.text.Label(
            "",
            font_name="Arial",
            font_size=16,
            x=self.width / 2,
            y=self.height / 2,
            anchor_x="center",
            anchor_y="top",
            color=(0, 0, 0, 255),
        )

        # focues block label
        self.labelDict["focusedBlock"] = pyglet.text.Label(
            "", font_name="Arial", font_size=12, x=5, y=25, anchor_x="left", anchor_y="top", color=(0, 0, 0, 255)
        )

        # This call schedules the `update()` method to be called 60 times a
        # second. This is the main game event loop.
        pyglet.clock.schedule_interval(self.update, 1.0 / 60)

        # interaction speed during mouse down events
        self.mouseInteractionSpeed = 0.35

        # start in window mode!
        self.fullScreen = False

        # a master timer for all the timers!
        self.mt = multiTimer.multiTimer()

        # check args for parameters
        for arg in sys.argv:
            if arg.startswith("rmVol="):
                # collect and remove "small" volumes
                self.blockWork.removeSmallVolumes(self.blockWork.getVolumes(), int(arg.replace("rmVol=", "")))  # 10000)
            elif arg.startswith("fillCavities="):
                # fill empty space
                self.blockWork.fillHoles(int(arg.replace("fillCavities=", "")))

                # add timer and bool for the initial loading text while rendereing the world
                # for the first time
        self.renderWorld = True
        self.mt.start("renderWorld")
Example #4
0
	def __init__(self, *args, **kwargs):
		super(Window, self).__init__(*args, **kwargs)

		# Whether or not the window exclusively captures the mouse.
		self.exclusive = False

		# When flying gravity has no effect and speed is increased.
		self.flying = True

		# First element is -1 when moving forward, 1 when moving back, and 0
		# otherwise. The second element is -1 when moving left, 1 when moving
		# right, and 0 otherwise.
		self.strafe = [0, 0]

		# Current (x, y, z) position in the world, specified with floats.
		self.position = (-2, -2, 1)

		# First element is rotation of the player in the x-z plane (ground
		# plane) measured from the z-axis down. The second is the rotation
		# angle from the ground plane up.
		self.rotation = (100, 0)

		# Which sector the player is currently in.
		self.sector = None

		# The crosshairs at the center of the screen.
		self.reticle = None

		# Velocity in the y (upward) direction.
		self.dy = 0

		# A list of blocks the player can place. Hit num keys to cycle.
		self.inventory = []
		for i in range(0, len(MATERIALS), 10):
			#print "inventory:",i, MATERIALS[i]
			self.inventory.append(i)

		# The current block the user can place. Hit num keys to cycle.
		self.block = self.inventory[0]

		# Convenience list of num keys.
		self.num_keys = [
			key._1, key._2, key._3, key._4, key._5,
			key._6, key._7, key._8, key._9, key._0]

		# the block that is currently focused
		self.focusedBlock = None

		# Instance of the model that handles the world.
		self.model = Model()
		
		# Instance of world modificator "blockwork"
		self.blockWork = blockWork.blockWork(self.model)

		self.labelDict = {}

		# The label that is displayed in the top left of the canvas.
		self.labelDict['worldInfo'] = pyglet.text.Label('', font_name='Arial', font_size=16,
			x=10, y=self.height - 10, anchor_x='left', anchor_y='top',
			color=(0, 0, 0, 255))

		# fix label while rendering the world
		self.labelDict['loabel'] = pyglet.text.Label("!RENDERING WORLD, STAY TUNED!", font_name='Arial', font_size=16,
			x=self.width / 2, y=self.height / 2 , anchor_x='center', anchor_y='top',
			color=(0, 0, 0, 255))
			
		# notifications from engine
		self.labelDict['notify'] = pyglet.text.Label("", font_name='Arial', font_size=16,
			x=self.width / 2, y=self.height / 2 , anchor_x='center', anchor_y='top',
			color=(0, 0, 0, 255))
		
		# focues block label
		self.labelDict['focusedBlock'] = pyglet.text.Label("", font_name='Arial', font_size=12,
			x=5, y=25, anchor_x='left', anchor_y='top',
			color=(0, 0, 0, 255))

		# This call schedules the `update()` method to be called 60 times a
		# second. This is the main game event loop.
		pyglet.clock.schedule_interval(self.update, 1.0 / 60)
		
		# interaction speed during mouse down events
		self.mouseInteractionSpeed = 0.35
		
		# start in window mode!
		self.fullScreen = False
		
		# a master timer for all the timers!
		self.mt = multiTimer.multiTimer()
		
		# check args for parameters
		for arg in sys.argv:
			if arg.startswith("rmVol="):
				# collect and remove "small" volumes
				self.blockWork.removeSmallVolumes(self.blockWork.getVolumes(), int(arg.replace("rmVol=", ""))) #10000)
			elif arg.startswith("fillCavities="):
				# fill empty space
				self.blockWork.fillHoles(int(arg.replace("fillCavities=", "")))
		
		# add timer and bool for the initial loading text while rendereing the world
		# for the first time
		self.renderWorld = True
		self.mt.start("renderWorld")
Example #5
0
	def __init__(self, model):
		self.mt = multiTimer.multiTimer()
		self.model = model