def handle_keydown(view, event, i_store, world, entity_select):
   (view_delta, entity_select) = on_keydown(event, world,
      entity_select, i_store)
   worldview.update_view(view, view_delta,
      image_store.get_images(i_store, entity_select)[0])

   return entity_select
Ejemplo n.º 2
0
 def _create_blob(self, world, name, pt, rate, ticks, i_store):
    blob = OreBlob(name, pt, rate,
       image_store.get_images(i_store, 'blob'),
       random.randint(actions.BLOB_ANIMATION_MIN, actions.BLOB_ANIMATION_MAX)
       * actions.BLOB_ANIMATION_RATE_SCALE)
    blob._schedule(world, ticks, i_store)
    return blob
Ejemplo n.º 3
0
def handle_keydown(view, event, i_store, world, entity_select):
   (view_delta, entity_select) = on_keydown(event, world,
      entity_select, i_store)
   worldview.update_view(view, view_delta,
      image_store.get_images(i_store, entity_select)[0])

   return entity_select
Ejemplo n.º 4
0
 def create_blob(world, name, pt, rate, ticks, i_store):
     blob = entities.OreBlob(
         name, pt, rate, image_store.get_images(i_store, 'blob'),
         random.randint(BLOB_ANIMATION_MIN, BLOB_ANIMATION_MAX) *
         BLOB_ANIMATION_RATE_SCALE)
     schedule_blob(world, blob, ticks, i_store)
     return blob
Ejemplo n.º 5
0
def create_obstacle(properties, i_store):
   if len(properties) == OBSTACLE_NUM_PROPERTIES:
      return entities.Obstacle(properties[OBSTACLE_NAME],
         point.Point(int(properties[OBSTACLE_COL]), int(properties[OBSTACLE_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]))
   else:
      return None
Ejemplo n.º 6
0
def create_blob(world, name, pt, rate, ticks, i_store): #place in ore
   blob = entities.OreBlob(name, pt, rate,
      image_store.get_images(i_store, 'blob'),
      random.randint(BLOB_ANIMATION_MIN, BLOB_ANIMATION_MAX)
      * BLOB_ANIMATION_RATE_SCALE)
   schedule_blob(world, blob, ticks, i_store)
   return blob
Ejemplo n.º 7
0
    def create_ore(world, name, pt, ticks, i_store):
        ore = entities.Ore(
            name, pt, image_store.get_images(i_store, 'ore'),
            random.randint(world.ORE_CORRUPT_MIN, world.ORE_CORRUPT_MAX))
        world.schedule_ore(world, ore, ticks, i_store)

        return ore
Ejemplo n.º 8
0
def create_blacksmith(properties, i_store):
   if len(properties) == SMITH_NUM_PROPERTIES:
      return entities.Blacksmith(properties[SMITH_NAME],
         point.Point(int(properties[SMITH_COL]), int(properties[SMITH_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]))
   else:
      return None
Ejemplo n.º 9
0
def add_background(world, properties, i_store):
    if len(properties) >= BGND_NUM_PROPERTIES:
        pt = point.Point(int(properties[BGND_COL]), int(properties[BGND_ROW]))
        name = properties[BGND_NAME]
        world.set_background(
            pt, entities.Background(name,
                                    image_store.get_images(i_store, name)))
Ejemplo n.º 10
0
   def handle_keydown(self, view, event, i_store, entity_select):
      (view_delta, entity_select) = self.on_keydown(event,
         entity_select, i_store)
      view.update_view(view_delta,
         image_store.get_images(i_store, entity_select)[0])

      return entity_select    
Ejemplo n.º 11
0
def main():
   random.seed()
   pygame.init()
   #generates a random world seed and initializes pygame
   
   screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
   #generates a display window
   
   i_store = image_store.load_images(IMAGE_LIST_FILE_NAME,
      TILE_WIDTH, TILE_HEIGHT)
   #Acquires all the images?

   num_cols = SCREEN_WIDTH // TILE_WIDTH * WORLD_WIDTH_SCALE
   num_rows = SCREEN_HEIGHT // TILE_HEIGHT * WORLD_HEIGHT_SCALE
   #Sets a number of vertical and horizontal tiles

   default_background = create_default_background(
      image_store.get_images(i_store, image_store.DEFAULT_IMAGE_NAME))
   #Sets the default background to an instance of the Background class

   world = worldmodel.WorldModel(num_rows, num_cols, default_background)
   #Sets world to an instance of the WorldModel class
   
   view = worldview.WorldView(SCREEN_WIDTH // TILE_WIDTH,
      SCREEN_HEIGHT // TILE_HEIGHT, screen, world, TILE_WIDTH, TILE_HEIGHT)
   #Sets view to an instance of the WorldView class

   load_world(world, i_store, WORLD_FILE)
   #Loads the world

   view.update_view()
   #Updates the image on-screen

   controller.activity_loop(view, world)
Ejemplo n.º 12
0
 def create_blob(self, name, pt, rate, ticks, i_store):
    blob = entities.OreBlob(name, pt, rate,
       image_store.get_images(i_store, 'blob'),
       random.randint(BLOB_ANIMATION_MIN, BLOB_ANIMATION_MAX)
       * BLOB_ANIMATION_RATE_SCALE)
    blob.schedule_blob(self,ticks, i_store)
    return blob
Ejemplo n.º 13
0
def create_obstacle(properties, i_store):
   if len(properties) == OBSTACLE_NUM_PROPERTIES:
      return entities.Obstacle(properties[OBSTACLE_NAME],
         point.Point(int(properties[OBSTACLE_COL]), int(properties[OBSTACLE_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]))
   else:
      return None
Ejemplo n.º 14
0
def create_ore(properties, i_store):
   if len(properties) == ORE_NUM_PROPERTIES:
      ore = entities.Ore(properties[ORE_NAME],
         point.Point(int(properties[ORE_COL]), int(properties[ORE_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[ORE_RATE]))
      return ore
   else:
      return None
Ejemplo n.º 15
0
def create_vein(properties, i_store):
   if len(properties) == VEIN_NUM_PROPERTIES:
      vein = entities.Vein(properties[VEIN_NAME], int(properties[VEIN_RATE]),
         point.Point(int(properties[VEIN_COL]), int(properties[VEIN_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[VEIN_REACH]))
      return vein
   else:
      return None
def create_new_entity(pt, entity_select, i_store):
   name = entity_select + '_' + str(pt.x) + '_' + str(pt.y)
   images = image_store.get_images(i_store,entity_select)
   if entity_select == 'obstacle':
      return entities.Obstacle(name, pt, images)
   elif entity_select == 'miner':
      return entities.MinerNotFull(name, MINER_LIMIT, pt,
         random.randint(MINER_RATE_MIN, MINER_RATE_MAX),
         images, MINER_ANIMATION_RATE)
Ejemplo n.º 17
0
def create_blacksmith(properties, i_store):
   if len(properties) == SMITH_NUM_PROPERTIES:
      return entities.Blacksmith(properties[SMITH_NAME],
         point.Point(int(properties[SMITH_COL]), int(properties[SMITH_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[SMITH_LIMIT]), int(properties[SMITH_RATE]))
      return smith
   else:
      return None
Ejemplo n.º 18
0
def create_vein(properties, i_store):
   if len(properties) == VEIN_NUM_PROPERTIES:
      vein = entities.Vein(properties[VEIN_NAME], int(properties[VEIN_RATE]),
         point.Point(int(properties[VEIN_COL]), int(properties[VEIN_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[VEIN_REACH]))
      return vein
   else:
      return None
Ejemplo n.º 19
0
def create_ore(properties, i_store):
   if len(properties) == ORE_NUM_PROPERTIES:
      ore = entities.Ore(properties[ORE_NAME],
         point.Point(int(properties[ORE_COL]), int(properties[ORE_ROW])),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[ORE_RATE]))
      return ore
   else:
      return None
Ejemplo n.º 20
0
def create_miner(properties, i_store):
   if len(properties) == MINER_NUM_PROPERTIES:
      miner = entities.MinerNotFull(properties[MINER_NAME],
         int(properties[MINER_LIMIT]),
         point.Point(int(properties[MINER_COL]), int(properties[MINER_ROW])),
         int(properties[MINER_RATE]),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[MINER_ANIMATION_RATE]))
      return miner
   else:
      return None
Ejemplo n.º 21
0
def create_miner(properties, i_store):
   if len(properties) == MINER_NUM_PROPERTIES:
      miner = entities.MinerNotFull(properties[MINER_NAME],
         int(properties[MINER_LIMIT]),
         point.Point(int(properties[MINER_COL]), int(properties[MINER_ROW])),
         int(properties[MINER_RATE]),
         image_store.get_images(i_store, properties[PROPERTY_KEY]),
         int(properties[MINER_ANIMATION_RATE]))
      return miner
   else:
      return None
def handle_mouse_button(view, world, event, entity_select, i_store):
   mouse_pt = mouse_to_tile(event.pos, view.tile_width, view.tile_height)
   tile_view_pt = view.viewport_to_world(mouse_pt)
   if event.button == mouse_buttons.LEFT and entity_select:
      if is_background_tile(entity_select):
         world.set_background(tile_view_pt,
            entities.Background(entity_select,
               image_store.get_images(i_store,entity_select)))
         return [tile_view_pt]
      else:
         new_entity = create_new_entity(tile_view_pt, entity_select, i_store)
         if new_entity:
Ejemplo n.º 23
0
def create_new_entity(pt, entity_select, i_store):
   name = entity_select + '_' + str(pt.x) + '_' + str(pt.y)
   images = image_store.get_images(i_store, entity_select)
   if entity_select == 'obstacle':
      return entities.Obstacle(name, pt, images)
   elif entity_select == 'miner':
      return entities.MinerNotFull(name, MINER_LIMIT, pt,
         random.randint(MINER_RATE_MIN, MINER_RATE_MAX),
         images, MINER_ANIMATION_RATE)
   elif entity_select == 'vein':
      return entities.Vein(name,
         random.randint(VEIN_RATE_MIN, VEIN_RATE_MAX), pt, images)
   elif entity_select == 'ore':
      return entities.Ore(name, pt, images,
         random.randint(ORE_RATE_MIN, ORE_RATE_MAX))
   elif entity_select == 'blacksmith':
      return entities.Blacksmith(name, pt, images)
   else:
      return None
Ejemplo n.º 24
0
def handle_mouse_button(view, world, event, entity_select, i_store):
   mouse_pt = mouse_to_tile(event.pos, view.tile_width, view.tile_height)
   tile_view_pt = worldview.viewport_to_world(view.viewport, mouse_pt)
   if event.button == mouse_buttons.LEFT and entity_select:
      if is_background_tile(entity_select):
         worldmodel.set_background(world, tile_view_pt,
            entities.Background(entity_select,
               image_store.get_images(i_store, entity_select)))
         return [tile_view_pt]
      else:
         new_entity = create_new_entity(tile_view_pt, entity_select, i_store)
         if new_entity:
            worldmodel.remove_entity_at(world, tile_view_pt)
            worldmodel.add_entity(world, new_entity)
            return [tile_view_pt]
   elif event.button == mouse_buttons.RIGHT:
      worldmodel.remove_entity_at(world, tile_view_pt)
      return [tile_view_pt]
   return []
def main():
   random.seed()
   pygame.init()
   screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
   i_store = image_store.load_images(IMAGE_LIST_FILE_NAME,
      TILE_WIDTH, TILE_HEIGHT)

   num_cols = SCREEN_WIDTH // TILE_WIDTH * WORLD_WIDTH_SCALE
   num_rows = SCREEN_HEIGHT // TILE_HEIGHT * WORLD_HEIGHT_SCALE

   default_background = create_default_background(
      image_store.get_images(i_store, image_store.DEFAULT_IMAGE_NAME))

   world = worldmodel.WorldModel(num_rows, num_cols, default_background)
   view = worldview.WorldView(SCREEN_WIDTH // TILE_WIDTH,
      SCREEN_HEIGHT // TILE_HEIGHT, screen, world, TILE_WIDTH, TILE_HEIGHT)

   view.update_view()

   builder_controller.activity_loop(view, world, i_store)
Ejemplo n.º 26
0
def main():
   random.seed()
   pygame.init()
   screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
   i_store = image_store.load_images(IMAGE_LIST_FILE_NAME,
      TILE_WIDTH, TILE_HEIGHT)

   num_cols = SCREEN_WIDTH // TILE_WIDTH * WORLD_WIDTH_SCALE
   num_rows = SCREEN_HEIGHT // TILE_HEIGHT * WORLD_HEIGHT_SCALE

   default_background = create_default_background(
      image_store.get_images(i_store, image_store.DEFAULT_IMAGE_NAME))

   world = worldmodel.WorldModel(num_rows, num_cols, default_background)
   view = worldview.WorldView(SCREEN_WIDTH // TILE_WIDTH,
      SCREEN_HEIGHT // TILE_HEIGHT, screen, world, TILE_WIDTH, TILE_HEIGHT)

   view.update_view()

   world.activity_loop(view, i_store)
Ejemplo n.º 27
0
def handle_mouse_button(view, world, event, entity_select, i_store):
   mouse_pt = mouse_to_tile(event.pos, view.tile_width, view.tile_height)
   tile_view_pt = worldview.viewport_to_world(view.viewport, mouse_pt)
   if event.button == mouse_buttons.LEFT and entity_select:
      if is_background_tile(entity_select):
         worldmodel.set_background(world, tile_view_pt,
            entities.Background(entity_select,
               image_store.get_images(i_store, entity_select)))
         return [tile_view_pt]
      else:
         new_entity = create_new_entity(tile_view_pt, entity_select, i_store)
         if new_entity:
            worldmodel.remove_entity_at(world, tile_view_pt)
            worldmodel.add_entity(world, new_entity)
            return [tile_view_pt]
   elif event.button == mouse_buttons.RIGHT:
      worldmodel.remove_entity_at(world, tile_view_pt)
      return [tile_view_pt]

   return []
def create_new_entity(pt, entity_select, i_store):
   name = entity_select + '_' + str(pt.x) + '_' + str(pt.y)
   images = image_store.get_images(i_store, entity_select)
   if entity_select == 'obstacle':
      return entities.Obstacle(name, pt, images)
   elif entity_select == 'miner':
      return entities.MinerNotFull(name, MINER_LIMIT, pt,
         random.randint(MINER_RATE_MIN, MINER_RATE_MAX),
         images, MINER_ANIMATION_RATE)
   elif entity_select == 'vein':
      return entities.Vein(name,
         random.randint(VEIN_RATE_MIN, VEIN_RATE_MAX), pt, images)
   elif entity_select == 'ore':
      return entities.Ore(name, pt, images,
         random.randint(ORE_RATE_MIN, ORE_RATE_MAX))
   elif entity_select == 'blacksmith':
      return entities.Blacksmith(name, pt, images,
         random.randint(SMITH_LIMIT_MIN, SMITH_LIMIT_MAX),
         random.randint(SMITH_RATE_MIN, SMITH_RATE_MAX))
   else:
      return None
Ejemplo n.º 29
0
def main(): # this is what starts the game, wouldn't leave that up to a class.
   random.seed() //dont need
   pygame.init()
   screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
   i_store = image_store.load_images(IMAGE_LIST_FILE_NAME,
      TILE_WIDTH, TILE_HEIGHT)

   num_cols = SCREEN_WIDTH // TILE_WIDTH * WORLD_WIDTH_SCALE
   num_rows = SCREEN_HEIGHT // TILE_HEIGHT * WORLD_HEIGHT_SCALE

   default_background = create_default_background(
      image_store.get_images(i_store, image_store.DEFAULT_IMAGE_NAME))

   world = worldmodel.WorldModel(num_rows, num_cols, default_background)
   view = worldview.WorldView(SCREEN_WIDTH // TILE_WIDTH,
      SCREEN_HEIGHT // TILE_HEIGHT, screen, world, TILE_WIDTH, TILE_HEIGHT)

   load_world(world, i_store, WORLD_FILE)

   view.update_view()

   controller.activity_loop(view, world)
Ejemplo n.º 30
0
 def create_vein(world, name, pt, ticks, i_store):
     vein = entities.Vein("vein" + name,
                          random.randint(VEIN_RATE_MIN, VEIN_RATE_MAX), pt,
                          image_store.get_images(i_store, 'vein'))
     return vein
   return ((x_delta, y_delta), entity_select)


def handle_mouse_motion(view, event):
   mouse_pt = mouse_to_tile(event.pos, view.tile_width, view.tile_height)
   view.mouse_move(mouse_pt)


def handle_keydown(view, event, i_store, world, entity_select):
   (view_delta, entity_select) = on_keydown(event, world,
      entity_select, i_store)
   view.update_view(view_delta,
<<<<<<< HEAD
      image_store.get_images(i_store,entity_select)[0])
=======
      image_store.get_images(i_store, entity_select)[0])
>>>>>>> ef5d0d10adbae67ed0396e8f15ace0ac5aefedd0

   return entity_select


def create_new_entity(pt, entity_select, i_store):
   name = entity_select + '_' + str(pt.x) + '_' + str(pt.y)
   images = image_store.get_images(i_store,entity_select)
   if entity_select == 'obstacle':
      return entities.Obstacle(name, pt, images)
   elif entity_select == 'miner':
      return entities.MinerNotFull(name, MINER_LIMIT, pt,
         random.randint(MINER_RATE_MIN, MINER_RATE_MAX),
         images, MINER_ANIMATION_RATE)
   elif entity_select == 'vein':
Ejemplo n.º 32
0
 def create_vein(self, name, pt, ticks, i_store):
    vein = entities.Vein("vein" + name,
       random.randint(VEIN_RATE_MIN, VEIN_RATE_MAX),
       pt, image_store.get_images(i_store, 'vein'))
    return vein
Ejemplo n.º 33
0
 def create_quake(self, pt, ticks, i_store):
    quake = entities.Quake("quake", pt,
       image_store.get_images(i_store, 'quake'), QUAKE_ANIMATION_RATE)
    quake.schedule_quake(self, ticks)
    return quake
Ejemplo n.º 34
0
   def create_ore(self, name, pt, ticks, i_store):
      ore = entities.Ore(name, pt, image_store.get_images(i_store, 'ore'),
         random.randint(ORE_CORRUPT_MIN, ORE_CORRUPT_MAX))
      ore.schedule_ore(self, ticks, i_store)

      return ore
Ejemplo n.º 35
0
    def create_ore(self, name, pt, ticks, i_store):
        ore = entities.Ore(name, pt, image_store.get_images(i_store, 'ore'),
                           random.randint(ORE_CORRUPT_MIN, ORE_CORRUPT_MAX))
        ore.schedule_ore(self, ticks, i_store)

        return ore
Ejemplo n.º 36
0
 def _create_quake(self, world, pt, ticks, i_store):
    quake = Quake("quake", pt, image_store.get_images(i_store, 'quake'), 
       actions.QUAKE_ANIMATION_RATE)
    quake._schedule(world, ticks)
    return quake
Ejemplo n.º 37
0
   def create_ore(world, name, pt, ticks, i_store):
       ore = entities.Ore(name, pt, image_store.get_images(i_store, 'ore'),
          random.randint(world.ORE_CORRUPT_MIN, world.ORE_CORRUPT_MAX))
       world.schedule_ore(world, ore, ticks, i_store)

       return ore
Ejemplo n.º 38
0
 def _create_ore(self, world, name, pt, ticks, i_store):
    ore = Ore(name, pt, image_store.get_images(i_store, 'ore'),
       random.randint(actions.ORE_CORRUPT_MIN, actions.ORE_CORRUPT_MAX))
    ore._schedule(world, ticks, i_store)
    return ore
Ejemplo n.º 39
0
 def create_quake(world, pt, ticks, i_store):
     quake = entities.Quake("quake", pt,
                            image_store.get_images(i_store, 'quake'),
                            QUAKE_ANIMATION_RATE)
     world.schedule_quake(world, quake, ticks)
     return quake
Ejemplo n.º 40
0
 def add_background(self, properties, i_store):
    if len(properties) >= BGND_NUM_PROPERTIES:
       pt = point.Point(int(properties[BGND_COL]), int(properties[BGND_ROW]))
       name = properties[BGND_NAME]
       self.set_background(pt,
          entities.Background(name, image_store.get_images(i_store,name)))