You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
788 B
24 lines
788 B
6 months ago
|
import os
|
||
|
|
||
|
import pygame
|
||
|
import random
|
||
|
|
||
|
from common_func import get_base_path
|
||
|
|
||
|
|
||
|
class Sun(pygame.sprite.Sprite):
|
||
|
def __init__(self, rect):
|
||
|
super(Sun, self).__init__()
|
||
|
self.image = pygame.image.load(os.path.join(get_base_path(), 'images/Sun/Sun_01.png')).convert_alpha()
|
||
|
self.images = [
|
||
|
pygame.image.load(os.path.join(get_base_path(), 'images/Sun/Sun_{:02d}.png'.format(i))).convert_alpha()
|
||
|
for i in range(1, 14)]
|
||
|
self.rect = self.images[1].get_rect()
|
||
|
offset_top = random.randint(-25, 25)
|
||
|
offset_left = random.randint(-25, 25)
|
||
|
self.rect.top = rect.top + offset_top
|
||
|
self.rect.left = rect.left + offset_left
|
||
|
|
||
|
def update(self, *args):
|
||
|
self.image = self.images[args[0] % len(self.images)]
|