當前位置: 首頁>>代碼示例>>Python>>正文


Python Graphics.blit方法代碼示例

本文整理匯總了Python中graphics.Graphics.blit方法的典型用法代碼示例。如果您正苦於以下問題:Python Graphics.blit方法的具體用法?Python Graphics.blit怎麽用?Python Graphics.blit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在graphics.Graphics的用法示例。


在下文中一共展示了Graphics.blit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Actor

# 需要導入模塊: from graphics import Graphics [as 別名]
# 或者: from graphics.Graphics import blit [as 別名]
class Actor( object ):
  """
    Base Class for Actors. Actors are any objects with an onscreen representation.

    Actor class contains:
     model    : wireframe model representing the onscreen actor
     rectangle: bounding rectangle, projection of model on to the plane, used for intersection 
                and collision detection            
     texture  : image to texture the model
  """
  def __init__( self, model, texture=None, drawmode='polygon', offset=(0,0) ):
    """
      Initialize the actor
      INPUT:
            - model: unknown representation of this Actor's model, dependent on graphics system
            - texture: unknow representation of the texture to apply to this Actor's model
            - bounding_rect: rectangular projection of this actor's model onto the plane, used
                             for intersection and collision
            - gfx_sys: graphics system reference TODO: get rid of this
    """
    self._model = model #TODO assume array
    #self._boundrect = bounding_rect #TODO assume array
    self._texpath = texture #TODO assume path
    self._mode = drawmode
    self._gfxsys = Graphics()
    self._offset = offset
    if texture: 
      self._texid = self._gfxsys.texture_register( self._texpath )
    else:
      self._texid = None
    self._position = (0,0)
#=================================================================================================
  def draw( self, pos, name ):
    """
      Request that this object be drawn at pos
    """
    self._position = (pos[0]+self._offset[0],pos[1]+self._offset[1])
    #print self._position
    self._gfxsys.blit( self._model, self._position, name, self._texid, self._mode )
#=================================================================================================
  def updatepos( self, pos ):
    """
      update this actor's position outside of a draw call
    """
    self._position = pos
開發者ID:doggerelverse,項目名稱:gelly,代碼行數:47,代碼來源:actor.py


注:本文中的graphics.Graphics.blit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。