46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from gamedata.objects.base import BaseObject
|
|
|
|
import math
|
|
|
|
class Skies(BaseObject):
|
|
|
|
def __init__(self,game,basesky="skies/base.png",nightsky="skies/night.png",daysky="skies/day.png"):
|
|
super().__init__(0,0,game,game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT)
|
|
size = [game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT]
|
|
self.basesky = game.pygame.transform.scale(game.sprite_lib[basesky],size)
|
|
self.nightsky = game.pygame.transform.scale(game.sprite_lib[nightsky],size)
|
|
self.daysky = game.pygame.transform.scale(game.sprite_lib[daysky],size)
|
|
|
|
self.blackrect = game.pygame.Surface(size)
|
|
self.blackrect.fill([0]*3)
|
|
|
|
self.speed = 0.02
|
|
self.timeelapsed = 0
|
|
|
|
self.depth = -3
|
|
|
|
self.blackrectalpha = 0.5
|
|
|
|
self.handlepause = True
|
|
|
|
def step(self):
|
|
|
|
self.timeelapsed+=self.game.dt
|
|
|
|
self.cosvalue = math.cos(self.timeelapsed*self.speed)
|
|
|
|
def draw(self):
|
|
|
|
self.game.window.blit(self.basesky,[0,0])
|
|
if self.cosvalue<0:
|
|
self.nightsky.set_alpha(-self.cosvalue*255)
|
|
self.game.window.blit(self.nightsky,[0,0])
|
|
else:
|
|
self.daysky.set_alpha(self.cosvalue*255)
|
|
self.game.window.blit(self.daysky,[0,0])
|
|
|
|
def afterdraw(self):
|
|
if self.cosvalue<0:
|
|
self.blackrect.set_alpha(-self.cosvalue*255*self.blackrectalpha)
|
|
self.game.realwindow.blit(self.blackrect,[0,0])
|