示例#1
0
 def inputDone(self):
   """Tries to load the Level. If it fails, a dummy level is created."""
   try:
     self.lvlarea.updateLevel(level.load(self.text, None))
     tinygui.popup("level %s loaded" % (self.text))
   except IOError:
     self.lvlarea.updateLevel(level.load(None, None))
     self.lvlarea.lvl.levelname = self.text
     tinygui.popup("new level %s" % (self.text))
示例#2
0
 def __init__(self, levelname):
   self.scroller = scroll.ScrollView(15, 30)
   self.lvl = level.load(levelname, self.scroller)
   self.rect = pygame.Rect(0, 0, self.scroller.w * 32, self.scroller.h * 32 + 32)
   self.lna = LevelNameArea(self)
   self.tsa = TileSetArea(self)
   self.cmd = CommandInputArea(self)
   self.children = [self.lna, self.tsa, self.cmd]
   self.displayGrid = True
   self.cursor = Cursor()
   self.mbdown = False
示例#3
0
文件: levelEdit.py 项目: sabren/blaze
    def __init__(self):
        State.__init__(self)
        if len(sys.argv) == 2:
            self.filename = sys.argv[1]
            self.level = level.load(self.filename)
        else:
            print 'usage: python %s <level>' % sys.argv[0]
            sys.exit()
        pygame.display.set_icon(data.icon)
        pygame.display.set_caption('Level Editor')
        self.bg = pygame.sprite.Group(self.level.s)

        self.buttons = pygame.sprite.Group()

        self.playerBtn = pygame.sprite.Sprite()
        self.playerBtn.image = data.Hero.button
        self.playerBtn.rect = self.playerBtn.image.get_rect()
        self.playerBtn.rect.topleft = (10,10)

        self.floorBtn = pygame.sprite.Sprite()
        self.floorBtn.image = self.level.tileset.floor
        self.floorBtn.rect = self.floorBtn.image.get_rect()
        self.floorBtn.rect.topleft = (10,self.playerBtn.rect.bottom+10)

        self.wallBtn = pygame.sprite.Sprite()
        self.wallBtn.image = self.level.tileset.wall
        self.wallBtn.rect = self.wallBtn.image.get_rect()
        self.wallBtn.rect.topleft = (10,self.floorBtn.rect.bottom+10)

        self.camBtn = pygame.sprite.Sprite()
        self.camBtn.image = data.Camera.still
        self.camBtn.rect = self.camBtn.image.get_rect()
        self.camBtn.rect.topleft = (10,self.wallBtn.rect.bottom+10)

        self.stairBtn = pygame.sprite.Sprite()
        self.stairBtn.image = self.level.tileset.stair
        self.stairBtn.rect = self.stairBtn.image.get_rect()
        self.stairBtn.rect.topleft = (10,self.camBtn.rect.bottom+10)

        self.enemyBtn = pygame.sprite.Sprite()
        self.enemyBtn.image = data.Enemy.button
        self.enemyBtn.rect = self.enemyBtn.image.get_rect()
        self.enemyBtn.rect.topleft = (10,self.stairBtn.rect.bottom+10)

        self.exitBtn = pygame.sprite.Sprite()
        self.exitBtn.image = self.level.tileset.exitDoor
        self.exitBtn.rect = self.exitBtn.image.get_rect()
        self.exitBtn.rect.topleft = (10,self.enemyBtn.rect.bottom+10)

        self.saveBtn = pygame.sprite.Sprite()
        self.saveBtn.image = font.render('Save',True,(255,255,255))
        self.saveBtn.rect = self.saveBtn.image.get_rect()
        self.saveBtn.rect.topleft = (10,self.exitBtn.rect.bottom+10)

        self.buttons.add(self.playerBtn,
                         self.floorBtn,
                         self.wallBtn,
                         self.camBtn,
                         self.stairBtn,
                         self.enemyBtn,
                         self.exitBtn,
                         self.saveBtn)

        self.keys = [0,0,0,0]
        self.selected = None
        self.cursor = None
        self.level.player.release()