本文整理汇总了Python中tile.Tile.get_tile方法的典型用法代码示例。如果您正苦于以下问题:Python Tile.get_tile方法的具体用法?Python Tile.get_tile怎么用?Python Tile.get_tile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tile.Tile
的用法示例。
在下文中一共展示了Tile.get_tile方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def __init__(self, tile, source, game):
super(Character, self).__init__(source=source, pos=(Tile.get_tile(tile).x, Tile.get_tile(tile).y))
self.speed_x, self.speed_y = CHAR_SPEED_X, CHAR_SPEED_Y
self.deacc = CHAR_DEACCELERATION
self.velocity_x = 0
self.velocity_y = 0
self.tile = tile
self.game = game
self.moving = False
self.game.add_widget(self)
示例2: move
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def move(self, direction):
if direction == 12:
tile_difference = Tile.V
speed = self.speed_y
elif direction == 3:
tile_difference = Tile.H
speed = self.speed_x
elif direction == 6:
tile_difference = -Tile.V
speed = -self.speed_y
elif direction == 9:
tile_difference = -Tile.H
speed = -self.speed_x
else:
raise ValueError("Incorrect direction in Box.move()")
target_tile = Tile.get_tile(self.tile + tile_difference)
if target_tile.walkable:
for box in self.game.boxes:
if box.tile == self.tile + tile_difference:
return False
if direction in (6, 12): self.velocity_y = speed
if direction in (9, 3): self.velocity_x = speed
self.tile += tile_difference
return True
return False
示例3: get_surrounding_tiles
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def get_surrounding_tiles(base_node):
array =(
(base_node.number + N),
(base_node.number + NE),
(base_node.number + E),
(base_node.number + SE),
(base_node.number + S),
(base_node.number + SW),
(base_node.number + W),
(base_node.number + NW),
)
tiles = []
onn = base_node.number
diagonals = [onn + NE, onn + NW, onn + SE, onn + SW]
for tile_number in array:
surrounding_tile = Tile.get_tile(tile_number)
if tile_number not in range(1, Tile.total_tiles + 1):
continue
if surrounding_tile.walkable and surrounding_tile not in closed_list:
# tiles.append(surrounding_tile) # Diagonal movement
tiles = blocky(tiles, diagonals, surrounding_tile)
return tiles
示例4: __init__
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def __init__(self, level):
super(Game, self).__init__()
self.level = Level.load_level(level)
self.background = Sprite(source='img/background.PNG')
self.size = self.background.size
self.player = None
self.boxes = []
# Initiate the game by creating tiles
Tile.make_tiles(self.size, self.level)
# Add bg widget first to not cover other sprites
self.add_widget(self.background)
# Add proper widgets for every non-empty tile in the Tile.List
for tile in Tile.List:
if tile.type != 'empty':
if Tile.get_tile(tile.number - Tile.V).walkable:
self.add_widget(Sprite(
source=Tile.image_files[tile.type],
pos=(tile.x, tile.y)), index=2)
else:
self.add_widget(Sprite(
source=Tile.image_files[tile.type + '_edge'],
pos=(tile.x, tile.y - SPRITE_EDGE_OFFSET)))
for tile in self.level.boxspawn:
self.boxes.append(Box(tile, self))
self.player = Player(self.level.playerspawn, self)
self.fps_lab = Label(
text='FPS: ' + str(Clock.get_rfps()),
pos=(2, self.height - 110),
font_name=APP_FONT,
font_size=18,
color=(240, 240, 240, 0.8))
self.add_widget(self.fps_lab)
self.add_widget(Label(
text="Level {}".format(self.level.level),
pos=(0, self.height - 80),
font_name=APP_FONT,
font_size=18,
color=(240, 240, 240, 0.8)))
# Schedule an interval for the game update function
Clock.schedule_interval(self.update, 1.0/60.0)
示例5: spawn
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def spawn(total_frames, FPS):
if total_frames % (FPS) == 0:
if total_frames % (FPS * 6) == 0:
r = randint(0, 2)
sounds = [pygame.mixer.Sound('audio/zs1.ogg'),
pygame.mixer.Sound('audio/zs2.ogg'),
pygame.mixer.Sound('audio/zs3.ogg')]
sound = sounds[ r ]
# TURNED OFF SOUND FOR DEBUGGING
# sound.play()
r = randint(0, len(Zombie.spawn_tiles) - 1)
tile_num = Zombie.spawn_tiles[r]
spawn_node = Tile.get_tile(tile_num)
Zombie(spawn_node.x, spawn_node.y)
示例6: userInteraction
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def userInteraction(screen, survivor):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_e:
survivor.current += 1
survivor.current %= 3
keys = pygame.key.get_pressed()
if keys[pygame.K_w]: # North
future_tile_number = survivor.get_number() - Tile.V
if future_tile_number in range(1, Tile.total_tiles + 1):
future_tile = Tile.get_tile(future_tile_number)
if future_tile.walkable:
survivor.set_target(future_tile)
survivor.rotate('n')
# survivor.y -= survivor.height
if keys[pygame.K_s]: # South
future_tile_number = survivor.get_number() + Tile.V
if future_tile_number in range(1, Tile.total_tiles + 1):
future_tile = Tile.get_tile(future_tile_number)
if future_tile.walkable:
survivor.set_target(future_tile)
survivor.rotate('s')
# survivor.y += survivor.height
if keys[pygame.K_a]: # West
future_tile_number = survivor.get_number() - Tile.H
if future_tile_number in range(1, Tile.total_tiles + 1):
future_tile = Tile.get_tile(future_tile_number)
if future_tile.walkable:
survivor.set_target(future_tile)
survivor.rotate('w')
# survivor.x -= survivor.width
if keys[pygame.K_d]: # East
future_tile_number = survivor.get_number() + Tile.H
if future_tile_number in range(1, Tile.total_tiles + 1):
future_tile = Tile.get_tile(future_tile_number)
if future_tile.walkable:
survivor.set_target(future_tile)
survivor.rotate('e')
# survivor.x += survivor.width
if keys[pygame.K_LEFT]:
survivor.rotate('w')
Bullet(survivor.centerx, survivor.centery, -10, 0, 'w', survivor.get_bullet_type() )
elif keys[pygame.K_RIGHT]:
survivor.rotate('e')
Bullet(survivor.centerx, survivor.centery, 10, 0, 'e', survivor.get_bullet_type() )
elif keys[pygame.K_UP]:
survivor.rotate('n')
Bullet(survivor.centerx, survivor.centery, 0, -10, 'n', survivor.get_bullet_type() )
elif keys[pygame.K_DOWN]:
survivor.rotate('s')
Bullet(survivor.centerx, survivor.centery, 0, 10, 's', survivor.get_bullet_type() )
示例7: get_tile
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def get_tile(self):
return Tile.get_tile(self.get_number())
示例8: move_to_tile
# 需要导入模块: from tile import Tile [as 别名]
# 或者: from tile.Tile import get_tile [as 别名]
def move_to_tile(self, tilenum):
tile = Tile.get_tile(tilenum)
self.x, self.y = tile.x, tile.y