本文整理汇总了Python中Engine.create_block方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.create_block方法的具体用法?Python Engine.create_block怎么用?Python Engine.create_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.create_block方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: redraw
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import create_block [as 别名]
def redraw(self, screen, drawselected=True):
if not self.visible:return
#Draw inventory background
screen.blit(self.image, (self.invpos[0]-\
self.imgoffset[0]+self.invsoffset[0], \
self.invpos[1]-self.imgoffset[1]+self.invsoffset[1]))
xx=0 #current slot
#Skip draw when there no inventory
if not self.inventory:return
for item in self.inventory.slots:
if item!=None:
img=self.imgloader.loadimage(item[0])
nx=(xx%self.invsize[0])*self.ts+self.getinvpos()[0]
ny=(xx/self.invsize[0])*self.ts+self.getinvpos()[1]
screen.blit(img, (nx, ny))
#Draw count
txt=self.font.render(str(item[1]), 1, (255, 255, 0))
screen.blit(txt, (nx, ny))
#Draw selection
if xx==self.selected and drawselected:
pygame.draw.rect(screen, (255, 255, 0), \
(nx-1, ny-1, self.ts-2, self.ts-2), 1)
drawselected=False
#increase index
xx+=1
#Draw tooltip
if self.lastslot!=None:
slot=self.inventory.getslot(self.lastslot)
if slot!=None:
mx, my=pygame.mouse.get_pos()
block=Engine.create_block(slot[0]) # create temp block
#Draw tooltip background
#pygame.draw.rect(screen, (64, 64, 64), \
# (mx, my, 128, 32), 0)
#Draw item name
color=(200, 200, 200)
img=self.font.render(str(block.name), 1, color, (64, 64, 64))
px,py=mx+(64-img.get_size()[0]/2),my
screen.blit(img, (px, py))