コード例 #1
0
    def update(self, dt):
        """Update the building template.

        This method just applies the current position of the entity to the
        renderable transform.

        :param dt: Time delta from last update.
        :type dt: float
        """
        x, y = self.pos

        m_x, m_y = to_matrix(x, y, self.scale_factor)
        if not in_matrix(self.matrix, m_x, m_y) or not self.matrix[m_y][m_x]:
            self.props.material.color = self.NON_BUILDABLE_COLOR
        else:
            self.props.material.color = self.BUILDABLE_COLOR

        self.obj.position = to_scene(x, y)
        self.obj.scale = Vec(1.05, 1.05, 1.05)
コード例 #2
0
    def update(self, dt):
        """Update the building template.

        This method just applies the current position of the entity to the
        renderable transform.

        :param dt: Time delta from last update.
        :type dt: float
        """
        x, y = self.pos

        m_x, m_y = to_matrix(x, y, self.scale_factor)
        if not in_matrix(self.matrix, m_x, m_y) or not self.matrix[m_y][m_x]:
            self[Renderable].node.params.update(self.NON_BUILDABLE_COLOR)
        else:
            self[Renderable].node.params.update(self.BUILDABLE_COLOR)

        t = self[Renderable].transform
        t.identity()
        t.translate(to_scene(x, y))
        t.scale(Vec(1.05, 1.05, 1.05))
コード例 #3
0
def set_cell_walkable(evt):
    """Set a cell as walkable in the debug terrain."""
    context = evt.context
    x, y = to_matrix(evt.pos[0], evt.pos[1], context.scale_factor)
    if in_matrix(context.matrix, x, y):
        context.matrix[y][x] = True
コード例 #4
0
def set_cell_walkable(evt):
    """Set a cell as walkable in the debug terrain."""
    context = evt.context
    x, y = to_matrix(evt.pos[0], evt.pos[1], context.scale_factor)
    if in_matrix(context.matrix, x, y):
        context.matrix[y][x] = True