MCPcopy Index your code
hub / github.com/fogleman/Minecraft / Window

Class Window

main.py:434–852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432
433
434class Window(pyglet.window.Window):
435
436 def __init__(self, *args, **kwargs):
437 super(Window, self).__init__(*args, **kwargs)
438
439 # Whether or not the window exclusively captures the mouse.
440 self.exclusive = False
441
442 # When flying gravity has no effect and speed is increased.
443 self.flying = False
444
445 # Strafing is moving lateral to the direction you are facing,
446 # e.g. moving to the left or right while continuing to face forward.
447 #
448 # First element is -1 when moving forward, 1 when moving back, and 0
449 # otherwise. The second element is -1 when moving left, 1 when moving
450 # right, and 0 otherwise.
451 self.strafe = [0, 0]
452
453 # Current (x, y, z) position in the world, specified with floats. Note
454 # that, perhaps unlike in math class, the y-axis is the vertical axis.
455 self.position = (0, 0, 0)
456
457 # First element is rotation of the player in the x-z plane (ground
458 # plane) measured from the z-axis down. The second is the rotation
459 # angle from the ground plane up. Rotation is in degrees.
460 #
461 # The vertical plane rotation ranges from -90 (looking straight down) to
462 # 90 (looking straight up). The horizontal rotation range is unbounded.
463 self.rotation = (0, 0)
464
465 # Which sector the player is currently in.
466 self.sector = None
467
468 # The crosshairs at the center of the screen.
469 self.reticle = None
470
471 # Velocity in the y (upward) direction.
472 self.dy = 0
473
474 # A list of blocks the player can place. Hit num keys to cycle.
475 self.inventory = [BRICK, GRASS, SAND]
476
477 # The current block the user can place. Hit num keys to cycle.
478 self.block = self.inventory[0]
479
480 # Convenience list of num keys.
481 self.num_keys = [
482 key._1, key._2, key._3, key._4, key._5,
483 key._6, key._7, key._8, key._9, key._0]
484
485 # Instance of the model that handles the world.
486 self.model = Model()
487
488 # The label that is displayed in the top left of the canvas.
489 self.label = pyglet.text.Label('', font_name='Arial', font_size=18,
490 x=10, y=self.height - 10, anchor_x='left', anchor_y='top',
491 color=(0, 0, 0, 255))

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected