Exemple #1
0
 def draw( self, pos = None ):
   """
     draw
   """
   vpos = Vertex()
   vpos.append( pos[0] )
   vpos.append( pos[1] )
   super(Tile,self).draw( vpos )#pos, (self.x,self.y) )
   for each in self.items:
     vpos[0]=vpos[0]+self._itemoffset[0]
     vpos[1]=vpos[1]+self._itemoffset[1]
     if not isinstance(each, Animactor):
       each.draw( vpos )#(pos[0],pos[1]),"object" )
     else:
       each.draw( vpos )
Exemple #2
0
 def __init__(self):
     """
 """
     self.sel = False
     self._image_file = "/home/lorin/projects/ge/art/planetcute/Selector.png"
     self._pos = Vertex()
     self._pos.append(-1.0)
     self._pos.append(-1.0)
     _model = Vertel()
     _model.set([(0.0, 0.0, 0.0), (0.0, 171.0 / 600.0, 0.0),
                 (101.0 / 800.0, 171.0 / 600.0, 0.0),
                 (101.0 / 800.0, 0.0, 0.0)])
     _bound = Vertel()
     _bound.set([(0.0, 0.0, 0.0), (0.0, 100.0 / 600, 0.0),
                 (100.0 / 800.0, 100.0 / 600, 0.0),
                 (100.0 / 800, 0.0, 0.0)])
     super(Selection, self).__init__(self._image_file, _model,
                                     _bound)  #, offset=(0,50))
Exemple #3
0
class Selection(Actor):
    """
  """
    def __init__(self):
        """
    """
        self.sel = False
        self._image_file = "/home/lorin/projects/ge/art/planetcute/Selector.png"
        self._pos = Vertex()
        self._pos.append(-1.0)
        self._pos.append(-1.0)
        _model = Vertel()
        _model.set([(0.0, 0.0, 0.0), (0.0, 171.0 / 600.0, 0.0),
                    (101.0 / 800.0, 171.0 / 600.0, 0.0),
                    (101.0 / 800.0, 0.0, 0.0)])
        _bound = Vertel()
        _bound.set([(0.0, 0.0, 0.0), (0.0, 100.0 / 600, 0.0),
                    (100.0 / 800.0, 100.0 / 600, 0.0),
                    (100.0 / 800, 0.0, 0.0)])
        super(Selection, self).__init__(self._image_file, _model,
                                        _bound)  #, offset=(0,50))

    #===============================================================================================
    def select(self, tile_actor):
        """
    """
        npos = tile_actor.getpos()
        self._pos[0] = npos[0] + tile_actor._itemoffset[0]
        self._pos[1] = npos[1] + tile_actor._itemoffset[1] + 0.02
        self.sel = tile_actor

    #===============================================================================================
    def draw(self):
        """
    """
        if self.sel:
            npos = self.sel.getpos()
            self._pos[0] = npos[0] + self.sel._itemoffset[0]
            self._pos[1] = npos[1] + self.sel._itemoffset[1] + 0.02
            super(Selection, self).draw(self._pos)
Exemple #4
0
class Selection( Actor ):
  """
  """
  def __init__(self):
    """
    """
    self.sel = False
    self._image_file = "/home/lorin/projects/ge/art/planetcute/Selector.png"
    self._pos = Vertex()
    self._pos.append( -1.0 )
    self._pos.append( -1.0 )
    _model = Vertel()
    _model.set( [ ( 0.0, 0.0, 0.0 ), 
                  ( 0.0, 171.0/600.0, 0.0 ), 
                  ( 101.0/800.0, 171.0/600.0,0.0 ),
                  ( 101.0/800.0 , 0.0, 0.0 ) ] )
    _bound = Vertel()
    _bound.set( [ ( 0.0, 0.0, 0.0 ),
                  ( 0.0, 100.0/600, 0.0 ),
                  ( 100.0/800.0, 100.0/600, 0.0 ),
                  ( 100.0/800, 0.0, 0.0 ) ] )
    super( Selection, self ).__init__( self._image_file, _model, _bound )#, offset=(0,50))
  #===============================================================================================
  def select(self, tile_actor ):
    """
    """
    npos = tile_actor.getpos()
    self._pos[0] = npos[0]+tile_actor._itemoffset[0]
    self._pos[1] = npos[1]+tile_actor._itemoffset[1]+0.02
    self.sel = tile_actor
  #===============================================================================================
  def draw(self):
    """
    """
    if self.sel:
      npos = self.sel.getpos()
      self._pos[0] = npos[0]+self.sel._itemoffset[0]
      self._pos[1] = npos[1]+self.sel._itemoffset[1]+0.02
      super(Selection,self).draw(self._pos)
Exemple #5
0
  def __init__(self, x, y, tilecode ):
    """
    """
    self._tilecode = tilecode
    self.tile_size = (100,82) #magic, depends on tile set
    # dict of tile type to image path mappings, will eventually be part of DB
    self.tiletypes = { '#' : "/home/lorin/projects/ge/art/planetcute/Stone Block.png",
                       '.' : "/home/lorin/projects/ge/art/planetcute/Stone Block.png",
                       'e' : "/home/lorin/projects/ge/art/planetcute/Wood Block.png",
                       'x' : "/home/lorin/projects/ge/art/planetcute/Wood Block.png"}

    self._itemoffset = Vertex()
    self._itemoffset.append (0.0)
    self._itemoffset.append (0.0)
    self._itemoffset[1] = 0.054
#    super(Tile,self).__init__( model   = [ (0,0), (0,181), (100,181), (100,0) ],
#                               texture = self.tiletypes[tilecode],
#                               x = 100,
#                               y = 85,
#                               boundoffset = (0,44) )
    _model = Vertel()
    _model.set( [ ( 0.0, 0.0, 0.0 ), 
                  ( 0.0, 171.0/600.0, 0.0 ), 
                  ( 101.0/800.0, 171.0/600.0,0.0 ),
                  ( 101.0/800.0 , 0.0, 0.0 ) ] )
    _bound = Vertel() 
    _bound.set( [ ( 0.0, 0.0, 0.0 ),
                  ( 0.0, 100.0/600.0, 0.0 ),
                  ( 100.0/800.0, 100.0/600, 0.0 ),
                  ( 100.0/800, 0.0, 0.0 ) ] )
    super(Tile,self).__init__( self.tiletypes[tilecode], _model, _bound )


    self.x = x
    self.y = y
    self.items = list()
    self.full = False
Exemple #6
0
 def __init__(self):
   """
   """
   self.sel = False
   self._image_file = "/home/lorin/projects/ge/art/planetcute/Selector.png"
   self._pos = Vertex()
   self._pos.append( -1.0 )
   self._pos.append( -1.0 )
   _model = Vertel()
   _model.set( [ ( 0.0, 0.0, 0.0 ), 
                 ( 0.0, 171.0/600.0, 0.0 ), 
                 ( 101.0/800.0, 171.0/600.0,0.0 ),
                 ( 101.0/800.0 , 0.0, 0.0 ) ] )
   _bound = Vertel()
   _bound.set( [ ( 0.0, 0.0, 0.0 ),
                 ( 0.0, 100.0/600, 0.0 ),
                 ( 100.0/800.0, 100.0/600, 0.0 ),
                 ( 100.0/800, 0.0, 0.0 ) ] )
   super( Selection, self ).__init__( self._image_file, _model, _bound )#, offset=(0,50))
Exemple #7
0
class Tile( Actor ):
  """
  """
  def __init__(self, x, y, tilecode ):
    """
    """
    self._tilecode = tilecode
    self.tile_size = (100,82) #magic, depends on tile set
    # dict of tile type to image path mappings, will eventually be part of DB
    self.tiletypes = { '#' : "/home/lorin/projects/ge/art/planetcute/Stone Block.png",
                       '.' : "/home/lorin/projects/ge/art/planetcute/Stone Block.png",
                       'e' : "/home/lorin/projects/ge/art/planetcute/Wood Block.png",
                       'x' : "/home/lorin/projects/ge/art/planetcute/Wood Block.png"}

    self._itemoffset = Vertex()
    self._itemoffset.append (0.0)
    self._itemoffset.append (0.0)
    self._itemoffset[1] = 0.054
#    super(Tile,self).__init__( model   = [ (0,0), (0,181), (100,181), (100,0) ],
#                               texture = self.tiletypes[tilecode],
#                               x = 100,
#                               y = 85,
#                               boundoffset = (0,44) )
    _model = Vertel()
    _model.set( [ ( 0.0, 0.0, 0.0 ), 
                  ( 0.0, 171.0/600.0, 0.0 ), 
                  ( 101.0/800.0, 171.0/600.0,0.0 ),
                  ( 101.0/800.0 , 0.0, 0.0 ) ] )
    _bound = Vertel() 
    _bound.set( [ ( 0.0, 0.0, 0.0 ),
                  ( 0.0, 100.0/600.0, 0.0 ),
                  ( 100.0/800.0, 100.0/600, 0.0 ),
                  ( 100.0/800, 0.0, 0.0 ) ] )
    super(Tile,self).__init__( self.tiletypes[tilecode], _model, _bound )


    self.x = x
    self.y = y
    self.items = list()
    self.full = False

  def loc(self):
    return tuple([self.x,self.y])
  
  def draw( self, pos = None ):
    """
      draw
    """
    vpos = Vertex()
    vpos.append( pos[0] )
    vpos.append( pos[1] )
    super(Tile,self).draw( vpos )#pos, (self.x,self.y) )
    for each in self.items:
      vpos[0]=vpos[0]+self._itemoffset[0]
      vpos[1]=vpos[1]+self._itemoffset[1]
      if not isinstance(each, Animactor):
        each.draw( vpos )#(pos[0],pos[1]),"object" )
      else:
        each.draw( vpos )

  def place_item( self, item ):
    """
      place an object on the tile
    """
    self.items.append( item )

  def remove_item( self, item ):
    """
    """
    self.items.remove( item )#TODO try

  def pop(self):
    """
    """
    self.items.pop()

  def __str__(self):
    """
      debug function, prints class data to console
    """
    str0 =  "Tile Object: %(pos)s \n" % {'pos': tuple([self.x,self.y]),}
    for each in self.items:
      str1 = each.__str__()
      str0 = str0+str1+'\n'
    return str0

  def setWall(self, full):
    """
    """
    self.full = full

  def isWall(self):
    return False
  def isOccupied(self):
    return True