Сделал повороты текстура в зависимости от направления движения
This commit is contained in:
@@ -16,9 +16,10 @@ def to_iso(tile_list):
|
||||
return tile_list
|
||||
|
||||
class Player(arcade.Sprite):
|
||||
def __init__(self,sprite):
|
||||
def __init__(self,sprite,lookLeft=True):
|
||||
super().__init__()
|
||||
self.texture = sprite.texture
|
||||
self.lookLeft = lookLeft
|
||||
self.center_x = sprite.center_x
|
||||
self.center_y = sprite.center_y
|
||||
self.move_timer = 0
|
||||
@@ -38,8 +39,15 @@ class Player(arcade.Sprite):
|
||||
self.move(-1,1,delta_time)
|
||||
|
||||
def move(self,dx,dy,dt):
|
||||
self.lookLeft = False if self.change_x > 0 else True
|
||||
self.change_x = dx * TILE_WIDTH//2*dt
|
||||
self.change_y = dy * TILE_HEIGHT//2*dt
|
||||
if self.change_x > 0 and self.lookLeft:
|
||||
self.texture = self.texture.flip_left_right()
|
||||
self.lookLeft = False
|
||||
elif self.change_x < 0 and not self.lookLeft:
|
||||
self.texture = self.texture.flip_left_right()
|
||||
self.lookLeft = True
|
||||
|
||||
|
||||
class MainView(arcade.View):
|
||||
|
||||
Reference in New Issue
Block a user