-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclouds.py
More file actions
26 lines (23 loc) · 860 Bytes
/
clouds.py
File metadata and controls
26 lines (23 loc) · 860 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
import pygame
import random
class Cloud(pygame.sprite.Sprite):
def __init__(self, x, y, image_path):
super().__init__()
self.image = pygame.image.load(image_path)
self.rect = self.image.get_rect()
self.rect.topleft = (x, y)
def create_clouds(num_clouds):
cloud_images = [
"assets/environment/small cloud 1.png",
"assets/environment/small cloud 2.png",
"assets/environment/big cloud 1.png",
"assets/environment/big cloud 2.png"
]
clouds = pygame.sprite.Group()
for i in range(num_clouds):
x = random.randint(50, 2000) # Adjust as needed based on your screen width
y = random.randint(0, 100) # Adjust as needed based on your screen height
image_path = random.choice(cloud_images)
cloud = Cloud(x, y, image_path)
clouds.add(cloud)
return clouds