本文整理汇总了Python中position.Position.x方法的典型用法代码示例。如果您正苦于以下问题:Python Position.x方法的具体用法?Python Position.x怎么用?Python Position.x使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.x方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resize
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import x [as 别名]
def resize(self, x, y):
direction = self.direction
position = Position()
position.x = self.x
position.y = self.y
size = Size()
size.width = self.width
size.height = self.height
side = get_side(direction)
if side is not VERTICAL:
size.width = x - self.pivot.x
if size.width < 0:
position.x = x
else:
position.x = self.pivot.x
if side is not HORIZONTAL:
size.height = y - self.pivot.y
if size.height < 0:
position.y = y
else:
position.y = self.pivot.y
self.set_position(position)
self.set_size(size)
示例2: __init__
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import x [as 别名]
class Player:
def __init__(self, parent=None, x=400, y=300, sprite=None,
level_max_x=MAP_WIDTH-WINDOW_WIDTH, level_max_y=MAP_HEIGHT-WINDOW_HEIGHT,
level_min_x=WINDOW_WIDTH/2, level_min_y=WINDOW_HEIGHT/2):
self.parent = parent
self.pos = Position(pos=[x, y])
self.vel = Position(pos=[0, 0])
self.speed = 1
self.sprite = sprite
self.max_pos = Position(level_max_x, level_max_y)
self.min_pos = Position(level_min_x, level_min_y)
self.stamina = 100
self.stamina_fade = 0
if sprite is not None:
self.sprite.move_sprite(self.pos)
self.delay = 8
self.timer = QTimer()
self.timer.timeout.connect(self.simulate)
self.timer.setInterval(self.delay)
self.timer.start()
def set_state(self, state):
self.sprite.set_state(state)
def state(self):
return self.sprite.state
def mov(self):
print('Stamina : %s' % round(self.stamina, 2))
self.stamina += self.stamina_fade
if self.stamina > 100:
self.stamina = 100
if self.stamina < 0:
self.stamina = 0
self.speed = 1
self.pos = self.pos + self.vel
if self.pos.x() < self.min_pos.x():
self.pos.x(self.min_pos.x() + self.speed)
if self.pos.y() < self.min_pos.y():
self.pos.y(self.min_pos.y() + self.speed)
if self.pos.x() > self.max_pos.x():
self.pos.x(self.max_pos.x() - self.speed)
if self.pos.y() > self.max_pos.y():
self.pos.y(self.max_pos.y() - self.speed)
def simulate(self):
self.sprite.move_sprite(self.pos)
self.mov()
示例3: funcVisit
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import x [as 别名]
def funcVisit(self, x, y):
pos = Position(x, y)
if pos.x < 0:
pos.x = 0
if pos.y < 0:
pos.y = 0
self.map[pos.x][pos.y].visible = True
self.map[pos.x][pos.y].discovered = True
示例4: set_static
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import x [as 别名]
def set_static(self, pix_pos=None, x_shift=None, y_shift=None, x_offset=0, y_offset=0,
z=1, scale=1.0):
if pix_pos is None:
pix_pos = Position()
else:
pix_pos = Position(pos=pix_pos)
if x_shift is None or y_shift is None:
self.states['static']['pix'].append(self.sheet)
else:
self.states['static']['pix'].append(self.sheet.copy(pix_pos.x(), pix_pos.y(), x_shift, y_shift))
self.pix = self.parent.m_scene.addPixmap(self.states['static']['pix'][0])
self.pix.setPos(self.pos.x(), self.pos.y())
self.pix.setOffset(x_offset, y_offset)
self.pix.setZValue(z)
self.pix.setScale(scale)
示例5: get_index_from_x_y
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import x [as 别名]
def get_index_from_x_y(self, x, y):
(horizontal, vertical) = self.get_aspect()
position = Position()
position.x = int((x - self.x) * pango.SCALE / horizontal)
position.y = int((y - self.y) * pango.SCALE / vertical)
return self.layout.xy_to_index(position.x, position.y)
示例6: __init__
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import x [as 别名]
class Sprite:
def __init__(self, pos=None, sheet=None, parent=None, width=None, height=None):
if pos is None:
self.pos = Position(pos=[0, 0])
else:
self.pos = Position(pos=pos)
self.parent = parent
self.width = width
self.height = height
self.sheet = QPixmap(sheet)
self.pix = None
self.states = {'static':
{'pix' : [],
'delay' : 1000}}
self.state = 'static'
self.step = 0
self.delay = 50
self.timer = QTimer()
self.timer.timeout.connect(self.animate)
self.timer.setInterval(self.delay)
self.timer.start()
def set_sheet(self, sheet):
self.sheet = QPixmap(sheet)
def set_static(self, pix_pos=None, x_shift=None, y_shift=None, x_offset=0, y_offset=0,
z=1, scale=1.0):
if pix_pos is None:
pix_pos = Position()
else:
pix_pos = Position(pos=pix_pos)
if x_shift is None or y_shift is None:
self.states['static']['pix'].append(self.sheet)
else:
self.states['static']['pix'].append(self.sheet.copy(pix_pos.x(), pix_pos.y(), x_shift, y_shift))
self.pix = self.parent.m_scene.addPixmap(self.states['static']['pix'][0])
self.pix.setPos(self.pos.x(), self.pos.y())
self.pix.setOffset(x_offset, y_offset)
self.pix.setZValue(z)
self.pix.setScale(scale)
def move_sprite(self, pos):
self.pos.set(pos)
self.pix.setPos(self.pos.x(), self.pos.y())
def set_state(self, state):
self.state = state
self.timer.setInterval(self.states[state]['delay'])
self.step = 0
self.pix.setPixmap(self.states[state]['pix'][self.step])
def add_state(self, name, maps=[], delay=50):
self.states[name] = {}
self.states[name]['pix'] = maps
self.states[name]['delay'] = delay
def animate(self):
self.step += 1
if self.step >= len(self.states[self.state]['pix']):
self.step = 0
#print('step:', self.step)
self.pix.setPixmap(self.states[self.state]['pix'][self.step])