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


Python Level.gen_base方法代码示例

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


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

示例1: playerTests

# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import gen_base [as 别名]
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,代码行数:56,代码来源:test.py

示例2: LevelTests

# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import gen_base [as 别名]
class LevelTests(unittest.TestCase):
    
    def setUp(self):
        self.width = 150
        self.height = 200
        self.level = Level(self.width, self.height)
    
    def test_width(self):
        assert self.level.width == self.width
            
    def test_height(self):
        assert self.level.height == self.height
        
    def test_genbase_outofbounds(self):
        self.level.gen_base(120, 120)
        assert self.level.board[2][2] == self.level.outofboundschar
        
    #outofbounds is 40 characters, so 41 should always be inbound
    def test_genbase_inbounds(self):
        self.level.gen_base(120, 120)
        assert self.level.board[41][41] == self.level.wallchar
        
    def test_genbase_adds_room(self):
        initial = len(self.level.rooms)
        self.level.gen_base(120, 120)
        aftergen = len(self.level.rooms)
        
        assert initial == 0 and aftergen == 1
开发者ID:NRoos,项目名称:lazy-stronghold,代码行数:30,代码来源:test.py

示例3: Level

# 需要导入模块: from Level import Level [as 别名]
# 或者: from Level.Level import gen_base [as 别名]
#benchmarking time
inittime = time.clock()

#World dimensions
width = 200
height = 200

#Inital spawn point of the player
playerx = 60
playery = 60
playercharacter = '@'

#inital level
level1 = Level(width, height)
level1.gen_base(playerx, playery)

level1.carve()

level1.player_room()

#Try to create "rooms" amount of randomly placed non-overlapping rooms
rooms = 30000
level1.gen_rooms(rooms)

board = level1.board

player = Player(playerx, playery, playercharacter, board)

def printboard():
    #set the playercharacter to the board for drawing
开发者ID:NRoos,项目名称:lazy-stronghold,代码行数:32,代码来源:Main.py


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