Beispiel #1
0
 def init(cls):
   GameRegistry.registerBlock(cls,cls.unlocalisedName)
   Block.registerTexture(cls.unlocalisedName)
   for i in range(3):
     path=os.path.join("animation",cls.unlocalisedName,"{}.png".format(i))
     img=pygame.image.load(path)
     cls.frames.append(img)
Beispiel #2
0
def make_block(klass_name,name,clear=False,drops=False):
  def blk_init():
    pass
  def init(self,x,y,screen):
    Block.__init__(self,x,y,screen)
    self.setTextureName(name)
    self.clear=clear
    self.drops=drops
    self.unlocalisedName=name
  attr_table={
    "unlocalisedName":name,
    "__init__":init,
    "init":blk_init,
  }
  klass=type(klass_name,(Block,),attr_table)
  GameRegistry.registerBlock(klass,name)
  Block.registerTexture(name)
  glob=globals()
  glob[klass_name]=klass
  global dy_blocks
  dy_blocks[klass_name]=name
  return klass
Beispiel #3
0
 def init(cls):
   GameRegistry.registerBlock(cls,cls.unlocalisedName)
   Block.registerTexture(cls.unlocalisedName)
Beispiel #4
0
                 send_str(sock, str(x))
                 send_str(sock, str(y))
         if event.key == pygame.K_j:
             player.inv.selPrev()
         if event.key == pygame.K_k:
             player.inv.clearSel()
         if event.key == pygame.K_l:
             player.inv.selNext()
         if event.key == pygame.K_e:
             inv = not inv
         if event.key == pygame.K_i:
             dy_blocks = blocks.dy_blocks
             Block.textures = {}
             Block.init()
             for klass, unName in dy_blocks.items():
                 Block.registerTexture(unName)
         elif event.key in key_to_dir.keys():
             move = True
             dir = key_to_dir[event.key]
     elif event.type == pygame.KEYUP:
         move = False
         player.frame = 1
 if move:
     player.move(dir)
     send_str(sock, "SET_POS_FOR_UID")
     send_str(sock, str(my_uid))
     send_str(sock, str(player.x))
     send_str(sock, str(player.y))
     send_str(sock, player.dir)
 if inv:
     screen.fill([255, 255, 255])