-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseaweed.py
More file actions
33 lines (27 loc) · 961 Bytes
/
seaweed.py
File metadata and controls
33 lines (27 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import random
import pygame
from utils import IMAGES
class Seaweed(pygame.sprite.Sprite):
def __init__(self, allsprites, x_pos, y_pos):
super().__init__()
self.image = IMAGES["spr_seaweed"]
self.rect = self.image.get_rect()
self.rect.topleft = x_pos, y_pos
self.seaweed_animate_timer = random.randint(0, 30)
allsprites.add(self)
def update(self):
self.seaweed_animate_timer += 1
seaweed_images = [
IMAGES["spr_seaweed"],
IMAGES["spr_seaweed_left"],
IMAGES["spr_seaweed_right"],
]
if 15 < self.seaweed_animate_timer < 30:
self.image = seaweed_images[1]
if self.seaweed_animate_timer >= 30:
self.image = seaweed_images[2]
if self.seaweed_animate_timer > 45:
self.seaweed_animate_timer = 0
self.image = seaweed_images[0]
def remove_sprite(self):
self.kill()