add tree shake
This commit is contained in:
parent
a0d655b274
commit
a5b9d062e2
1 changed files with 17 additions and 4 deletions
21
creeper.py
21
creeper.py
|
|
@ -35,8 +35,11 @@ class TreeSprite:
|
|||
self.flip = flip
|
||||
self.surf = surf
|
||||
self.leafs = [Leaf(self, self.surf, (x + 25, y + 25)) for i in range(2)]
|
||||
self.shaking = 0
|
||||
|
||||
def shake(self):
|
||||
if self.shaking == 0:
|
||||
self.shaking = 10
|
||||
self.leafs.extend(
|
||||
[
|
||||
Leaf(
|
||||
|
|
@ -52,6 +55,13 @@ class TreeSprite:
|
|||
]
|
||||
)
|
||||
|
||||
@property
|
||||
def rotate(self):
|
||||
if self.shaking == 0:
|
||||
return 0
|
||||
self.shaking -= 1
|
||||
return random.randint(-15, 15)
|
||||
|
||||
@property
|
||||
def rect(self):
|
||||
return pygame.Rect(
|
||||
|
|
@ -64,10 +74,13 @@ class TreeSprite:
|
|||
def draw(self):
|
||||
if self.health > 0:
|
||||
self.surf.blit(
|
||||
pygame.transform.flip(
|
||||
pygame.transform.scale(self.image, (self.scale, self.scale)),
|
||||
self.flip,
|
||||
False,
|
||||
pygame.transform.rotate(
|
||||
pygame.transform.flip(
|
||||
pygame.transform.scale(self.image, (self.scale, self.scale)),
|
||||
self.flip,
|
||||
False,
|
||||
),
|
||||
self.rotate,
|
||||
),
|
||||
(self.x, self.y),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue