当前位置: 首页>>代码示例>>Python>>正文


Python instructions.InstructionGroup类代码示例

本文整理汇总了Python中kivy.graphics.instructions.InstructionGroup的典型用法代码示例。如果您正苦于以下问题:Python InstructionGroup类的具体用法?Python InstructionGroup怎么用?Python InstructionGroup使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了InstructionGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, target, following):
        super(EntityFollow, self).__init__(target)
        self.following = following
        self.cells = []
        self.moving = False
        self.instructions = InstructionGroup()
        targeted = self.target.map.layers.by_name['below'].get_at(*self.following.pos)
        # targeted = self.target.map.layers.by_name['below'].get_neighbor_cells(following_cell)[0]
        origin_cell = self.target.map.layers.by_name['below'].get_at(*self.target.pos)

        if targeted is not None and targeted.tile.is_passable():
            cells = targeted.layer.a_star_search(origin_cell, targeted)
            # if there's only two cells selected, and goal is not origin neighbor... then run away, RUN AWAY!
            if len(cells) == 2 and targeted not in self.target.map.layers.by_name['below'].get_neighbor_cells(origin_cell):
                return
            if len(cells) > 1:
                cells.reverse()
                # self.instructions.clear()
                self.instructions = InstructionGroup()
                # self.highlight_tiles(cells)
                self.cells = cells
                self.moving = False
        if not self.cells:
            print('no cells here dawg')
            self.target.state = EntityIdle(self.target)
            self.end()
            return
        # self.highlight_tiles(self.cells)
        self.foreshadowed = None
        self.velocity = [0, 0]
        self.target.anim_delay = .2
        self.task = Clock.schedule_interval(self.slow_update, .6)
开发者ID:spinningD20,项目名称:kivy_rpg,代码行数:32,代码来源:realtime.py

示例2: __init__

    def __init__(self, *args, **kwargs):
        super(LevelProgressBar, self).__init__(*args, **kwargs)

        texture = Texture.create(size=(1, 16))

        size = 1 * 16 * 3

        buf = [
            int(Color(
                .66 - (float(data) / size) * .66,
                .75,
                .75,
                mode='hsv'
            ).rgb[data % 3] * 255) for data in range(size)
        ]

        buf = b''.join(map(chr, buf))

        texture.blit_buffer(buf, colorfmt='rgb', bufferfmt='ubyte')

        self.progress_bar = Rectangle(texture=texture)
        self.progress_mask = Rectangle()

        group = InstructionGroup()
        group.add(Color(0, 0, 0))
        group.add(self.progress_mask)

        self.canvas.add(Color(1, 1, 1))
        self.canvas.add(self.progress_bar)
        self.canvas.add(group)

        self.bind(pos=self.redraw, size=self.redraw)
开发者ID:Cheaterman,项目名称:TetrimusBase,代码行数:32,代码来源:levelprogressbar.py

示例3: add_explosion

    def add_explosion(self, line):
        line += self.currently_exploding
        self.currently_exploding += 1

        explosion = InstructionGroup()
        color = Color(1, 1, .5, .8)

        explosion.add(color)

        explosion.add(Rectangle(
            pos=self.coord_to_pos(0, line),
            size=(
                self.tile_size()[0] * self.cols,
                self.tile_size()[1]
            )
        ))

        self.canvas.add(explosion)

        def remove(self):
            self.canvas.remove(explosion)
            self.currently_exploding -= 1

        anim = Animation(
            a=0,
            duration=.125
        )
        anim.bind(on_complete=lambda *args: remove(self))
        anim.start(color)
开发者ID:Cheaterman,项目名称:TetrimusBase,代码行数:29,代码来源:tetrisarea.py

示例4: Renderer

class Renderer(Widget):

    def __init__(self, **kw):
        self.shader_file = kw.pop("shader_file", None)
        self.canvas = Canvas()
        super(Renderer, self).__init__(**kw)

        with self.canvas:
            self._viewport = Rectangle(size=self.size, pos=self.pos)
            self.fbo = Fbo(size=self.size,
                           with_depthbuffer=True, compute_normal_mat=True)
        self._config_fbo()
        self.texture = self.fbo.texture
        self.camera = None
        self.scene = None

    def _config_fbo(self):
        # set shader file here
        self.fbo.shader.source = self.shader_file or \
                                os.path.join(kivy3_path, "default.glsl")
        with self.fbo:
            Callback(self._setup_gl_context)
            PushMatrix()
            # instructions set for all instructions
            self._instructions = InstructionGroup()
            PopMatrix()
            Callback(self._reset_gl_context)

    def _setup_gl_context(self, *args):
        glEnable(GL_DEPTH_TEST)
        self.fbo.clear_buffer()

    def _reset_gl_context(self, *args):
        glDisable(GL_DEPTH_TEST)

    def render(self, scene, camera):
        self.scene = scene
        self.camera = camera
        self.camera.bind_to(self)
        self._instructions.add(scene.as_instructions())
        Clock.schedule_once(self._update_matrices, -1)

    def on_size(self, instance, value):
        self.fbo.size = value
        self._viewport.texture = self.fbo.texture
        self._viewport.size = value
        self._update_matrices()

    def on_texture(self, instance, value):
        self._viewport.texture = value

    def _update_matrices(self, dt=None):
        if self.camera:
            self.fbo['projection_mat'] = self.camera.projection_matrix
            self.fbo['modelview_mat'] = self.camera.modelview_matrix
        else:
            raise RendererError("Camera is not defined for renderer")

    def set_clear_color(self, color):
        self.fbo.clear_color = color
开发者ID:inclement,项目名称:kivy3,代码行数:60,代码来源:renderer.py

示例5: put_pixel

def put_pixel(x, y, color, canvas, token, alpha=None, thickness=2):
    r, g, b = color.r, color.g, color.b
    c = Color(r, g, b)
    if alpha:
        c.a = alpha
    group = InstructionGroup(group=token)
    group.add(c)
    group.add(Rectangle(pos=(x, y), size=(thickness, thickness)))

    canvas.add(group)
开发者ID:kujbol,项目名称:graficzne,代码行数:10,代码来源:basics.py

示例6: get_graphics

 def get_graphics(self, gc, polygons, points_line, rgbFace, closed=False):
     '''Return an instruction group which contains the necessary graphics
        instructions to draw the respective graphics.
     '''
     instruction_group = InstructionGroup()
     if isinstance(gc.line['dash_list'], tuple):
         gc.line['dash_list'] = list(gc.line['dash_list'])
     if rgbFace is not None:
         if len(polygons.meshes) != 0:
             instruction_group.add(Color(*rgbFace))
             for vertices, indices in polygons.meshes:
                 instruction_group.add(Mesh(
                     vertices=vertices,
                     indices=indices,
                     mode=str("triangle_fan")
                 ))
     instruction_group.add(Color(*gc.get_rgb()))
     if _mpl_1_5 and closed:
         points_poly_line = points_line[:-2]
     else:
         points_poly_line = points_line
     if gc.line['width'] > 0:
         instruction_group.add(Line(points=points_poly_line,
             width=int(gc.line['width'] / 2),
             dash_length=gc.line['dash_length'],
             dash_offset=gc.line['dash_offset'],
             dash_joint=gc.line['joint_style'],
             dash_list=gc.line['dash_list']))
     return instruction_group
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:29,代码来源:backend_kivy.py

示例7: __init__

    def __init__(self, body, size, texture=None, halfShift=True):

        ig = InstructionGroup()
        ig.add(Color(1,1,1, 1.0))
        ig.add(Rectangle(pos=(0,0), size=size, texture=texture))

        offset = None
        if halfShift:
            offset = [-1.0*s/2.0 for s in size]

        super(TextrueRect, self).__init__(body, instruction=ig, offset=offset)
开发者ID:DerThorsten,项目名称:kivy_dev,代码行数:11,代码来源:body_render_instructions.py

示例8: PaintAreaBackgroundWidget

class PaintAreaBackgroundWidget(RelativeLayout):

    selectedColor = ListProperty([1,0,0,1])

    def __init__(self, *args, **kwargs):
        super(PaintAreaBackgroundWidget, self).__init__(*args, **kwargs)

        self.lineGroup = None
        self.line = None
        self.isDrawing = False

    def on_touch_down(self, touch):

        # only draw if no widget is selected 
        if self.paintWidget.selectedItem is None:

            if self.collide_point(*touch.pos):

                self.isDrawing = True

                width = self.lineWidth
                self.lineGroup = InstructionGroup()
                #print self.lineGroup
                self.line = Line(points=(touch.x, touch.y),width=width,dash_offset=2)
                self.lineGroup.add(Color(*self.selectedColor))
                self.lineGroup.add(self.line)
                self.canvas.add(self.lineGroup)

    def on_touch_move(self, touch):
        if self.paintWidget.selectedItem is None:
            if self.collide_point(*touch.pos):
                self.line.points += [touch.x, touch.y]

    def on_touch_up(self, touch):
        if self.paintWidget.selectedItem is None:
            if self.collide_point(*touch.pos) and len(self.line.points)>1:
                    

                self.canvas.remove(self.lineGroup)

                lp = numpy.array(self.line.points)
                scatterPolyLine = ScatterPolyLineWidget(paintWidget=self.paintWidget,
                    linePoints=lp, lineWidth=self.lineWidth, lineColor=self.selectedColor)


                self.line.points = []
        
                scatterPolyLine.pos =  [scatterPolyLine.minX,
                                        scatterPolyLine.minY]
                #.size = polyLineWidget.size
                self.addPaintedThingsWidget.add_widget(scatterPolyLine)
                #self.addedOne = True
            self.isDrawing = False
开发者ID:DerThorsten,项目名称:kivy_dev,代码行数:53,代码来源:main.py

示例9: clear

 def clear(self):
     """Reset the entire letter grid, eliminating all letter boxes."""
     self._labels = dict()
    
     self.canvas.clear()
     self.canvas.add(Color(0,0,0,1))
     self.canvas.add(Rectangle(pos=self.pos,size=self.size))
     
     self._back  = InstructionGroup()
     self._front = InstructionGroup()
     self.canvas.add(self._back)
     self.canvas.add(self._front)
开发者ID:michellehn,项目名称:wordpuzzle-solver,代码行数:12,代码来源:lettergui.py

示例10: __init__

    def __init__(self, player1, player2, **kwargs):
        self.canvas = InstructionGroup()

        self.beamColor = Color(0.0, 0.0, 0.0, 1.0)
        self.beamGroup = InstructionGroup()
        self.beamThickness = 40
        self.canvas.add(self.beamGroup)

        self.player1 = player1
        self.player2 = player2

        self.beamState = 0
        self.isColliding = False
开发者ID:adparadise,项目名称:pmgj6-harvesters,代码行数:13,代码来源:beam.py

示例11: __init__

 def __init__(self, target, **kwargs):
     super(SelectAttackState, self).__init__(target, **kwargs)
     self.amount = self.target.map.tile_width
     self.moving = False
     self.velocity = [0, 0]
     self.layer = self.target.map.layers.by_name['below']
     self.foreshadowed = self.layer.get_at(*target.center)
     self.move_keys = [Keyboard.keycodes['left'], Keyboard.keycodes['right'],
                       Keyboard.keycodes['up'], Keyboard.keycodes['down'], Keyboard.keycodes['enter']]
     self.travelled = set()
     self.checked = set()
     self.index = {}
     self.instructions = InstructionGroup()
     self.layer = self.target.map.layers.by_name['below']
     self.confirmed = False
     self.effect = MeleeDamage
     tile = self.layer.get_at(*self.target.pos)
     self.cursor = Sprite(pos=[tile.px, tile.py],
                          size=self.target.size, texture=images['cursor'], opacity=0.5)
     self.current_tile = self.target.get_current_cell()
     self.target.game.layer_widgets['sprite_layer'].add_widget(self.cursor)
     self.get_tiles_in_range(tile, 0)
     self.selected = None
     self.last_touched = None
     self.highlight_tiles()
开发者ID:spinningD20,项目名称:kivy_rpg,代码行数:25,代码来源:turn.py

示例12: __init__

    def __init__(self, enemyType, **kwargs):
        self.canvas = InstructionGroup()

        self.enemyType = enemyType
        self.sprite = Sprite()

        if self.enemyType == 'normal':
            self.setOffsetTheta(0)
            self.sprite.color.r = 0.0
            self.sprite.color.g = 0.2
            self.sprite.color.b = 0.5
        else:
            self.setOffsetTheta(math.pi / 2)
            self.sprite.color.r = 0.5
            self.sprite.color.g = 0.1
            self.sprite.color.b = 0.1

        self.health = 100

        self.pos = (0, 0)
        self.velocity = [0, 0]

        self.updateAppearance()

        self.canvas.add(self.sprite.canvas)

        self.shouldRemove = False
开发者ID:adparadise,项目名称:pmgj6-harvesters,代码行数:27,代码来源:enemy.py

示例13: __init__

    def __init__(self, playerCode, **kwargs):
        self.canvas = InstructionGroup()

        self.sprite = Sprite()

        self.playerCode = playerCode
        self.frameNum = 0

        self.bottomLeft = (0, 0)
        self.topRight = (700, 500)
        self.pos = (0, 0)

        self.direction = (0, 0)
        self.speed = 0
        self.targetDirection = (0, 0)
        self.targetSpeed = 0
        self.isTweeningDirection = False
        self.isTweeningSpeed = False
        self.newDirectionSince = 0
        self.newSpeedSince = 0
        self.directionChange = (0, 0)

        if playerCode == 'p2':
        	self.sprite.color.r = 1

        if playerCode == 'enemy1':
        	self.sprite.color.b = 1

        self.canvas.add(self.sprite.canvas)
开发者ID:adparadise,项目名称:pmgj6-harvesters,代码行数:29,代码来源:player.py

示例14: __init__

 def __init__(self, **kw):
     """**Constructor**: Create a new letter box
     
         :param keywords: dictionary of keyword arguments 
         **Precondition**: See below.
     
     To use the constructor for this class, you should provide
     it with a list of keyword arguments that initialize various
     attributes.  For example, to initialize a 2x3 grid, use
     the constructor call
     
         GObject(rows=2,cols=3)
     
     You do not need to provide the keywords as a dictionary.
     The ** in the parameter `keywords` does that automatically.
     
     Any attribute of this class may be used as a keyword.  The
     argument must satisfy the invariants of that attribute.  See
     the list of attributes of this class for more information."""
     Widget.__init__(self,**kw)
     self._resized = True
     self._labels = dict()
     self._set_properties(kw)
     self.bind(pos=self._reposition)
     
     # Create a layer for proper state control.
     self._back  = InstructionGroup()
     self._front = InstructionGroup()
     self.canvas.add(self._back)
     self.canvas.add(self._front)
     
     # Bind kivy attributes to methods
     self.bind(size=self._resize)
     self.bind(cols=self._resize)
     self.bind(rows=self._resize)
     self.bind(border=self._set_border)
     self.bind(font_size=self._set_font_size)
     self.bind(bold=self._set_bold)
     self.bind(italic=self._set_italic)
     self.bind(foreground=self._set_foreground)
     self.bind(background=self._set_background)
     self.bind(textcolor=self._set_textcolor)
开发者ID:michellehn,项目名称:wordpuzzle-solver,代码行数:42,代码来源:lettergui.py

示例15: _config_fbo

 def _config_fbo(self):
     # set shader file here
     self.fbo.shader.source = self.shader_file or \
                             os.path.join(kivy3_path, "default.glsl")
     with self.fbo:
         Callback(self._setup_gl_context)
         PushMatrix()
         # instructions set for all instructions
         self._instructions = InstructionGroup()
         PopMatrix()
         Callback(self._reset_gl_context)
开发者ID:3demax,项目名称:kivy3,代码行数:11,代码来源:renderer.py


注:本文中的kivy.graphics.instructions.InstructionGroup类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。