text: from __future__ import division
  
  from core.core import * 
  
  TICKS_PER_SEC = 60
  
  # Size of sectors used to ease block loading.
  SECTOR_SIZE = 16
  
  WALKING_SPEED = 5
  FLYING_SPEED = 15
  
  GRAVITY = 10.0
  MAX_JUMP_HEIGHT = 1.2 # About the height of a block.
  # To derive the formula for calculating jump speed, first solve
  #    v_t = v_0 + a * t
  # for the time at which you achieve maximum height, where a is the acceleration
  # due to gravity and v_t = 0. This gives:
  #    t = - v_0 / a
  # Use t and the desired MAX_JUMP_HEIGHT to solve for v_0 (jump speed) in
  #    s = s_0 + v_0 * t + (a * t^2) / 2
  JUMP_SPEED = math.sqrt(2 * GRAVITY * MAX_JUMP_HEIGHT)
  TERMINAL_VELOCITY = 50
  
  PLAYER_HEIGHT = 2
  
  
  TEXTURE_PATH = 'texture.png'
  
  GRASS = tex_coords((1, 0), (0, 1), (0, 0))
  SAND = tex_coords((1, 1), (1, 1), (1, 1))
  BRICK = tex_coords((2, 0), (2, 0), (2, 0))
  STONE = tex_coords((2, 1), (2, 1), (2, 1))
  
  FACES = [
      ( 0, 1, 0),
      ( 0,-1, 0),
      (-1, 0, 0),
      ( 1, 0, 0),
      ( 0, 0, 1),
      ( 0, 0,-1),
  ]
  
  
  def setup_fog():
      """ Configure the OpenGL fog properties.
  
      """
      # Enable fog. Fog "blends a fog color with each rasterized pixel fragment's
      # post-texturing color."
      glEnable(GL_FOG)
      # Set the fog color.
      glFogfv(GL_FOG_COLOR, (GLfloat * 4)(0.5, 0.69, 1.0, 1))
      # Say we have no preference between rendering speed and quality.
      glHint(GL_FOG_HINT, GL_DONT_CARE)
      # Specify the equation used to compute the blending factor.
      glFogi(GL_FOG_MODE, GL_LINEAR)
      # How close and far away fog starts and ends. The closer the start and end,
      # the denser the fog in the fog range.
      glFogf(GL_FOG_START, 20.0)
      glFogf(GL_FOG_END, 60.0)
  
  
  def setup():
      """ Basic OpenGL configuration.
  
      """
      # Set the color of "clear", i.e. the sky, in rgba.
      glClearColor(0.5, 0.69, 1.0, 1)
      # Enable culling (not rendering) of back-facing facets -- facets that aren't
      # visible to you.
      glEnable(GL_CULL_FACE)
      # Set the texture minification/magnification function to GL_NEAREST (nearest
      # in Manhattan distance) to the specified texture coordinates. GL_NEAREST
      # "is generally faster than GL_LINEAR, but it can produce textured images
      # with sharper edges because the transition between texture elements is not
      # as smooth."
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
      setup_fog()
  
  
  def main():
      window = Window(width=800, height=600, caption='PyMinerClone', resizable=True)
      # Hide the mouse cursor and prevent the mouse from leaving the window.
      #window.set_exclusive_mouse(True)
      window.set_exclusive_mouse(False)
      setup()
      pyglet.app.run()
  
  
  if __name__ == '__main__':
      main()
  