diff --git a/Cloud.py b/Cloud.py index 8755491..85f11bf 100644 --- a/Cloud.py +++ b/Cloud.py @@ -5,20 +5,86 @@ Cloud entity class import pygame import random +import os class Cloud(pygame.sprite.Sprite): + imgDir = os.path.join(os.path.dirname(__file__), 'data') + cloudImage = pygame.image.load( + os.path.join(imgDir, 'cloud.png') + )#.convert() + images = ( + pygame.transform.scale( + cloudImage.subsurface((0, 0, 128, 32)), (512, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((128, 0, 128, 32)), (512, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((256, 0, 128, 32)), (512, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((0, 32, 128, 32)), (512, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((128, 32, 128, 32)), (512, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((256, 32, 128, 32)), (512, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((0, 64, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((96, 64, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((192, 64, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((288, 64, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((0, 96, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((96, 96, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((192, 96, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((288, 96, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((0, 128, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((96, 128, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((192, 128, 96, 32)), (384, 128) + ), + pygame.transform.scale( + cloudImage.subsurface((288, 128, 96, 32)), (384, 128) + ), + ) + for image in images: + image.set_colorkey((255,0,255)) + def __init__(self, mainGameClass, cloudType): pygame.sprite.Sprite.__init__(self) self.type = cloudType self.mainGameClass = mainGameClass - self.image = pygame.Surface((random.randint(150, 350), - random.randint(50, 150))) + self.image = Cloud.images[random.randint(0, len(Cloud.images)-1)] - color = 255 - 15 * (3-cloudType) - self.image.fill((color, color, color)) + # self.image = pygame.Surface((random.randint(128, 512), + # random.randint(32, 128))) + + # color = 255 - 15 * (3-cloudType) + # self.image.fill((color, color, color)) self.rect = self.image.get_rect() self.rect.center = ( diff --git a/data/cloud.png b/data/cloud.png new file mode 100644 index 0000000..6b5c9b9 Binary files /dev/null and b/data/cloud.png differ diff --git a/data/cloud.xcf b/data/cloud.xcf new file mode 100644 index 0000000..ce1e838 Binary files /dev/null and b/data/cloud.xcf differ