本文整理汇总了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
示例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
示例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