Added background clouds
This commit is contained in:
parent
df215051f7
commit
8547c71d5c
@ -9,3 +9,7 @@ All the textures are edited by myself to fit the [Famicube palette](https://losp
|
|||||||
## Little characters
|
## Little characters
|
||||||
|
|
||||||
[GraphxKid - OpenGameArt](https://opengameart.org/content/arcade-platformer-assets)
|
[GraphxKid - OpenGameArt](https://opengameart.org/content/arcade-platformer-assets)
|
||||||
|
|
||||||
|
## Clouds
|
||||||
|
|
||||||
|
[Jetrel - OpenGameArt](https://opengameart.org/content/old-frogatto-clouds)
|
||||||
|
BIN
gamedata/assets/clouds.png
Normal file
BIN
gamedata/assets/clouds.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
BIN
gamedata/assets/cloudsdark.png
Normal file
BIN
gamedata/assets/cloudsdark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@ -12,8 +12,8 @@ class BackgroundDrawer(BaseObject):
|
|||||||
game = self.game
|
game = self.game
|
||||||
self.tilew = sprite.get_width()
|
self.tilew = sprite.get_width()
|
||||||
self.tileh = sprite.get_height()
|
self.tileh = sprite.get_height()
|
||||||
nbw = round(self.rect[2]/self.tilew+1.5)
|
nbw = round(self.rect[2]/self.tilew+2)
|
||||||
nbh = round(self.rect[3]/self.tileh+1.5)
|
nbh = round(self.rect[3]/self.tileh+2)
|
||||||
sw = nbw*self.tileh
|
sw = nbw*self.tileh
|
||||||
sh = nbh*self.tileh
|
sh = nbh*self.tileh
|
||||||
self.sprite = game.pygame.Surface((sw,sh),game.pygame.SRCALPHA)
|
self.sprite = game.pygame.Surface((sw,sh),game.pygame.SRCALPHA)
|
||||||
|
@ -8,5 +8,5 @@ class MovingBackground(BackgroundDrawer):
|
|||||||
self.spdy = spdy
|
self.spdy = spdy
|
||||||
|
|
||||||
def step(self):
|
def step(self):
|
||||||
self.rect[0]+=self.spdx
|
self.rect[0]+=self.spdx*self.game.dt
|
||||||
self.rect[1]+=self.spdy
|
self.rect[1]+=self.spdy*self.game.dt
|
||||||
|
21
gamedata/objects/ingame/clouds.py
Normal file
21
gamedata/objects/ingame/clouds.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
from gamedata.objects.base import BaseObject
|
||||||
|
|
||||||
|
class Clouds(BaseObject):
|
||||||
|
|
||||||
|
def __init__(self,game,minwidth,speed=30,cameraratio=1,spritename="clouds.png"):
|
||||||
|
super().__init__(0,0,game)
|
||||||
|
self.sprite = game.sprite_lib[spritename]
|
||||||
|
self.speed = speed
|
||||||
|
self.minwidth = minwidth
|
||||||
|
self.cameraratio = cameraratio
|
||||||
|
depth = -1
|
||||||
|
self.horoffset = 0
|
||||||
|
|
||||||
|
def step(self):
|
||||||
|
self.horoffset+=self.game.dt*self.speed
|
||||||
|
|
||||||
|
def draw(self):
|
||||||
|
offset = (self.horoffset-self.game.globals["camerax"]*self.cameraratio)%self.sprite.get_width()
|
||||||
|
nbsprites = round((self.minwidth+offset)//self.sprite.get_width()+2)
|
||||||
|
for i in range(nbsprites):
|
||||||
|
self.game.window.blit(self.sprite,[(i-1)*self.sprite.get_width()+offset,0])
|
@ -1,6 +1,7 @@
|
|||||||
from gamedata.objects.base import BaseObject
|
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
|
||||||
|
|
||||||
class Manager(BaseObject):
|
class Manager(BaseObject):
|
||||||
def __init__(self,game):
|
def __init__(self,game):
|
||||||
@ -12,7 +13,7 @@ class Manager(BaseObject):
|
|||||||
self.speedmargin = 7
|
self.speedmargin = 7
|
||||||
self.stepmargin = 2
|
self.stepmargin = 2
|
||||||
self.spawntimer = game.lib.Timer(self.basetime) # Time elapsing each lemming spawn
|
self.spawntimer = game.lib.Timer(self.basetime) # Time elapsing each lemming spawn
|
||||||
self.deathtimer = game.lib.Timer(1) # Time betwin each life loss
|
self.deathtimer = game.lib.Timer(1) # Time between each life loss
|
||||||
self.started = False
|
self.started = False
|
||||||
self.invincible = False
|
self.invincible = False
|
||||||
self.scoreratio = 0.2 # Points earned per seconds and per lemming
|
self.scoreratio = 0.2 # Points earned per seconds and per lemming
|
||||||
@ -21,6 +22,12 @@ 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)
|
||||||
|
|
||||||
|
# Clouds in the background
|
||||||
|
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.game.gameloop.summon(self.cloudsdark)
|
||||||
|
self.game.gameloop.summon(self.clouds)
|
||||||
|
|
||||||
# Summon the tiles
|
# Summon the tiles
|
||||||
self.tiles = Tiles(288,0,game)
|
self.tiles = Tiles(288,0,game)
|
||||||
game.gameloop.summon(self.tiles)
|
game.gameloop.summon(self.tiles)
|
||||||
@ -59,8 +66,18 @@ class Manager(BaseObject):
|
|||||||
|
|
||||||
def afterdraw(self):
|
def afterdraw(self):
|
||||||
txtsurfacescore = self.game.fontfile.render("Score : "+str(int(self.score)),False,[150,255,150])
|
txtsurfacescore = self.game.fontfile.render("Score : "+str(int(self.score)),False,[150,255,150])
|
||||||
txtsurfacelives = self.game.fontfile.render("Lives : "+str(int(max(0,self.lives))),False,[255,150,150])
|
txtsurfacescoreblack = self.game.fontfile.render("Score : "+str(int(self.score)),False,[0]*3)
|
||||||
|
|
||||||
|
txtsurfacelives = self.game.fontfile.render("Lives : "+str(int(self.lives)),False,[255,150,150])
|
||||||
|
txtsurfacelivesblack = self.game.fontfile.render("Lives : "+str(int(self.lives)),False,[0]*3)
|
||||||
|
border = 2
|
||||||
|
for x in range(-border,border+1):
|
||||||
|
for y in range(-border,border+1):
|
||||||
|
self.game.realwindow.blit(txtsurfacescoreblack,[20+x,20+y])
|
||||||
self.game.realwindow.blit(txtsurfacescore,[20,20])
|
self.game.realwindow.blit(txtsurfacescore,[20,20])
|
||||||
|
for x in range(-border,border+1):
|
||||||
|
for y in range(-border,border+1):
|
||||||
|
self.game.realwindow.blit(txtsurfacelivesblack,[20+x,20*2+y+txtsurfacescore.get_height()])
|
||||||
self.game.realwindow.blit(txtsurfacelives,[20,20*2+txtsurfacescore.get_height()])
|
self.game.realwindow.blit(txtsurfacelives,[20,20*2+txtsurfacescore.get_height()])
|
||||||
|
|
||||||
self.endrect.set_alpha((1-self.endtimer.getratio())*255)
|
self.endrect.set_alpha((1-self.endtimer.getratio())*255)
|
||||||
|
Loading…
Reference in New Issue
Block a user