-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nofel
committed
Feb 20, 2024
1 parent
dae316f
commit 2675c63
Showing
3 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import random | ||
|
||
class Cloud: | ||
def __init__(self, pos, img, speed, depth): | ||
self.pos = list(pos) | ||
self.img = img | ||
self.speed = speed | ||
self.depth = depth | ||
|
||
def update(self): | ||
self.pos[0] += self.speed | ||
|
||
def render(self, surf, offset=(0,0)): | ||
render_pos = (self.pos[0] - offset[0] * self.depth, self.pos[1] - offset[1] * self.depth) | ||
surf.blit(self.img, (render_pos[0] % (surf.get_width() + self.img.get_width()) - self.img.get_width(), render_pos[1] % (surf.get_height() + self.img.get_height()) - self.img.get_height())) | ||
|
||
class Clouds: | ||
def __init__(self, cloud_imgs, count=16): | ||
self.clouds = [] | ||
|
||
for i in range(count): | ||
self.clouds.append(Cloud((random.random() * 9999, random.random() * 9999), random.choice(cloud_imgs), random.random() * 0.05 + 0.05, random.random() * 0.6 + 0.2)) | ||
self.clouds.sort(key=lambda x: x.depth) | ||
|
||
def update(self): | ||
for cloud in self.clouds: | ||
cloud.update() | ||
|
||
def render(self, surf, offset=(0,0)): | ||
for cloud in self.clouds: | ||
cloud.render(surf, offset) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters