Added day cycle
This commit is contained in:
parent
2ca249f666
commit
b5f893b51e
@ -13,3 +13,7 @@ All the textures are edited by myself to fit the [Famicube palette](https://losp
|
|||||||
## Clouds
|
## Clouds
|
||||||
|
|
||||||
[Jetrel - OpenGameArt](https://opengameart.org/content/old-frogatto-clouds)
|
[Jetrel - OpenGameArt](https://opengameart.org/content/old-frogatto-clouds)
|
||||||
|
|
||||||
|
## Sky gradients
|
||||||
|
|
||||||
|
[rh0 - OpenGameArt](https://opengameart.org/content/18-gradient-skies-640x480)
|
||||||
|
BIN
gamedata/assets/skies/base.png
Normal file
BIN
gamedata/assets/skies/base.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
gamedata/assets/skies/day.png
Normal file
BIN
gamedata/assets/skies/day.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
BIN
gamedata/assets/skies/night.png
Normal file
BIN
gamedata/assets/skies/night.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
@ -2,6 +2,7 @@ from gamedata.objects.base import BaseObject
|
|||||||
from gamedata.objects.ingame.spawner import Spawner
|
from gamedata.objects.ingame.spawner import Spawner
|
||||||
from gamedata.objects.ingame.tiles import Tiles
|
from gamedata.objects.ingame.tiles import Tiles
|
||||||
from gamedata.objects.ingame.clouds import Clouds
|
from gamedata.objects.ingame.clouds import Clouds
|
||||||
|
from gamedata.objects.ingame.skies import Skies
|
||||||
|
|
||||||
class Manager(BaseObject):
|
class Manager(BaseObject):
|
||||||
def __init__(self,game):
|
def __init__(self,game):
|
||||||
@ -22,6 +23,9 @@ class Manager(BaseObject):
|
|||||||
self.endrect = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT))
|
self.endrect = game.pygame.Surface((game.DISPLAY_WIDTH,game.DISPLAY_HEIGHT))
|
||||||
self.endrect.fill([0]*3)
|
self.endrect.fill([0]*3)
|
||||||
|
|
||||||
|
# Sky gradients
|
||||||
|
self.game.gameloop.summon(Skies(game))
|
||||||
|
|
||||||
# Clouds in the background
|
# Clouds in the background
|
||||||
self.clouds = Clouds(game,game.DISPLAY_WIDTH,speed=30,cameraratio=0.8)
|
self.clouds = Clouds(game,game.DISPLAY_WIDTH,speed=30,cameraratio=0.8)
|
||||||
self.cloudsdark = Clouds(game,game.DISPLAY_WIDTH,speed=10,cameraratio=0.4,spritename="cloudsdark.png")
|
self.cloudsdark = Clouds(game,game.DISPLAY_WIDTH,speed=10,cameraratio=0.4,spritename="cloudsdark.png")
|
||||||
|
43
gamedata/objects/ingame/skies.py
Normal file
43
gamedata/objects/ingame/skies.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
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 = -2
|
||||||
|
|
||||||
|
self.blackrectalpha = 0.5
|
||||||
|
|
||||||
|
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])
|
Loading…
Reference in New Issue
Block a user