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


Python Level.Level类代码示例

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


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

示例1: __init__

    def __init__(self, player, active_sprite_list):
        """ Create level 1. """

        # Call the parent constructor
        Level.__init__(self, player, self._BACKGROUND_IMAGE)
        self.show_text(self._INTRO_TEXT)
        self.active_sprite_list = active_sprite_list

        self.level_limit = -1000

        # Array with type of platform, and x, y location of the platform.
        level = [
            [210, 30, 450, 500],
            [210, 30, 850, 500],
            [210, 30, 1000, 500],
        ]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform()
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            self.platform_list.add(block)

        toots = Toots(player, self.active_sprite_list)
        toots.level = self
        toots.rect.x = 1000
        toots.rect.y = SCREEN_HEIGHT + 100
        self.enemy_list = pygame.sprite.Group()
        self.enemy_list.add(toots)
开发者ID:jdubinsky,项目名称:pug_adventure,代码行数:31,代码来源:Level05.py

示例2: __init__

	def __init__(self, director, player):
		Level.__init__(self, director, player)
		self.player.rect.x = 766
		self.player.rect.y = 82

		self.enemyGroup.add([Nazist(640, 140, self.player, director),
# 							Nazist(640, 176, self.player, director),
# 							Nazist(688, 18, self.player, director),
							Nazist(524, 51, self.player, director),
# 							Nazist(524, 140, self.player, director),
							Nazist(345, 46, self.player, director),
							Nazist(345, 70, self.player, director),
# 							Nazist(345, 100, self.player, director),
							Nazist(140, 145, self.player, director),
							Nazist(140, 175, self.player, director),
							Nazist(185, 10, self.player, director),
							Mr_H(27, 48, self.player, director)])


		self.bg = load_image("mapa_h.png", Constants.MAP_DIR)
		self.collisionBg = load_image("mapa_h_bg.png", Constants.BG_MAP_DIR)

		load_music("level_three.xm")
		pygame.mixer.music.set_volume(0.25)
		pygame.mixer.music.play(-1)

		player.setWeapons([WpnGrenade(), WpnRifle()])
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:27,代码来源:LevelThree.py

示例3: __init__

    def __init__(self, player):
        """ Create level 1. """

        # Call the parent constructor
        Level.__init__(self, player, self._BACKGROUND_IMAGE)

        self.player = player
        self.show_text(self._INTRO_TEXT)
        self.level_limit = -1000

        # Array with width, height, x, and y of platform
        level = [[210, 70, 500, 500],
                 [210, 70, 800, 400],
                 [210, 70, 1000, 500],
                 [210, 70, 1120, 280],
                 ]

        # Go through the array above and add platforms
        for platform in level:
            block = Platform()
            block.rect.x = platform[2]
            block.rect.y = platform[3]
            block.player = self.player
            self.platform_list.add(block)

        self.enemy_list = pygame.sprite.Group()
        self.make_n_random_enemies(2)
开发者ID:jdubinsky,项目名称:pug_adventure,代码行数:27,代码来源:Level01.py

示例4: __init__

    def __init__(self, width, height):
        Level.__init__(self, width, height)
        ##initialize blocks##
        boxtop = Terrain(20, -19, 40, 2, 0, 0,100, self, 0.5)
        boxleft= Terrain(-1,-5,2,30,0,0,100,self,0.5)
        boxbottom= Terrain(27.0,9.0,54.0,2.0,0.0,0.0,100,self,0.5)
        boxright= Terrain(55,-5,2,30,0,0,100,self,0.5)

        goal= Goal(53,5,1,5,0,0,100,self,0.5)
        
        
        b =   Block(2, 2,  4, 1, 0, 0,  1, self, 0.5)
        c =  Player(7, 5,  1, 2, 0, 0,  1, self, 0.5)
        d =   Block(4, 2, 4, 1, 0, 5,  2, self, 0.5)  
        a =   GoalBlock(4, 5, 2, 2, 0, 5,  2, self, 0.5) 
        m = Trampoline(30, -4, 2, 1, 0, 0, 1, self, 0.5)
        e = Spike(30.0, 7.5, 41.0, 1.0, 0.0, 0.0, 100, self, 0.1)
        f = Spike(29.0, 6.5, 1.0, 1.0, 0.0, 0.0, 100, self, 0.1)
        self.add_elem(c)
        self.add_elem(m)
        self.add_elem(b)
        self.add_elem(a)
        self.add_elem(d)
        self.add_elem(e)
        self.add_elem(f)
        self.add_elem(boxtop)
        self.add_elem(boxright)
        self.add_elem(boxbottom)
        self.add_elem(boxleft)
        self.add_elem(goal)
开发者ID:Peterfly,项目名称:Physformer,代码行数:30,代码来源:Level1.py

示例5: __init__

    def __init__(self, director, player):
        Level.__init__(self, director, player)
        self.player.rect.x = 782
        self.player.rect.y = 912
        self.dead_sub_boss = 0      #Counts the dead Centurions.
        self.enemyGroup.add([Legionnaire(987, 768, self.player, director),
                             Legionnaire(1083, 768, self.player, director),
                             Legionnaire(1119, 768, self.player, director),
                             Legionnaire(987, 834, self.player, director),
                             Legionnaire(477, 747, self.player, director),
                             Legionnaire(645, 738, self.player, director),
                             Legionnaire(477, 891, self.player, director),
                             Legionnaire(645, 788, self.player, director),
                             Centurion(150, 288, self.player, director),
                             Centurion(1455, 288, self.player, director),
                             Centurion(1329, 1248, self.player, director)]) 

        self.door = Door(760, 575, 'door_sheet.png', -1, 'coordDoor.txt', [2], 'door_open.wav')     
        self.doorGroup = EntityGroup([])
        self.doorGroup.add(self.door)
        self.groups.append(self.doorGroup)

        self.bg = load_image("map_caesar_a_img.png", Constants.MAP_DIR)
        self.collisionBg = load_image(
            "map_caesar_a_bg.png", Constants.BG_MAP_DIR)

        load_music("level_one.it")
        pygame.mixer.music.set_volume(1)
        pygame.mixer.music.play(-1)

        player.setWeapons([WpnBlade("wpns2.png", -1, pygame.Rect(344, 342, 28, 28), "blade_swing.wav", 0.5), \
                          WpnBow("items-1.png", None, pygame.Rect(0, 24, 24, 24))])
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:32,代码来源:LevelOneA.py

示例6: __init__

 def __init__(self, width, height):
     Level.__init__(self, width, height)
     ##initialize blocks##
     boxtop = Terrain(20, -19, 40, 2, 0, 0,100, self, 0.5)
     boxleft= Terrain(-1,-5,2,30,0,0,100,self,0.5)
     boxbottom= Terrain(20,9,40,2,0,0,100,self,0.5)
     boxright= Terrain(41,-5,2,30,0,0,100,self,0.5)
     barrbottom = Terrain(15,-6,6,1,0,0,100,self,.5)
     barrright = Terrain(18.5,-11,1,10,0,0,100,self,.5)
     
     goal= Goal(38,-15.5,1,5,0,0,100,self,0.5)
     
     tramp1= Trampoline(7,7,6,1,0,0,100,self,.5)
     tramp2= Trampoline(36,7,6,1,0,0,100,self,.5)
     tramp3= Trampoline(32,-8,6,1,0,0,100,self,.5)
     tramp4= Trampoline(36,-23,6,1,0,0,100,self,.5)
     p =  Player(2, 5,  1, 2, 0, 0,  1, self, 0.5) 
     g =   GoalBlock(16.5, -7, 2, 2, 0, 0,  2, self, 0.5)
     self.add_elem(p)
     self.add_elem(barrbottom)
     self.add_elem(barrright)
     self.add_elem(tramp1)
     self.add_elem(tramp2)
     self.add_elem(tramp3)
     self.add_elem(tramp4)
     self.add_elem(g)
     self.add_elem(boxtop)
     self.add_elem(boxright)
     self.add_elem(boxbottom)
     self.add_elem(boxleft)
     self.add_elem(goal)
开发者ID:Peterfly,项目名称:Physformer,代码行数:31,代码来源:LevelReal.py

示例7: processEvent

    def processEvent(self, event):
        if event.type == pygame.USEREVENT and event.code == PAGEDEAD:
            m = MessageScene(self.director, self, 'Congratulations', "You have completed the game!\nNow you're entitled \nto the 3D version.", "Press to quit")
            m.messageBox.button.onMouseDown = lambda: pygame.event.post(pygame.event.Event(pygame.QUIT))
            self.director.setScene(m)

        Level.processEvent(self, event)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:7,代码来源:LevelFour.py

示例8: __init__

 def __init__(self, player):
     Level.__init__(self, player)
     self.init_enemies()
     self.init_items()
     self.PLAYER_START = [72, 57]
     self.is_beatable = False
     self.init_labels()
开发者ID:mattgor123,项目名称:CS255-ActionRPM,代码行数:7,代码来源:Level_2.py

示例9: load

    def load(self):
        # get list of segment files
        seg_file_pattern = os.path.join('assets','data','segdata','*[0-9].gif')
        seg_files = glob.glob(seg_file_pattern)

        # load segments into pygame surfaces
        # creates Segments
        # groups segments into levels
        lvl_groups = {}
        for seg_file in seg_files:
            seg_id = string.split(os.path.basename(seg_file),'.')[1]
            filename = os.path.basename(seg_file)
            lvl_id = filename[:string.find(filename,'.')]

            segment = Segment(lvl_id + '.' + seg_id)
            
            if (lvl_id not in lvl_groups):
                lvl_groups[lvl_id] = [segment]
            else:
                lvl_groups[lvl_id].append(segment)

        # create Levels
        for lvl_id in lvl_groups.keys():
            segments = lvl_groups[lvl_id]
            level = Level(lvl_id)
            for segment in segments:
                level.add_segment(segment)
            level.connect()
            self.levels[lvl_id] = level
开发者ID:churay,项目名称:zol,代码行数:29,代码来源:World.py

示例10: GameSpace

class GameSpace():

    def __init__(self):
        pygame.init()
        pygame.display.set_caption('Tanks')
        self.screen = pygame.display.set_mode(WIN_DISPLAY)
        self.background = Surface(WIN_DISPLAY)
        self.background.fill(Color(WIN_COLOR))

        self.timer = pygame.time.Clock()

        self.cf = ClientConnFactory(self)
        reactor.connectTCP(HOST,PORT,self.cf)
        reactor.run()

    def start(self):
        self.player = Player(100,100)# инициализируем Tank
        self.level1 = Level('level1.txt')#Инициализируем level1
        self.level1.load_level()

        #self.test_loop()


    def tick(self):
        print 'tick'
        for e in pygame.event.get():
            if e.type == QUIT:
                reactor.stop()
                raise SystemExit, "Quit"
            if e.type == KEYDOWN and e.key == K_LEFT:
                print '*'*100
                print "KEYDOWN K_LEFT"
                self.sendData("KEYDOWN LEFT! Yu-hooo")
            print 'end tick for'
        #self.sendData("**********************Hello!")
        self.screen.blit(self.background,(0,0))
        self.screen.blit(self.player.image,(100,100))
        pygame.display.update()


    def sendData(self, data):
        self.cf.conn.send(data)

    def addData(self, data):
        print "INCOMING: ", data

    def test_loop(self):
        while True:
            for e in pygame.event.get():
                if e.type == QUIT:
                     raise SystemExit, "QUIT"
                if e.type == KEYDOWN and e.key == K_LEFT:
                    print "KEYDOWN K_LEFT"


            self.screen.blit(self.background,(0,0))
            self.screen.blit(self.player.image,(100,100))
            pygame.display.update()
开发者ID:Oleksandr1,项目名称:tank,代码行数:58,代码来源:main.py

示例11: processEvent

    def processEvent(self, event):
        if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
            nextLevel = LevelTwo(self.director, self.player)
            self.director.setScene(nextLevel)
        if event.type == pygame.KEYDOWN and event.key == pygame.K_F1:
            self.door.setActive(True)
            # nextLevel = LevelOneB(self.director, self.player)
            # self.director.setScene(nextLevel)

        Level.processEvent(self, event)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:10,代码来源:LevelOneA.py

示例12: initLevel

def initLevel(level_set,level):
	# Create an instance of this Level
	global myLevel
	myLevel = Level(level_set,level)

	# Draw this level
	drawLevel(myLevel.getMatrix())
	
	global target_found
	target_found = False
开发者ID:kazantzakis,项目名称:pySokoban,代码行数:10,代码来源:sokoban.py

示例13: processEvent

	def processEvent(self, event):
		if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
			nextLevel = LevelFour(self.director, self.player)
			self.director.setScene(nextLevel)

		if event.type == pygame.USEREVENT and event.code == MRHDEAD:
			nextLevel = LevelFour(self.director, self.player)
			self.director.setScene(nextLevel)

		Level.processEvent(self, event)
开发者ID:dgalaktionov,项目名称:Aleph,代码行数:10,代码来源:LevelThree.py

示例14: playerTests

class playerTests(unittest.TestCase):
    
    def setUp(self):
        self.level = Level(200, 200)

        self.level.gen_base(60, 60)

        board = self.level.board
        self.player = Player(60, 60, '@', board)
        self.level.board[self.player.y][self.player.x - 1] = ' '
        self.level.board[self.player.y][self.player.x + 1] = ' '
        self.level.board[self.player.y - 1][self.player.x] = ' '
        self.level.board[self.player.y + 1][self.player.x] = ' '


    def test_playercantgothroughwalls(self):
        initx = self.player.x
        inity = self.player.y

        #Set a wall to the left of player
        self.level.board[self.player.y][self.player.x-1] = '+'
        self.player.move('a')
        assert self.player.y == inity and self.player.x == initx
        
    def test_playercanmoveleft(self):
        initx = self.player.x
        inity = self.player.y
        print(inity, " ", self.player.y)
        print(initx, " ", self.player.x)


        self.player.move('a')
        assert self.player.y == inity and self.player.x == initx -1
        
        
    def test_playercanmoveright(self):
        initx = self.player.x
        inity = self.player.y
        self.player.move('d')
        assert self.player.y == inity and self.player.x == initx +1
    
        
    def test_playercanmoveup(self):
        initx = self.player.x
        inity = self.player.y
        self.player.move('w')
        assert self.player.y == inity - 1 and self.player.x == initx
        
        
    def test_playercanmovedown(self):
        initx = self.player.x
        inity = self.player.y
        self.player.move('s')
        assert self.player.y == inity +1 and self.player.x == initx
开发者ID:NRoos,项目名称:lazy-stronghold,代码行数:54,代码来源:test.py

示例15: readDetailsForCustomLevel

 def readDetailsForCustomLevel(self):
     """
     This method allows to the user create and use a new customized level
     to generate Sudoku games.
     Note. This level will not be stored in the .xml file
     """
     userLevel = Level(0, 0, "Custom level")
     userLevel.setBottomLimit = int(self.getUserInput("\
     Please enter a number to set the minimun limit for empty spaces"))
     userLevel.setTopLimit = int(self.getUserInput("\
     Please enter a number to set the maximun limit for empty spaces"))
     return userLevel
开发者ID:villarrealp,项目名称:sudokuD,代码行数:12,代码来源:ConsoleMenu.py


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